Reputation: 213
For various reasons my unit testing environment won't have access to the environment that's needed to start ignite. I don't need ignite to start for the test and I'd like for the code to just ignore the call to Ignition.start(). How do I do that?
I've tried mocking away ignition but when I try to mock away the start() method it throws an error.
when(ignitionMock.start())
This results in the following error:
org.mockito.exceptions.misusing.MissingMethodInvocationException: when() requires an argument which has to be 'a method call on a mock'. For example: when(mock.getArticles()).thenReturn(articles);
Also, this error might show up because: 1. you stub either of: final/private/equals()/hashCode() methods. Those methods cannot be stubbed/verified. Mocking methods declared on non-public parent classes is not supported. 2. inside when() you don't call method on mock but on some other object.
Upvotes: 1
Views: 531
Reputation: 311188
You could use doNothing()
:
doNothing().when(ignitionMock).start();
Upvotes: 1