It seems like JMockit leaves mocked classes behind after test completes #365

Closed
knut-forkalsrud opened this Issue Nov 28, 2016 · 0 comments

Projects

None yet

2 participants

@knut-forkalsrud

I'm using JMockit 1.29 and JUnit 4.11 (with Hamcrest 1.3).

I have a project with about 3000 test methods, most of them in JUnit 3 style test classes (extends TestCase). When trying to add new, independent, tests based on JMockit I see random breakage of some of the old tests. When I get into the debugger I see JMockit interfering. I realize that the JMockit tests do not support Junit3 style API, but the old style test doesn't use anything JMockit related.

The attached file mixing-old-new.zip has a reproducible example. It has a JMockit test, a TestCase test and a domain object that is mocked in the former, not in the latter.

Compile with javac -cp jmockit-1.29.jar:junit-4.11.jar *.java
Running with the old test first succeeds java -cp .:jmockit-1.29.jar:junit-4.11.jar:hamcrest-core-1.3.jar org.junit.runner.JUnitCore OldStyleTest NewStyleTest
Running with the new test first fails the old test: java -cp .:jmockit-1.29.jar:junit-4.11.jar:hamcrest-core-1.3.jar org.junit.runner.JUnitCore NewStyleTest OldStyleTest
The expectation is of course that the order of the tests don't matter.

@rliesenfeld rliesenfeld self-assigned this Nov 30, 2016
@rliesenfeld rliesenfeld added a commit that closed this issue Nov 30, 2016
@rliesenfeld rliesenfeld Added cleanup of mocked classes at the start of each test class, in o…
…rder to account for JUnit 3.8-style test classes in a JUnit 4 test suite; closes #365.
2ea07aa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment