Nate Clingman
Nate Clingman

Reputation: 3

Is there a way to override a doReturn in Mockito?

I want to run a method even though in @Before I set

doReturn(mockResult).when(spyObject).getResult();

It makes sense to do that for all of my other test methods, but I want to test the getter and setter for result now. Is there a way to override the doReturn and force it to actually run the method, or should I just move the doReturn statement to the beginning of every test method?

Upvotes: 0

Views: 925

Answers (1)

varkashy
varkashy

Reputation: 385

you can try using callRealMethod

when(mock.someMethod()).thenCallRealMethod();

Upvotes: 1

Related Questions