This content has been marked as final. Show 3 replies
I believe it runs them in different classloaders, yes; at the very least it runs each unit test with a new instance of the test suite class. If that is a problem for you, you might want to switch to TestNG which has a leaner lifecycle in my opinion.
Aacc wrote:You can test it.
Question is, does Junit run (through ant) each test suite in separate classLoader?
Create a static initializer and use System.out to output something meaningful. Then run two test classes. that use version 1 (you don't need version 2).
If the output appears twice then it means it loaded the test class into a class loader.
The test shows it's not stable. sometimes from version 1 some times from version 2.
I wonder if JUnit has any document clarify this as I thought this is common issue. if one test suite interfere by classes loaded in another suite and causing failure, it would be very hard to debug to find out root cause - thought Junit need to clarify this.