use of org.junit.platform.engine.support.descriptor.EngineDescriptor in project junit5 by junit-team.
the class XmlReportWriterTests method writesEmptyErrorElementForFailedTestWithoutCause.
@Test
void writesEmptyErrorElementForFailedTestWithoutCause() throws Exception {
engineDescriptor = new EngineDescriptor(UniqueId.forEngine("myEngineId"), "Fancy Engine") {
@Override
public String getLegacyReportingName() {
return "myEngine";
}
};
UniqueId uniqueId = engineDescriptor.getUniqueId().append("test", "test");
engineDescriptor.addChild(new TestDescriptorStub(uniqueId, "some fancy name") {
@Override
public String getLegacyReportingName() {
return "failedTest";
}
});
TestPlan testPlan = TestPlan.from(singleton(engineDescriptor));
XmlReportData reportData = new XmlReportData(testPlan, Clock.systemDefaultZone());
reportData.markFinished(testPlan.getTestIdentifier(uniqueId.toString()), failed(null));
String content = writeXmlReport(testPlan, reportData);
assertValidAccordingToJenkinsSchema(content);
// @formatter:off
assertThat(content).containsSubsequence("<testcase name=\"failedTest\" classname=\"myEngine\"", "<error/>", "</testcase>");
// @formatter:on
}
use of org.junit.platform.engine.support.descriptor.EngineDescriptor in project junit5 by junit-team.
the class XmlReportsWritingListenerTests method writesReportEntriesToSystemOutElement.
@Test
void writesReportEntriesToSystemOutElement(@Root Path tempDirectory, TestReporter testReporter) throws Exception {
EngineDescriptor engineDescriptor = new EngineDescriptor(UniqueId.forEngine("engine"), "Engine");
engineDescriptor.addChild(new TestDescriptorStub(UniqueId.root("child", "test"), "test"));
TestPlan testPlan = TestPlan.from(singleton(engineDescriptor));
StringWriter out = new StringWriter();
XmlReportsWritingListener listener = new XmlReportsWritingListener(tempDirectory, new PrintWriter(out));
listener.testPlanExecutionStarted(testPlan);
TestIdentifier testIdentifier = testPlan.getTestIdentifier("[child:test]");
listener.executionStarted(testIdentifier);
listener.reportingEntryPublished(testIdentifier, ReportEntry.from("foo", "bar"));
Map<String, String> map = new LinkedHashMap<>();
map.put("bar", "baz");
map.put("qux", "foo");
listener.reportingEntryPublished(testIdentifier, ReportEntry.from(map));
listener.executionFinished(testIdentifier, successful());
listener.executionFinished(testPlan.getTestIdentifier("[engine:engine]"), successful());
String content = readValidXmlFile(tempDirectory.resolve("TEST-engine.xml"));
// testReporter.publishEntry("xml", content);
// @formatter:off
assertThat(content).containsSubsequence("<testsuite", "<testcase", "<system-out>", "Report Entry #1 (timestamp: " + Year.now(), "- foo: bar\n", "Report Entry #2 (timestamp: " + Year.now(), "- bar: baz\n", "- qux: foo\n", "</system-out>", "</testcase>", "</testsuite>");
// @formatter:on
}
use of org.junit.platform.engine.support.descriptor.EngineDescriptor 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.junit.platform.engine.support.descriptor.EngineDescriptor 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.junit.platform.engine.support.descriptor.EngineDescriptor in project junit5 by junit-team.
the class RunListenerAdapterTests method notifiedForTestSetForSingleNodeEngine.
@Test
void notifiedForTestSetForSingleNodeEngine() {
EngineDescriptor engine = new EngineDescriptor(UniqueId.forEngine("engine"), "engine") {
@Override
public Type getType() {
return Type.TEST;
}
};
TestPlan plan = TestPlan.from(Collections.singletonList(engine));
adapter.testPlanExecutionStarted(plan);
adapter.executionStarted(TestIdentifier.from(engine));
InOrder inOrder = inOrder(listener);
inOrder.verify(listener).testSetStarting(new SimpleReportEntry(JUnitPlatformProvider.class.getName(), "engine"));
inOrder.verify(listener).testStarting(new SimpleReportEntry("<unrooted>", "engine"));
inOrder.verifyNoMoreInteractions();
adapter.executionFinished(TestIdentifier.from(engine), successful());
inOrder = inOrder(listener);
inOrder.verify(listener).testSucceeded(new SimpleReportEntry("<unrooted>", "engine"));
inOrder.verify(listener).testSetCompleted(new SimpleReportEntry(JUnitPlatformProvider.class.getName(), "engine"));
inOrder.verifyNoMoreInteractions();
}
Aggregations