Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EasyMock - do you have to reset() mocks after test?

I think the answer is yes, but I was unable to find anything definite in the easymock documentation.

I'm getting an error when first test is mocking a class, and then another test is using this class in a regular way. The class turns out to be mocked in the second test and fails with unexpected invocation.

Is there a way to automate the cleanup, besides using the EasyMockSupport and calling resetAll() in @After method (preferably something that doesn't have to be repeated in each class)?

like image 735
Jakub Bochenski Avatar asked Sep 19 '25 21:09

Jakub Bochenski


1 Answers

It seems you don't need to manually reset the mocks.

In my case the mocked class was stored in a static variable, once this was corrected the tests started running OK.

It would be nice if EasyMock reported the place where violated expectation was recorded - that would have made it much easier to find the source of the problem.

like image 109
Jakub Bochenski Avatar answered Sep 22 '25 11:09

Jakub Bochenski