topchef
topchef

Reputation: 19803

JUnit Test Runner that creates tests just before running them

I use JUnit 3.x TestRunner that intantiates all tests at once before running them.

Is there a Test Runner available that would create each test (or at least each test suite's tests) just before running them?
I can use JUnit 4.x runners but my tests are 3.x tests.

Upvotes: 3

Views: 1851

Answers (2)

Nat
Nat

Reputation: 9951

In JUnit 3 you'd need to write your own TestSuite class that delayed instantiation of the tests in the suite.

Upvotes: 3

Gregory Mostizky
Gregory Mostizky

Reputation: 7261

You are probably doing it wrong.

Each unit test should be self-contained and not depend on any other test results. Otherwise when one of the tests break it will break all the tests that depend on it. So you will see a lot of errors without easy way to understand what is the actual cause. On the other hand if all unit tests are independent a broken test is extremely easy to debug and fix.

EDIT: I am assuming the reason you ask the original question is because you have some dependencies in your test. If I am wrong please ignore this answer :)

Upvotes: 1

Related Questions