use of org.junit.platform.launcher.TestIdentifier 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.TestIdentifier 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.TestIdentifier in project junit5 by junit-team.
the class RunListenerAdapterTests method displayNamesIgnoredInReport.
@Test
void displayNamesIgnoredInReport() throws NoSuchMethodException {
TestMethodTestDescriptor descriptor = new TestMethodTestDescriptor(newId(), MyTestClass.class, MyTestClass.class.getDeclaredMethod("myNamedTestMethod"));
TestIdentifier factoryIdentifier = TestIdentifier.from(descriptor);
ArgumentCaptor<ReportEntry> entryCaptor = ArgumentCaptor.forClass(ReportEntry.class);
adapter.executionSkipped(factoryIdentifier, "");
verify(listener).testSkipped(entryCaptor.capture());
ReportEntry value = entryCaptor.getValue();
assertEquals("myNamedTestMethod", value.getName());
}
use of org.junit.platform.launcher.TestIdentifier 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());
}
use of org.junit.platform.launcher.TestIdentifier in project junit5 by junit-team.
the class RunListenerAdapterTests method identifiersAsParentOnTestPlan.
private static TestIdentifier identifiersAsParentOnTestPlan(TestPlan plan, TestDescriptor parent, TestDescriptor child) {
child.setParent(parent);
TestIdentifier parentIdentifier = TestIdentifier.from(parent);
TestIdentifier childIdentifier = TestIdentifier.from(child);
plan.add(parentIdentifier);
plan.add(childIdentifier);
return childIdentifier;
}
Aggregations