use of org.junit.runner.Request in project junit4 by junit-team.
the class CategoryTest method testCountWithExplicitExcludeFilter_usingConstructor.
@Test
public void testCountWithExplicitExcludeFilter_usingConstructor() throws Throwable {
CategoryFilter include = new CategoryFilter(null, 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 CategoryTest method testCountWithMultipleIncludeFilter.
@Test
public void testCountWithMultipleIncludeFilter() throws Throwable {
CategoryFilter exclude = CategoryFilter.include(true, SlowTests.class, FastTests.class);
Request baseRequest = Request.aClass(OneOfEach.class);
Result result = new JUnitCore().run(baseRequest.filterWith(exclude));
assertTrue(result.wasSuccessful());
assertEquals(2, result.getRunCount());
}
use of org.junit.runner.Request in project bazel by bazelbuild.
the class JUnit4TestXmlListenerTest method assumptionViolationsAreReportedAsSkippedTests.
@Test
public void assumptionViolationsAreReportedAsSkippedTests() throws Exception {
TestSuiteModelSupplier mockModelSupplier = mock(TestSuiteModelSupplier.class);
TestSuiteModel mockModel = mock(TestSuiteModel.class);
CancellableRequestFactory mockRequestFactory = mock(CancellableRequestFactory.class);
OutputStream mockXmlStream = mock(OutputStream.class);
JUnit4TestXmlListener listener = new JUnit4TestXmlListener(mockModelSupplier, mockRequestFactory, fakeSignalHandlers, mockXmlStream, errPrintStream);
Request request = Request.classWithoutSuiteMethod(TestWithAssumptionViolation.class);
Description suiteDescription = request.getRunner().getDescription();
Description testDescription = suiteDescription.getChildren().get(0);
when(mockModelSupplier.get()).thenReturn(mockModel);
JUnitCore core = new JUnitCore();
core.addListener(listener);
core.run(request);
assertEquals("no output to stderr expected", 0, errStream.size());
InOrder inOrder = inOrder(mockModel);
inOrder.verify(mockModel).testSkipped(testDescription);
inOrder.verify(mockModel).writeAsXml(mockXmlStream);
verify(mockRequestFactory, never()).cancelRun();
}
use of org.junit.runner.Request in project bazel by bazelbuild.
the class JUnit4TestXmlListenerTest method assumptionViolationsAtSuiteLevelAreReportedAsSkippedSuite.
@Test
public void assumptionViolationsAtSuiteLevelAreReportedAsSkippedSuite() throws Exception {
TestSuiteModelSupplier mockModelSupplier = mock(TestSuiteModelSupplier.class);
TestSuiteModel mockModel = mock(TestSuiteModel.class);
CancellableRequestFactory mockRequestFactory = mock(CancellableRequestFactory.class);
OutputStream mockXmlStream = mock(OutputStream.class);
JUnit4TestXmlListener listener = new JUnit4TestXmlListener(mockModelSupplier, mockRequestFactory, fakeSignalHandlers, mockXmlStream, errPrintStream);
Request request = Request.classWithoutSuiteMethod(TestWithAssumptionViolationOnTheSuiteLevel.class);
Description suiteDescription = request.getRunner().getDescription();
when(mockModelSupplier.get()).thenReturn(mockModel);
JUnitCore core = new JUnitCore();
core.addListener(listener);
core.run(request);
assertEquals("no output to stderr expected", 0, errStream.size());
InOrder inOrder = inOrder(mockModel);
inOrder.verify(mockModel).testSkipped(suiteDescription);
inOrder.verify(mockModel).writeAsXml(mockXmlStream);
verify(mockRequestFactory, never()).cancelRun();
}
use of org.junit.runner.Request 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);
}
Aggregations