use of org.junit.platform.launcher.TestPlan in project junit5 by junit-team.
the class LauncherFactoryTests method create.
@Test
void create() {
LauncherDiscoveryRequest discoveryRequest = createLauncherDiscoveryRequestForBothStandardEngineExampleClasses();
TestPlan testPlan = LauncherFactory.create().discover(discoveryRequest);
Set<TestIdentifier> roots = testPlan.getRoots();
assertThat(roots).hasSize(2);
// @formatter:off
List<String> ids = roots.stream().map(TestIdentifier::getUniqueId).collect(toList());
// @formatter:on
assertThat(ids).containsOnly("[engine:junit-vintage]", "[engine:junit-jupiter]");
}
use of org.junit.platform.launcher.TestPlan in project junit5 by junit-team.
the class RunListenerAdapterTests method notifiedWithParentDisplayNameWhenTestClassUnknown.
@Test
void notifiedWithParentDisplayNameWhenTestClassUnknown() throws Exception {
// Set up a test plan
TestPlan plan = TestPlan.from(Collections.singletonList(new EngineDescriptor(newId(), "Luke's Plan")));
adapter.testPlanExecutionStarted(plan);
// Use the test plan to set up child with parent.
final String parentDisplay = "I am your father";
TestIdentifier child = newSourcelessChildIdentifierWithParent(plan, parentDisplay, null);
adapter.executionStarted(child);
// Check that the adapter has informed Surefire that the test has been invoked,
// with the parent name as source (since the test case itself had no source).
ArgumentCaptor<ReportEntry> entryCaptor = ArgumentCaptor.forClass(ReportEntry.class);
verify(listener).testStarting(entryCaptor.capture());
assertEquals(parentDisplay, entryCaptor.getValue().getSourceName());
}
use of org.junit.platform.launcher.TestPlan in project junit5 by junit-team.
the class RunListenerAdapterTests method notifiedWithCorrectNamesWhenClassExecutionFailed.
@Test
void notifiedWithCorrectNamesWhenClassExecutionFailed() throws Exception {
ArgumentCaptor<ReportEntry> entryCaptor = ArgumentCaptor.forClass(ReportEntry.class);
TestPlan testPlan = TestPlan.from(Collections.singletonList(new EngineDescriptor(newId(), "Luke's Plan")));
adapter.testPlanExecutionStarted(testPlan);
adapter.executionFinished(identifiersAsParentOnTestPlan(testPlan, newEngineDescriptor(), newClassDescriptor()), TestExecutionResult.failed(new AssertionError()));
verify(listener).testFailed(entryCaptor.capture());
ReportEntry entry = entryCaptor.getValue();
assertEquals(MyTestClass.class.getTypeName(), entry.getSourceName());
assertNotNull(entry.getStackTraceWriter());
}
use of org.junit.platform.launcher.TestPlan in project junit5 by junit-team.
the class RunListenerAdapterTests method notifiedForTestSetForSingleNodeEngine.
@Test
void notifiedForTestSetForSingleNodeEngine() {
EngineDescriptor engine = new EngineDescriptor(UniqueId.forEngine("engine"), "engine") {
@Override
public Type getType() {
return Type.TEST;
}
};
TestPlan plan = TestPlan.from(Collections.singletonList(engine));
adapter.testPlanExecutionStarted(plan);
adapter.executionStarted(TestIdentifier.from(engine));
InOrder inOrder = inOrder(listener);
inOrder.verify(listener).testSetStarting(new SimpleReportEntry(JUnitPlatformProvider.class.getName(), "engine"));
inOrder.verify(listener).testStarting(new SimpleReportEntry("<unrooted>", "engine"));
inOrder.verifyNoMoreInteractions();
adapter.executionFinished(TestIdentifier.from(engine), successful());
inOrder = inOrder(listener);
inOrder.verify(listener).testSucceeded(new SimpleReportEntry("<unrooted>", "engine"));
inOrder.verify(listener).testSetCompleted(new SimpleReportEntry(JUnitPlatformProvider.class.getName(), "engine"));
inOrder.verifyNoMoreInteractions();
}
use of org.junit.platform.launcher.TestPlan in project junit5 by junit-team.
the class RunListenerAdapterTests method notifiedWithCorrectNamesWhenClassExecutionSkipped.
@Test
void notifiedWithCorrectNamesWhenClassExecutionSkipped() throws Exception {
ArgumentCaptor<ReportEntry> entryCaptor = ArgumentCaptor.forClass(ReportEntry.class);
TestPlan testPlan = TestPlan.from(Collections.singletonList(new EngineDescriptor(newId(), "Luke's Plan")));
adapter.testPlanExecutionStarted(testPlan);
TestIdentifier classIdentifier = identifiersAsParentOnTestPlan(testPlan, newEngineDescriptor(), newClassDescriptor());
adapter.executionSkipped(classIdentifier, "test");
verify(listener).testSkipped(entryCaptor.capture());
ReportEntry entry = entryCaptor.getValue();
assertTrue(MyTestClass.class.getTypeName().contains(entry.getName()));
assertEquals(MyTestClass.class.getTypeName(), entry.getSourceName());
}
Aggregations