2

We are using our custom test runner, that extend ParentRunner:

public class OurTestRunner extends ParentRunner<TestRunnerForOneConfigCase> {...}

class TestRunnerForOneConfigCase extends BlockJUnit4ClassRunner {...}

Inspired by how to combine @RunWith with @RunWith(Parameterized.class), I would like to use OurTestRunner with test parameters. So I am trying to implement the factory:

public class OurTestRunnerFactory implements ParametersRunnerFactory {
  @Override
  public org.junit.runner.Runner createRunnerForTestWithParameters(TestWithParameters test) throws InitializationError {
    return new OurTestRunner(test /* but it takes Class<T> as parameter */); 
  }
}

However, OurTestRunner and the its parent class ParentRunner take only the Class<T> as parameter, and not TestWithParameters (i.e. it doesn't take the parameters).

Is there a version of ParentRunner that is compatible with Parameterized? If not, what is the easiest way to extend our setup (without rewriting everything)?

Grzenio
  • 35,875
  • 47
  • 158
  • 240

1 Answers1

0

You can have only one Test Runner, but you can do it in such way:

 public class SimpleExampleTest {

    @Rule
    public Generator<String> params =
        new ListGenerator(asList("alpha", "beta", "gamma"));

    @Test
    public void testSomething() throws Exception {
        assertTrue(params.value().length() >= 4);
    }
}