1

I want to create the following test class with JUnit4:

import junitparams.JUnitParamsRunner;
import org.junit.runner.RunWith;
import de.bechte.junit.runners.context.HierarchicalContextRunner;

@RunWith(JUnitParamsRunner.class)
@RunWith(HierarchicalContextRunner.class)
public class MultipleRunWithTest {
   //...
}

I want to use both facilities of HierarchicalContextRunner and JUnitParamsRunner, because they are handy in creating readable unit tests. JUnit gives this compile error:

Duplicate annotation @RunWith   MultipleRunWith.java

What could be a resonable solution?

Juergen
  • 3,489
  • 6
  • 35
  • 59

1 Answers1

2

Unfortunately, there is no way in JUnit to use two runners at a time. I think this would require refactoring the JUnit core into some kind of event-based execution framework that allows interception of the request at several extension points.

So for me, there is no way to do this right now. I hope that the hierarchical context runner will replace the default runner some time. Then everything should be fine. ;-)

All the best, Stefan

John Powell
  • 12,253
  • 6
  • 59
  • 67