EasyMock: Mocked object is calling actual method

后端 未结 1 563
广开言路
广开言路 2021-01-12 01:40

I\'ve following code snippet in my unit test,

ClassToBeMocked mock = createMock(ClassToBeMocked.class); //I\'ve statically imported EasyMock.*
mock.callMetho         


        
相关标签:
1条回答
  • 2021-01-12 02:16

    This will happen if you are mocking a class with a 'final' method. EasyMock does not override a final method. If you cannot mock an interface, and you cannot change the method to non-final, you can use PowerMock along with EasyMock to get around this limitation. That specific use case is described here.

    0 讨论(0)
提交回复
热议问题