private List<Runner> createRunnersForParameters( Iterable<Object> allParameters, String namePattern, ParametersRunnerFactory runnerFactory) throws Exception { try { List<TestWithParameters> tests = createTestsForParameters( allParameters, namePattern); List<Runner> runners = new ArrayList<Runner>(); for (TestWithParameters test : tests) { runners.add(runnerFactory .createRunnerForTestWithParameters(test)); } return runners; } catch (ClassCastException e) { throw parametersMethodReturnedWrongType(); } }
private List<Runner> createRunnersForParameters( Iterable<Object> allParameters, String namePattern, ParametersRunnerFactory runnerFactory) throws InitializationError, Exception { try { List<TestWithParameters> tests = createTestsForParameters( allParameters, namePattern); List<Runner> runners = new ArrayList<Runner>(); for (TestWithParameters test : tests) { runners.add(runnerFactory .createRunnerForTestWithParameters(test)); } return runners; } catch (ClassCastException e) { throw parametersMethodReturnedWrongType(); } }
private ParametersRunnerFactory getParametersRunnerFactory() throws InstantiationException, IllegalAccessException { UseParametersRunnerFactory annotation = testClass .getAnnotation(UseParametersRunnerFactory.class); if (annotation == null) { return DEFAULT_FACTORY; } else { Class<? extends ParametersRunnerFactory> factoryClass = annotation .value(); return factoryClass.newInstance(); } }
public Parameterized(Class<?> klass) throws Throwable { super(klass); FrameworkMethod parametersMethod = getParametersMethod(); if (parametersMethod != null) { Parameters parameters = parametersMethod.getAnnotation(Parameters.class); Method declaredMethod = org.junit.runners.Parameterized.class.getDeclaredMethod("createRunnersForParameters", Iterable.class, String.class, ParametersRunnerFactory.class); declaredMethod.setAccessible(true); l = (List<Runner>)declaredMethod.invoke(this, allParameters(klass, parametersMethod), parameters.name(), BlockJUnit4ClassRunnerWithParametersFactory.class.newInstance()); } }
/** * Only called reflectively. Do not use programmatically. */ public Parameterized(Class<?> klass) throws Throwable { super(klass, NO_RUNNERS); ParametersRunnerFactory runnerFactory = getParametersRunnerFactory( klass); Parameters parameters = getParametersMethod().getAnnotation( Parameters.class); fRunners = Collections.unmodifiableList(createRunnersForParameters( allParameters(), parameters.name(), runnerFactory)); }
private ParametersRunnerFactory getParametersRunnerFactory(Class<?> klass) throws InstantiationException, IllegalAccessException { UseParametersRunnerFactory annotation = klass .getAnnotation(UseParametersRunnerFactory.class); if (annotation == null) { return DEFAULT_FACTORY; } else { Class<? extends ParametersRunnerFactory> factoryClass = annotation .value(); return factoryClass.newInstance(); } }