Mocks created by JUnit4 tests are not cleaned up when run with JUnit5 #734
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please provide the following information:
Version of JMockit that was used: 1.49.a (see https://github.com/JOSM/jmockit1/tree/josm-fixes )
Description of the problem or enhancement request:
When running JUnit4 and JUnit5 tests together, JMockit does not properly cleanup after mocks are created in the JUnit4 tests.
Problem code:
https://github.com/jmockit/jmockit1/blob/master/main/src/mockit/internal/startup/JMockitInitialization.java#L34
Workaround for non-patched releases:
Create a new
mockit.internal.state.SavePoint
before each test (i.e., in a@Before
method) and then call the rollback method in an@After
method. See https://josm.openstreetmap.de/changeset/18551/josm/ for an example using a customTestRule
.If a defect or unexpected result, JMockit project members should be able to reproduce it.
For that, include an example test (perhaps accompanied by a Maven/Gradle build script) which
can be executed without changes and reproduces the failure.
If an enhancement or new feature request, it should be justified by an example test
demonstrating the validity and usefulness of the desired enhancement or new feature.
The issue does not fall outside the scope of the project (for example, attempting to use
JMockit APIs from Groovy or Scala code, or with an Android runtime).
The JDK where the problem occurs is a final release, not a development build.