use of org.junit.platform.engine.support.descriptor.EngineDescriptor 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());
}
use of org.junit.platform.engine.support.descriptor.EngineDescriptor 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.engine.support.descriptor.EngineDescriptor 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.engine.support.descriptor.EngineDescriptor 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.engine.support.descriptor.EngineDescriptor in project junit5 by junit-team.
the class VintageDiscoverer method discover.
public TestDescriptor discover(EngineDiscoveryRequest discoveryRequest, UniqueId uniqueId) {
EngineDescriptor engineDescriptor = new EngineDescriptor(uniqueId, "JUnit Vintage");
// @formatter:off
collectTestClasses(discoveryRequest).toRequests().map(request -> resolver.createRunnerTestDescriptor(request, uniqueId)).filter(Objects::nonNull).forEach(engineDescriptor::addChild);
// @formatter:on
return engineDescriptor;
}
Aggregations