use of org.junit.platform.engine.TestExecutionResult in project junit5 by junit-team.
the class VintageLauncherIntegrationTests method executesOnlyNotExcludedTaggedMethodOfNestedTestClass.
@Test
void executesOnlyNotExcludedTaggedMethodOfNestedTestClass() {
Class<?> testClass = EnclosedJUnit4TestCase.class;
Class<?> nestedTestClass = EnclosedJUnit4TestCase.NestedClass.class;
LauncherDiscoveryRequestBuilder request = //
request().selectors(//
selectClass(testClass)).filters(excludeTags(Categories.Failing.class.getName()));
TestPlan testPlan = discover(request);
assertThat(testPlan.getDescendants(getOnlyElement(testPlan.getRoots()))).hasSize(3);
Map<TestIdentifier, TestExecutionResult> results = execute(request);
//
assertThat(results.keySet().stream().map(TestIdentifier::getDisplayName)).containsExactlyInAnyOrder("JUnit Vintage", testClass.getName(), nestedTestClass.getName(), "successfulTest");
}
use of org.junit.platform.engine.TestExecutionResult in project junit5 by junit-team.
the class VintageLauncherIntegrationTests method removesCompleteClassIfNoMethodHasMatchingTags.
@Test
void removesCompleteClassIfNoMethodHasMatchingTags() {
Class<?> testClass = PlainJUnit4TestCaseWithFiveTestMethods.class;
LauncherDiscoveryRequestBuilder request = //
request().selectors(//
selectClass(testClass)).filters(includeTags("wrong-tag"));
TestPlan testPlan = discover(request);
assertThat(testPlan.getDescendants(getOnlyElement(testPlan.getRoots()))).isEmpty();
Map<TestIdentifier, TestExecutionResult> results = execute(request);
//
assertThat(results.keySet().stream().map(TestIdentifier::getDisplayName)).containsExactly("JUnit Vintage");
}
use of org.junit.platform.engine.TestExecutionResult in project junit5 by junit-team.
the class VintageLauncherIntegrationTests method executesAllTestsForNotFilterableRunner.
@TrackLogRecords
@Test
void executesAllTestsForNotFilterableRunner(LogRecordListener logRecordListener) {
Class<?> testClass = JUnit4TestCaseWithNotFilterableRunner.class;
LauncherDiscoveryRequestBuilder request = //
request().selectors(//
selectClass(testClass)).filters((PostDiscoveryFilter) descriptor -> includedIf(descriptor.getDisplayName().contains("#1")));
TestPlan testPlan = discover(request);
logRecordListener.clear();
assertThat(testPlan.getDescendants(getOnlyElement(testPlan.getRoots()))).hasSize(3);
Map<TestIdentifier, TestExecutionResult> results = execute(request);
//
assertThat(results.keySet().stream().map(TestIdentifier::getDisplayName)).containsExactlyInAnyOrder("JUnit Vintage", testClass.getName(), "Test #0", "Test #1");
//
assertThat(logRecordListener.stream(RunnerTestDescriptor.class, Level.WARNING).map(LogRecord::getMessage)).containsExactly(//
"Runner " + NotFilterableRunner.class.getName() + " (used on class " + testClass.getName() + ")" + " does not support filtering and will therefore be run completely.");
}
use of org.junit.platform.engine.TestExecutionResult in project junit5 by junit-team.
the class HierarchicalTestExecutorTests method abortInContainerBeforeAll.
@Test
void abortInContainerBeforeAll() throws Exception {
MyContainer child = spy(new MyContainer(UniqueId.root("container", "child container")));
root.addChild(child);
TestAbortedException anAbortedException = new TestAbortedException("in BeforeAll");
when(root.before(rootContext)).thenThrow(anAbortedException);
InOrder inOrder = inOrder(listener, root, child);
executor.execute();
ArgumentCaptor<TestExecutionResult> rootExecutionResult = ArgumentCaptor.forClass(TestExecutionResult.class);
inOrder.verify(root).prepare(rootContext);
inOrder.verify(root).shouldBeSkipped(rootContext);
inOrder.verify(listener).executionStarted(root);
inOrder.verify(root).before(rootContext);
inOrder.verify(root).after(rootContext);
inOrder.verify(listener).executionFinished(eq(root), rootExecutionResult.capture());
assertThat(rootExecutionResult.getValue().getStatus()).isEqualTo(ABORTED);
assertThat(rootExecutionResult.getValue().getThrowable()).containsSame(anAbortedException);
verifyNoMoreInteractions(child);
}
use of org.junit.platform.engine.TestExecutionResult in project junit5 by junit-team.
the class HierarchicalTestExecutorTests method exceptionInPrepare.
@Test
void exceptionInPrepare() throws Exception {
RuntimeException prepareException = new RuntimeException("in prepare()");
doThrow(prepareException).when(root).prepare(rootContext);
executor.execute();
ArgumentCaptor<TestExecutionResult> rootExecutionResult = ArgumentCaptor.forClass(TestExecutionResult.class);
InOrder inOrder = inOrder(listener, root);
inOrder.verify(root).prepare(rootContext);
inOrder.verify(listener).executionStarted(root);
inOrder.verify(listener).executionFinished(eq(root), rootExecutionResult.capture());
inOrder.verifyNoMoreInteractions();
assertThat(rootExecutionResult.getValue().getStatus()).isEqualTo(FAILED);
assertThat(rootExecutionResult.getValue().getThrowable()).containsSame(prepareException);
assertThat(prepareException.getSuppressed()).isEmpty();
}
Aggregations