jmockit / jmockit1

Advanced Java library for integration testing, mocking, faking, and code coverage
Other
458 stars 238 forks source link

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

Open tsmock opened 1 year ago

tsmock commented 1 year ago

Please provide the following information:

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.