MockitoAnnotations.initMocks(this);
In general, we use a BaseTest and call the method there and extend our tests from that BaseTest. Thus, the tests succeed when you run them separately. However, when you call them as suite, you may get the folowing error:
testClass cannot be null. For info how to use @Mock annotations see examples in javadoc for MockitoAnnotations class
I tried several approaches to fix this including using
MockitoTestNGListener.class
, none of which work. Then i find an article advising not to use inheritance in tests (http://www.petrikainulainen.net/programming/unit-testing/3-reasons-why-we-should-not-use-inheritance-in-our-tests/), removing inheritance and calling MockitoAnnotations.initMocks(this);
inside every test class worked :)
Hiç yorum yok:
Yorum Gönder