use of org.apache.maven.surefire.report.ReportEntry 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.apache.maven.surefire.report.ReportEntry 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.apache.maven.surefire.report.ReportEntry 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.apache.maven.surefire.report.ReportEntry 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.apache.maven.surefire.report.ReportEntry 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());
}
Aggregations