use of org.junit.platform.launcher.TestPlan in project junit5 by junit-team.
the class DefaultLauncherTests method discoverTestPlanForSingleEngine.
@Test
void discoverTestPlanForSingleEngine() {
DemoHierarchicalTestEngine engine = new DemoHierarchicalTestEngine("myEngine");
engine.addTest("test1", noOp);
engine.addTest("test2", noOp);
DefaultLauncher launcher = createLauncher(engine);
TestPlan testPlan = launcher.discover(request().selectors(selectPackage("any")).build());
assertThat(testPlan.getRoots()).hasSize(1);
TestIdentifier rootIdentifier = testPlan.getRoots().iterator().next();
assertThat(testPlan.getChildren(rootIdentifier.getUniqueId())).hasSize(2);
assertThat(testPlan.getChildren("[engine:myEngine]")).hasSize(2);
}
use of org.junit.platform.launcher.TestPlan in project junit5 by junit-team.
the class DefaultLauncherTests method discoverTestPlanForEngineThatThrowsRuntimeExceptionInDiscoverPhase.
@Test
void discoverTestPlanForEngineThatThrowsRuntimeExceptionInDiscoverPhase() {
TestEngine engine = new TestEngineStub() {
@Override
public TestDescriptor discover(org.junit.platform.engine.EngineDiscoveryRequest discoveryRequest, UniqueId uniqueId) {
throw new RuntimeException("ignored");
}
};
TestPlan testPlan = createLauncher(engine).discover(request().build());
assertThat(testPlan.getRoots()).hasSize(0);
}
use of org.junit.platform.launcher.TestPlan in project junit5 by junit-team.
the class RunListenerAdapterTests method notifiedWithCorrectNamesWhenMethodExecutionStarted.
@Test
void notifiedWithCorrectNamesWhenMethodExecutionStarted() 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 methodIdentifier = identifiersAsParentOnTestPlan(testPlan, newClassDescriptor(), newMethodDescriptor());
adapter.executionStarted(methodIdentifier);
verify(listener).testStarting(entryCaptor.capture());
ReportEntry entry = entryCaptor.getValue();
assertEquals(MY_TEST_METHOD_NAME, entry.getName());
assertEquals(MyTestClass.class.getName(), entry.getSourceName());
assertNull(entry.getStackTraceWriter());
}
use of org.junit.platform.launcher.TestPlan in project junit5 by junit-team.
the class RunListenerAdapterTests method notifiedLazilyForTestSetWhenFirstTestWithoutClassDescriptorParentStarted.
@Test
void notifiedLazilyForTestSetWhenFirstTestWithoutClassDescriptorParentStarted() {
EngineDescriptor engine = newEngineDescriptor();
TestDescriptor parent = newTestDescriptor(engine.getUniqueId().append("container", "noClass"), "parent", Type.CONTAINER);
engine.addChild(parent);
TestDescriptor child1 = newTestDescriptor(parent.getUniqueId().append("test", "child1"), "child1", Type.TEST);
parent.addChild(child1);
TestDescriptor child2 = newTestDescriptor(parent.getUniqueId().append("test", "child2"), "child2", Type.TEST);
parent.addChild(child2);
TestPlan plan = TestPlan.from(Collections.singletonList(engine));
adapter.testPlanExecutionStarted(plan);
adapter.executionStarted(TestIdentifier.from(engine));
adapter.executionStarted(TestIdentifier.from(parent));
verifyZeroInteractions(listener);
adapter.executionStarted(TestIdentifier.from(child1));
InOrder inOrder = inOrder(listener);
inOrder.verify(listener).testSetStarting(new SimpleReportEntry(JUnitPlatformProvider.class.getName(), "parent"));
inOrder.verify(listener).testStarting(new SimpleReportEntry("parent", "child1"));
inOrder.verifyNoMoreInteractions();
adapter.executionFinished(TestIdentifier.from(child1), successful());
verify(listener).testSucceeded(new SimpleReportEntry("parent", "child1"));
verifyNoMoreInteractions(listener);
adapter.executionStarted(TestIdentifier.from(child2));
verify(listener).testStarting(new SimpleReportEntry("parent", "child2"));
verifyNoMoreInteractions(listener);
adapter.executionFinished(TestIdentifier.from(child2), successful());
verify(listener).testSucceeded(new SimpleReportEntry("parent", "child2"));
verifyNoMoreInteractions(listener);
adapter.executionFinished(TestIdentifier.from(parent), successful());
verify(listener).testSetCompleted(new SimpleReportEntry(JUnitPlatformProvider.class.getName(), "parent"));
verifyNoMoreInteractions(listener);
adapter.executionFinished(TestIdentifier.from(engine), successful());
verifyNoMoreInteractions(listener);
}
use of org.junit.platform.launcher.TestPlan in project junit5 by junit-team.
the class RunListenerAdapterTests method notifiedWithCompatibleNameForMethodWithArguments.
@Test
void notifiedWithCompatibleNameForMethodWithArguments() 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 methodIdentifier = identifiersAsParentOnTestPlan(testPlan, newClassDescriptor(), newMethodDescriptor(String.class));
adapter.executionStarted(methodIdentifier);
verify(listener).testStarting(entryCaptor.capture());
ReportEntry entry = entryCaptor.getValue();
assertEquals(MY_TEST_METHOD_NAME + "{String}", entry.getName());
assertEquals(MyTestClass.class.getName(), entry.getSourceName());
assertNull(entry.getStackTraceWriter());
}
Aggregations