Skip to main content

Parameterized tests in Junit 3 -- another Java

Adding some experimental code that modifies a junit3 test?  Yearning for Junit4 @RunWith(Parameterized.class) annotation?

For simple things like an experiment flag you can do this:

Add the flag to the base test class.

   boolean experiment = false;

Create a subclass of your test and change the value in your setUp method:

 class FooWithExperimentTest extends FooTest {

 protected void setUp() throws Exception {
    this.experiment = true;

Your subclass will run with the varying value.