use of org.junit.runner.Request in project buck by facebook.
the class JUnitRunner method run.
@Override
public void run() throws Throwable {
Level stdOutLogLevel = Level.INFO;
Level stdErrLogLevel = Level.WARNING;
String unparsedStdOutLogLevel = System.getProperty(STD_OUT_LOG_LEVEL_PROPERTY);
String unparsedStdErrLogLevel = System.getProperty(STD_ERR_LOG_LEVEL_PROPERTY);
if (unparsedStdOutLogLevel != null) {
stdOutLogLevel = Level.parse(unparsedStdOutLogLevel);
}
if (unparsedStdErrLogLevel != null) {
stdErrLogLevel = Level.parse(unparsedStdErrLogLevel);
}
for (String className : testClassNames) {
final Class<?> testClass = Class.forName(className);
List<TestResult> results = new ArrayList<>();
RecordingFilter filter = new RecordingFilter();
if (mightBeATestClass(testClass)) {
JUnitCore jUnitCore = new JUnitCore();
Runner suite = new Computer().getSuite(createRunnerBuilder(), new Class<?>[] { testClass });
Request request = Request.runner(suite);
request = request.filterWith(filter);
jUnitCore.addListener(new TestListener(results, stdOutLogLevel, stdErrLogLevel));
jUnitCore.run(request);
}
// Combine the results with the tests we filtered out
List<TestResult> actualResults = combineResults(results, filter.filteredOut);
writeResult(className, actualResults);
}
}
use of org.junit.runner.Request in project junit4 by junit-team.
the class CategoryTest method testCountWithMultipleExcludeFilter.
@Test
@SuppressWarnings("unchecked")
public void testCountWithMultipleExcludeFilter() throws Throwable {
Set<Class<?>> exclusions = new HashSet<Class<?>>(2);
Collections.addAll(exclusions, SlowTests.class, FastTests.class);
CategoryFilter exclude = CategoryFilter.categoryFilter(true, null, true, exclusions);
Request baseRequest = Request.aClass(OneOfEach.class);
Result result = new JUnitCore().run(baseRequest.filterWith(exclude));
assertTrue(result.wasSuccessful());
assertEquals(1, result.getRunCount());
}
use of org.junit.runner.Request in project junit4 by junit-team.
the class CategoryTest method testCountWithExplicitIncludeFilter.
@Test
public void testCountWithExplicitIncludeFilter() throws Throwable {
CategoryFilter include = CategoryFilter.include(SlowTests.class);
Request baseRequest = Request.aClass(TestSuiteWithNoCategories.class);
Result result = new JUnitCore().run(baseRequest.filterWith(include));
assertTrue(result.wasSuccessful());
assertEquals(2, result.getRunCount());
}
use of org.junit.runner.Request in project junit4 by junit-team.
the class CategoryTest method testCountWithExplicitExcludeFilter.
@Test
public void testCountWithExplicitExcludeFilter() throws Throwable {
CategoryFilter include = CategoryFilter.exclude(SlowTests.class);
Request baseRequest = Request.aClass(TestSuiteWithNoCategories.class);
Result result = new JUnitCore().run(baseRequest.filterWith(include));
assertEquals(2, result.getFailureCount());
assertEquals(2, result.getRunCount());
}
use of org.junit.runner.Request in project junit4 by junit-team.
the class TheoryTestUtils method runTheoryClass.
public static Result runTheoryClass(Class<?> testClass) throws InitializationError {
Runner theoryRunner = new Theories(testClass);
Request request = Request.runner(theoryRunner);
return new JUnitCore().run(request);
}
Aggregations