use of org.junit.runner.Runner in project gradle by gradle.
the class IgnoredTestDescriptorProvider method getAllDescriptions.
List<Description> getAllDescriptions(Description description, String className) {
final AllExceptIgnoredTestRunnerBuilder allExceptIgnoredTestRunnerBuilder = new AllExceptIgnoredTestRunnerBuilder();
try {
final Class<?> testClass = description.getClass().getClassLoader().loadClass(className);
Runner runner = allExceptIgnoredTestRunnerBuilder.runnerForClass(testClass);
if (runner == null) {
// fall back to default runner
runner = Request.aClass(testClass).getRunner();
}
final Description runnerDescription = runner.getDescription();
return runnerDescription.getChildren();
} catch (Throwable throwable) {
throw new TestSuiteExecutionException(String.format("Unable to process Ignored class %s.", className), throwable);
}
}
use of org.junit.runner.Runner in project bazel by bazelbuild.
the class Filters method apply.
/**
* Returns a Request that only contains those tests that should run when
* a filter is applied, filtering out all empty suites.<p>
*
* Note that if the request passed into this method caches its runner,
* that runner will be modified to use the given filter. To be safe,
* do not use the passed-in request after calling this method.
*
* @param request Request to filter
* @param filter Filter to apply
* @return request
* @throws NoTestsRemainException if the applying the filter removes all tests
*/
public static Request apply(Request request, Filter filter) throws NoTestsRemainException {
filter = new SuiteTrimmingFilter(filter);
Runner runner = request.getRunner();
filter.apply(runner);
return Request.runner(runner);
}
use of org.junit.runner.Runner in project bazel by bazelbuild.
the class MemoizingRequestTest method testOverridingCreateRunner.
public void testOverridingCreateRunner() {
final Runner stubRunner = mock(Runner.class);
MemoizingRequest memoizingRequest = new MemoizingRequest(mockRequestDelegate) {
@Override
protected Runner createRunner(Request delegate) {
return stubRunner;
}
};
Runner firstRunner = memoizingRequest.getRunner();
Runner secondRunner = memoizingRequest.getRunner();
assertSame(stubRunner, firstRunner);
assertSame(firstRunner, secondRunner);
verifyZeroInteractions(mockRequestDelegate);
}
use of org.junit.runner.Runner in project bazel by bazelbuild.
the class JUnit4Runner method applyFilter.
private static Request applyFilter(Request request, Filter filter) throws NoTestsRemainException {
Runner runner = request.getRunner();
new SuiteTrimmingFilter(filter).apply(runner);
return Request.runner(runner);
}
use of org.junit.runner.Runner in project intellij-community by JetBrains.
the class JUnit46ClassesRequestBuilder method getClassesRequest.
public static Request getClassesRequest(final String suiteName, Class[] classes, Map classMethods, Class category) {
boolean canUseSuiteMethod = canUseSuiteMethod(classMethods);
try {
if (category != null) {
try {
Class.forName("org.junit.experimental.categories.Categories");
} catch (ClassNotFoundException e) {
throw new RuntimeException("Categories are not available");
}
}
Runner suite;
if (canUseSuiteMethod) {
try {
Class.forName("org.junit.experimental.categories.Categories");
suite = new IdeaSuite48(collectWrappedRunners(classes), suiteName, category);
} catch (ClassNotFoundException e) {
suite = new IdeaSuite(collectWrappedRunners(classes), suiteName);
}
} else {
final AllDefaultPossibilitiesBuilder builder = new AllDefaultPossibilitiesBuilder(canUseSuiteMethod);
try {
Class.forName("org.junit.experimental.categories.Categories");
suite = new IdeaSuite48(builder, classes, suiteName, category);
} catch (ClassNotFoundException e) {
suite = new IdeaSuite(builder, classes, suiteName);
}
}
return Request.runner(suite);
} catch (InitializationError e) {
throw new RuntimeException(e);
}
}
Aggregations