use of org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine in project junit5 by junit-team.
the class XmlReportsWritingListenerTests method writesFileForFailingContainer.
@Test
void writesFileForFailingContainer(@Root Path tempDirectory) throws Exception {
DemoHierarchicalTestEngine engine = new DemoHierarchicalTestEngine("dummy");
engine.addTest("test", () -> fail("never called"));
engine.getEngineDescriptor().setBeforeAllBehavior(() -> fail("failure before all tests"));
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=\"test\"", "<failure message=\"failure before all tests\" type=\"" + AssertionFailedError.class.getName() + "\">", "AssertionFailedError: failure before all tests", "\tat", "</failure>", "</testcase>", "</testsuite>");
// @formatter:on
}
use of org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine in project junit5 by junit-team.
the class XmlReportsWritingListenerTests method writesFileForSingleAbortedTest.
@Test
void writesFileForSingleAbortedTest(@Root Path tempDirectory) throws Exception {
DemoHierarchicalTestEngine engine = new DemoHierarchicalTestEngine("dummy");
engine.addTest("abortedTest", () -> assumeFalse(true, "deliberately aborted"));
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=\"abortedTest\"", "<skipped>", "TestAbortedException: ", "deliberately aborted", "at ", "</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 writesSystemProperties.
@Test
void writesSystemProperties(@Root Path tempDirectory) throws Exception {
DemoHierarchicalTestEngine engine = new DemoHierarchicalTestEngine("dummy");
engine.addTest("test", () -> {
});
executeTests(engine, tempDirectory);
String content = readValidXmlFile(tempDirectory.resolve("TEST-dummy.xml"));
// @formatter:off
assertThat(content).containsSubsequence("<testsuite", "<properties>", "<property name=\"file.separator\" value=\"" + File.separator + "\"/>", "<property name=\"path.separator\" value=\"" + File.pathSeparator + "\"/>", "</properties>", "<testcase", "</testsuite>");
// @formatter:on
}
use of org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine in project junit5 by junit-team.
the class XmlReportsWritingListenerTests method writesFileForSingleSucceedingTest.
@Test
void writesFileForSingleSucceedingTest(@Root Path tempDirectory) throws Exception {
DemoHierarchicalTestEngine engine = new DemoHierarchicalTestEngine("dummy");
engine.addTest("succeedingTest", "display<-->Name 😎", () -> {
});
executeTests(engine, tempDirectory);
String content = readValidXmlFile(tempDirectory.resolve("TEST-dummy.xml"));
// @formatter:off
assertThat(content).containsSubsequence("<testsuite name=\"dummy\" tests=\"1\" skipped=\"0\" failures=\"0\" errors=\"0\"", "<testcase name=\"display<-->Name 😎\" classname=\"dummy\"", "<system-out>", "unique-id: [engine:dummy]/[test:succeedingTest]", "display-name: display<-->Name 😎", "</system-out>", "</testcase>", "<system-out>", "unique-id: [engine:dummy]", "display-name: dummy", "</system-out>", "</testsuite>").doesNotContain("<skipped").doesNotContain("<failure").doesNotContain("<error");
// @formatter:on
}
use of org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine in project junit5 by junit-team.
the class DefaultLauncherTests method launcherWillExecuteEnginesHonoringBothIncludeAndExcludeEngineFilters.
@Test
void launcherWillExecuteEnginesHonoringBothIncludeAndExcludeEngineFilters() {
DemoHierarchicalTestEngine firstEngine = new DemoHierarchicalTestEngine("first");
TestDescriptor test1 = firstEngine.addTest("test1", noOp);
DemoHierarchicalTestEngine secondEngine = new DemoHierarchicalTestEngine("second");
TestDescriptor test2 = secondEngine.addTest("test2", noOp);
DemoHierarchicalTestEngine thirdEngine = new DemoHierarchicalTestEngine("third");
TestDescriptor test3 = thirdEngine.addTest("test3", noOp);
DefaultLauncher launcher = createLauncher(firstEngine, secondEngine, thirdEngine);
// @formatter:off
TestPlan testPlan = launcher.discover(request().selectors(selectUniqueId(test1.getUniqueId()), selectUniqueId(test2.getUniqueId()), selectUniqueId(test3.getUniqueId())).filters(includeEngines("first", "second"), excludeEngines("second")).build());
// @formatter:on
assertThat(testPlan.getRoots()).hasSize(1);
TestIdentifier rootIdentifier = testPlan.getRoots().iterator().next();
assertThat(testPlan.getChildren(rootIdentifier.getUniqueId())).hasSize(1);
assertThat(testPlan.getChildren(UniqueId.forEngine("first").toString())).hasSize(1);
}
Aggregations