I use @Parameterized
in many cases to run tests on a number of permutations. This works very well and keeps the test-code itself simple and clean.
However sometimes I would like to have some of the test-methods still run only once as they do not make use of the parameters, is there a way with JUnit to mark the test-method as "singleton" or "run-once"?
Note: This does not concern running single tests in Eclipse, I know how to do that :)
You could structure your test with the Enclosed runner.
@RunWith(Enclosed.class)
public class TestClass {
@RunWith(Parameterized.class)
public static class TheParameterizedPart {
@Parameters
public static Object[][] data() {
...
}
@Test
public void someTest() {
...
}
@Test
public void anotherTest() {
...
}
}
public static class NotParameterizedPart {
@Test
public void someTest() {
...
}
}
}