Is it possible to initialize the object to test not on declaration but in each test case? I can't initialize the object on declaration because the parameters passed to the constructor are part of the test cases. I would need something as:
@TestSubject
private ClassUnderTest classUnderTest;
@Mock
private Collaborator mock;
@Test
public void test12() {
classUnderTest = new ClassUnderTest(1, 2);
replay(mock);
Integer result = classUnderTest.work(3, 4);
// Assertions
}
But if I do the above, Easymock complains:
java.lang.NullPointerException: Have you forgotten to instantiate classUnderTest?
I've taken a look at MockBuilder, but I don't see how it can help in this case.
Aucun commentaire:
Enregistrer un commentaire