Parameterized tests in Junit 3 -- another Java #protip
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 {
@Override
protected void setUp() throws Exception {
this.experiment = true;
super.setUp();
}
}
Your subclass will run with the varying value.
#googplus