use of org.junit.platform.launcher.TestPlan in project junit5 by junit-team.
the class RunListenerAdapterTests method notifiedEagerlyForTestSetWhenClassExecutionStarted.
@Test
void notifiedEagerlyForTestSetWhenClassExecutionStarted() throws Exception {
EngineDescriptor engine = newEngineDescriptor();
TestDescriptor parent = newClassDescriptor();
engine.addChild(parent);
TestDescriptor child = newMethodDescriptor();
parent.addChild(child);
TestPlan plan = TestPlan.from(Collections.singletonList(engine));
adapter.testPlanExecutionStarted(plan);
adapter.executionStarted(TestIdentifier.from(engine));
adapter.executionStarted(TestIdentifier.from(parent));
verify(listener).testSetStarting(new SimpleReportEntry(JUnitPlatformProvider.class.getName(), MyTestClass.class.getName()));
verifyNoMoreInteractions(listener);
adapter.executionStarted(TestIdentifier.from(child));
verify(listener).testStarting(new SimpleReportEntry(MyTestClass.class.getName(), MY_TEST_METHOD_NAME));
verifyNoMoreInteractions(listener);
adapter.executionFinished(TestIdentifier.from(child), successful());
verify(listener).testSucceeded(new SimpleReportEntry(MyTestClass.class.getName(), MY_TEST_METHOD_NAME));
verifyNoMoreInteractions(listener);
adapter.executionFinished(TestIdentifier.from(parent), successful());
verify(listener).testSetCompleted(new SimpleReportEntry(JUnitPlatformProvider.class.getName(), MyTestClass.class.getName()));
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 stackTraceWriterDefaultsToTestClass.
@Test
void stackTraceWriterDefaultsToTestClass() throws Exception {
TestPlan plan = TestPlan.from(Collections.singletonList(new EngineDescriptor(newId(), "Some Plan")));
adapter.testPlanExecutionStarted(plan);
TestIdentifier child = newSourcelessChildIdentifierWithParent(plan, "Parent", null);
adapter.executionFinished(child, TestExecutionResult.failed(new RuntimeException("message")));
ArgumentCaptor<ReportEntry> entryCaptor = ArgumentCaptor.forClass(ReportEntry.class);
verify(listener).testError(entryCaptor.capture());
assertNotNull(entryCaptor.getValue().getStackTraceWriter());
assertNotNull(entryCaptor.getValue().getStackTraceWriter().smartTrimmedStackTrace());
assertNotNull(entryCaptor.getValue().getStackTraceWriter().writeTraceToString());
assertNotNull(entryCaptor.getValue().getStackTraceWriter().writeTrimmedTraceToString());
}
use of org.junit.platform.launcher.TestPlan in project junit5 by junit-team.
the class RunListenerAdapterTests method stackTraceWriterPresentWhenParentHasSource.
@Test
void stackTraceWriterPresentWhenParentHasSource() throws Exception {
TestPlan plan = TestPlan.from(Collections.singletonList(new EngineDescriptor(newId(), "Some Plan")));
adapter.testPlanExecutionStarted(plan);
TestIdentifier child = newSourcelessChildIdentifierWithParent(plan, "Parent", ClassSource.from(MyTestClass.class));
adapter.executionFinished(child, TestExecutionResult.failed(new RuntimeException()));
ArgumentCaptor<ReportEntry> entryCaptor = ArgumentCaptor.forClass(ReportEntry.class);
verify(listener).testError(entryCaptor.capture());
assertNotNull(entryCaptor.getValue().getStackTraceWriter());
}
use of org.junit.platform.launcher.TestPlan in project junit5 by junit-team.
the class TestPlanScannerFilter method accept.
@Override
@SuppressWarnings("rawtypes")
public boolean accept(Class testClass) {
// @formatter:off
LauncherDiscoveryRequest discoveryRequest = request().selectors(selectClass(testClass)).filters(includeAndExcludeFilters).build();
// @formatter:on
TestPlan testPlan = launcher.discover(discoveryRequest);
return testPlan.containsTests();
}
use of org.junit.platform.launcher.TestPlan in project junit5 by junit-team.
the class DefaultLauncher method execute.
private void execute(Root root, ConfigurationParameters configurationParameters, TestExecutionListener... listeners) {
TestExecutionListenerRegistry listenerRegistry = buildListenerRegistryForExecution(listeners);
TestPlan testPlan = TestPlan.from(root.getEngineDescriptors());
TestExecutionListener testExecutionListener = listenerRegistry.getCompositeTestExecutionListener();
testExecutionListener.testPlanExecutionStarted(testPlan);
ExecutionListenerAdapter engineExecutionListener = new ExecutionListenerAdapter(testPlan, testExecutionListener);
for (TestEngine testEngine : root.getTestEngines()) {
TestDescriptor testDescriptor = root.getTestDescriptorFor(testEngine);
execute(testEngine, new ExecutionRequest(testDescriptor, engineExecutionListener, configurationParameters));
}
testExecutionListener.testPlanExecutionFinished(testPlan);
}
Aggregations