use of org.junit.runner.Request in project gradle by gradle.
the class JUnitTestClassExecutor method runTestClass.
private void runTestClass(String testClassName) throws ClassNotFoundException {
final Class<?> testClass = Class.forName(testClassName, false, applicationClassLoader);
if (isNestedClassInsideEnclosedRunner(testClass)) {
return;
}
List<Filter> filters = new ArrayList<Filter>();
if (options.hasCategoryConfiguration()) {
verifyJUnitCategorySupport();
filters.add(new CategoryFilter(options.getIncludeCategories(), options.getExcludeCategories(), applicationClassLoader));
}
Request request = Request.aClass(testClass);
Runner runner = request.getRunner();
if (!options.getIncludedTests().isEmpty() || !options.getIncludedTestsCommandLine().isEmpty()) {
TestSelectionMatcher matcher = new TestSelectionMatcher(options.getIncludedTests(), options.getIncludedTestsCommandLine());
// matches the filter, run the entire suite instead of filtering away its contents.
if (!runner.getDescription().isSuite() || !matcher.matchesTest(testClassName, null)) {
filters.add(new MethodNameFilter(matcher));
}
}
if (runner instanceof Filterable) {
Filterable filterable = (Filterable) runner;
for (Filter filter : filters) {
try {
filterable.filter(filter);
} catch (NoTestsRemainException e) {
// Ignore
return;
}
}
} else if (allTestsFiltered(runner, filters)) {
return;
}
RunNotifier notifier = new RunNotifier();
notifier.addListener(listener);
runner.run(notifier);
}
Aggregations