Note to self; Mockito cannot stub final methods
August 23rd, 2008
I realize this is clearly stated on the Mockito website, but it caught myself and my pair up for a little while. we were trying to stub out a ResourceBundle using Mockito and found that the unit test kept trying to find a concrete implementation of the ResourceBundle. The reason, we figured out is that the ResourceBundle.getString() method is final and Mockito cannot mock or stub final methods. Something to keep in mind when working with this mocking framework.
Categories: Java, Java Frameworks, Programming