Closed Vampire closed 8 years ago
It was probably a threading issue. I will consider adding a null check in that rollback method.
Calling tearDown() is something one should do only in the exceptional case where the mock-up needs to get undone at the middle of a test; apart from that it gets called automatically at the appropriate time.
Ok, thought so, thanks.
It was unlikely a threading issue as it was 100% reproducible.
I'm currently upgrading our JMockit 1.8 tests to JMockit 1.24.
One of my colleagues used the MockUps API in some strange way that I will try to rewrite, but nevertheless it triggered an NPE in JMockit that probably shouldn't be there. I fear I cannot really give a code sample. But basically there were some
MockUp
instance fields, those were assigned with mocks in a@Before
method, then in an@After
method theirtearDown()
methods were called (there is no sense in doing so, is there?) and in some of the Tests alsotearDown()
was called and a newMockUp
instance created and assigned to the instance field.This resulted in the StackTrace
which I found out after breaking into the NPE constructor actually comes from
mockit.internal.state.MockClasses.SavePoint#rollback:169
wheremockUpData.numberOfMockupsForSingleInstance = mockUpClassAndCount.getValue();
is done, but for one loop-iterationmockUpData
actually isnull
and thus the NPE is thrown.After removing all
tearDown()
calls (especially the ones in the test methods), the NPE was gone and the tests green.