mardi 26 avril 2016

How to debug mockito mocks/stubs/matchers?

During normal test development using mockito, I (and many others for sure) run into many situations where our when(service.doSomething(paramMatcher, paramMatcher2, ...).thenReturn(...) drives me crazy. So many combinations that are possible between lists, vargars, null values, etc. it is often hours spent just trying to get the formula right and even then I give up and just use any() with thenAnswer(manual matching).

How can I debug the parameter matching mechanism of mockito? For added difficulty, I run my tests using Mockito runner which means that I use annotation to initialize and automatically inject my mocked services.

Aucun commentaire:

Enregistrer un commentaire