Skip to content

Mocks created by JUnit4 tests are not cleaned up when run with JUnit5#734

Open
tsmock wants to merge 1 commit intojmockit:masterfrom
tsmock:patch-1
Open

Mocks created by JUnit4 tests are not cleaned up when run with JUnit5#734
tsmock wants to merge 1 commit intojmockit:masterfrom
tsmock:patch-1

Conversation

@tsmock
Copy link
Copy Markdown

@tsmock tsmock commented Sep 8, 2022

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 custom TestRule.

  • Check the following:
  • 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.

Additionally search classpath for the VintageTestEngine, which is what is used to run JUnit4 tests under JUnit5.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants