use of org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine in project junit5 by junit-team.
the class XmlReportsWritingListenerTests method measuresTimesInSeconds.
@Test
void measuresTimesInSeconds(@Root Path tempDirectory) throws Exception {
DemoHierarchicalTestEngine engine = new DemoHierarchicalTestEngine("dummy");
engine.addTest("firstTest", () -> {
});
engine.addTest("secondTest", () -> {
});
executeTests(engine, tempDirectory, new IncrementingClock(0, Duration.ofMillis(333)));
String content = readValidXmlFile(tempDirectory.resolve("TEST-dummy.xml"));
// @formatter:off
// start end
// ----------- ---------- -----------
// engine 0 (1) 1,665 (6)
// firstTest 333 (2) 666 (3)
// secondTest 999 (4) 1,332 (5)
assertThat(content).containsSubsequence("<testsuite", "time=\"1.665\"", "<testcase name=\"firstTest\" classname=\"dummy\" time=\"0.333\"", "<testcase name=\"secondTest\" classname=\"dummy\" time=\"0.333\"");
// @formatter:on
}
use of org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine in project junit5 by junit-team.
the class XmlReportsWritingListenerTests method writesFileForSingleFailingTest.
@Test
void writesFileForSingleFailingTest(@Root Path tempDirectory) throws Exception {
DemoHierarchicalTestEngine engine = new DemoHierarchicalTestEngine("dummy");
engine.addTest("failingTest", () -> fail("expected to <b>fail</b>"));
executeTests(engine, tempDirectory);
String content = readValidXmlFile(tempDirectory.resolve("TEST-dummy.xml"));
// @formatter:off
assertThat(content).containsSubsequence("<testsuite name=\"dummy\" tests=\"1\" skipped=\"0\" failures=\"1\" errors=\"0\"", "<testcase name=\"failingTest\"", "<failure message=\"expected to <b>fail</b>\" type=\"" + AssertionFailedError.class.getName() + "\">", "AssertionFailedError: expected to <b>fail</b>", "\tat", "</failure>", "</testcase>", "</testsuite>").doesNotContain("<skipped").doesNotContain("<error");
// @formatter:on
}
use of org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine in project junit5 by junit-team.
the class XmlReportsWritingListenerTests method writesFileForSingleSkippedTest.
@Test
void writesFileForSingleSkippedTest(@Root Path tempDirectory) throws Exception {
DemoHierarchicalTestEngine engine = new DemoHierarchicalTestEngine("dummy");
DemoHierarchicalTestDescriptor testDescriptor = engine.addTest("skippedTest", () -> fail("never called"));
testDescriptor.markSkipped("should be skipped");
executeTests(engine, tempDirectory);
String content = readValidXmlFile(tempDirectory.resolve("TEST-dummy.xml"));
// @formatter:off
assertThat(content).containsSubsequence("<testsuite name=\"dummy\" tests=\"1\" skipped=\"1\" failures=\"0\" errors=\"0\"", "<testcase name=\"skippedTest\"", "<skipped>", "should be skipped", "</skipped>", "</testcase>", "</testsuite>").doesNotContain("<failure").doesNotContain("<error");
// @formatter:on
}
use of org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine in project junit5 by junit-team.
the class XmlReportsWritingListenerTests method testWithImmeasurableTimeIsOutputCorrectly.
@Test
void testWithImmeasurableTimeIsOutputCorrectly(@Root Path tempDirectory) throws Exception {
DemoHierarchicalTestEngine engine = new DemoHierarchicalTestEngine("dummy");
engine.addTest("test", () -> {
});
executeTests(engine, tempDirectory, Clock.fixed(Instant.EPOCH, ZoneId.systemDefault()));
String content = readValidXmlFile(tempDirectory.resolve("TEST-dummy.xml"));
// @formatter:off
assertThat(content).containsSubsequence("<testsuite", "<testcase name=\"test\" classname=\"dummy\" time=\"0\"");
// @formatter:on
}
use of org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine in project junit5 by junit-team.
the class XmlReportsWritingListenerTests method writesFileForSkippedContainer.
@Test
void writesFileForSkippedContainer(@Root Path tempDirectory) throws Exception {
DemoHierarchicalTestEngine engine = new DemoHierarchicalTestEngine("dummy");
engine.addTest("test", () -> fail("never called"));
engine.getEngineDescriptor().markSkipped("should be skipped");
executeTests(engine, tempDirectory);
String content = readValidXmlFile(tempDirectory.resolve("TEST-dummy.xml"));
// @formatter:off
assertThat(content).containsSubsequence("<testsuite name=\"dummy\" tests=\"1\" skipped=\"1\" failures=\"0\" errors=\"0\"", "<testcase name=\"test\"", "<skipped>", "parent was skipped: should be skipped", "</skipped>", "</testcase>", "</testsuite>");
// @formatter:on
}
Aggregations