lundi 7 octobre 2019

How do I verify a method is not called on a mock from within the scope of one test only?

I understand that I can verify(mock, times(0)).methodCall() and this works when I run my one test individually. The problem is that other tests within the file have interactions with this method and when I run all of the tests in the file I get an exception org.mockito.exceptions.verification.NeverWantedButInvoked: because another test had an interaction with the mock.

Is there a way to limit the verify() to only count the number of interactions from within the scope of one test method instead of counting interactions across all of the tests within the file?

Aucun commentaire:

Enregistrer un commentaire