1

I am trying to test the just the invocation of a final method to be verified. I do not want to execute that.

//First I spied the test class.
TestClass testClass =  spy(new TestClass());

//I did something like
doNothing().when(testClass ).method1(parameter);
...
//but in the following line I found the actual method1 is invoked and exceptions are thrown
verify(testClass ).method1(parameter);

How to just check the method1 invocation without executing when spied?

Thank You !

arghtype
  • 4,156
  • 11
  • 43
  • 57
user1438823
  • 1,243
  • 3
  • 18
  • 24
  • 1
    Can you include the actual TestClass in your question? It might explain things. For example, if method1 is final, you would get this behavior. – jhericks Mar 28 '14 at 16:09
  • 1
    See http://stackoverflow.com/questions/3793791/final-method-mocking – arghtype May 20 '14 at 07:33

0 Answers0