use of org.junit.runner.Runner in project junit4 by junit-team.
the class SingleMethodTest method parameterizedFilterToSingleMethod.
@Test
public void parameterizedFilterToSingleMethod() throws Exception {
count = 0;
Runner runner = Request.method(ParameterizedOneTimeSetup.class, "one[0]").getRunner();
Result result = new JUnitCore().run(runner);
assertEquals(1, result.getRunCount());
}
use of org.junit.runner.Runner in project junit4 by junit-team.
the class SingleMethodTest method eliminateUnnecessaryTreeBranches.
@Test
public void eliminateUnnecessaryTreeBranches() throws Exception {
Runner runner = Request.aClass(OneTwoSuite.class).filterWith(Description.createTestDescription(TestOne.class, "a")).getRunner();
Description description = runner.getDescription();
assertEquals(1, description.getChildren().size());
}
use of org.junit.runner.Runner in project junit4 by junit-team.
the class AnnotatedBuilderTest method memberClassDeepInsideAnnotatedMemberClass_isRunWithParentMemberClassRunner.
@Test
public void memberClassDeepInsideAnnotatedMemberClass_isRunWithParentMemberClassRunner() throws Exception {
Runner runner = builder.runnerForClass(OuterClass.InnerClassWithOwnRunWith.MostInnerClass.class);
assertThat(runner, is(instanceOf(InnerRunner.class)));
RunnerSpy runnerSpy = (RunnerSpy) runner;
assertThat(runnerSpy.getInvokedTestClass(), is((Object) OuterClass.InnerClassWithOwnRunWith.MostInnerClass.class));
}
use of org.junit.runner.Runner in project junit4 by junit-team.
the class AnnotatedBuilderTest method annotatedMemberClassInsideAnnotatedTopLevelClass_isRunWithOwnRunner.
@Test
public void annotatedMemberClassInsideAnnotatedTopLevelClass_isRunWithOwnRunner() throws Exception {
Runner runner = builder.runnerForClass(OuterClass.InnerClassWithOwnRunWith.class);
assertThat(runner, is(instanceOf(InnerRunner.class)));
RunnerSpy runnerSpy = (RunnerSpy) runner;
assertThat(runnerSpy.getInvokedTestClass(), is((Object) OuterClass.InnerClassWithOwnRunWith.class));
}
use of org.junit.runner.Runner in project gerrit by GerritCodeReview.
the class ConfigSuite method runnersFor.
private static List<Runner> runnersFor(Class<?> clazz) {
Method defaultConfig = getDefaultConfig(clazz);
List<Method> configs = getConfigs(clazz);
Map<String, org.eclipse.jgit.lib.Config> configMap = callConfigMapMethod(getConfigMap(clazz), configs);
Field parameterField = getOnlyField(clazz, Parameter.class);
checkArgument(parameterField != null, "No @ConfigSuite.Parameter found");
Field nameField = getOnlyField(clazz, Name.class);
List<Runner> result = Lists.newArrayListWithCapacity(configs.size() + 1);
try {
result.add(new ConfigRunner(clazz, parameterField, nameField, null, callConfigMethod(defaultConfig)));
for (Method m : configs) {
result.add(new ConfigRunner(clazz, parameterField, nameField, m.getName(), callConfigMethod(m)));
}
for (Map.Entry<String, org.eclipse.jgit.lib.Config> e : configMap.entrySet()) {
result.add(new ConfigRunner(clazz, parameterField, nameField, e.getKey(), e.getValue()));
}
return result;
} catch (InitializationError e) {
System.err.println("Errors initializing runners:");
for (Throwable t : e.getCauses()) {
t.printStackTrace();
}
throw new RuntimeException(e);
}
}
Aggregations