use of org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine in project junit5 by junit-team.
the class DefaultLauncherTests method launcherAppliesPostDiscoveryFilters.
@Test
void launcherAppliesPostDiscoveryFilters() {
DemoHierarchicalTestEngine engine = new DemoHierarchicalTestEngine("myEngine");
DemoHierarchicalTestDescriptor test1 = engine.addTest("test1", noOp);
engine.addTest("test2", noOp);
DefaultLauncher launcher = createLauncher(engine);
PostDiscoveryFilter includeWithUniqueIdContainsTest = new PostDiscoveryFilterStub(descriptor -> FilterResult.includedIf(descriptor.getUniqueId().toString().contains("test")), () -> "filter1");
PostDiscoveryFilter includeWithUniqueIdContains1 = new PostDiscoveryFilterStub(descriptor -> FilterResult.includedIf(descriptor.getUniqueId().toString().contains("1")), () -> "filter2");
TestPlan testPlan = //
launcher.discover(//
request().selectors(//
selectPackage("any")).filters(includeWithUniqueIdContainsTest, //
includeWithUniqueIdContains1).build());
assertThat(testPlan.getChildren(UniqueId.forEngine("myEngine").toString())).hasSize(1);
assertThat(testPlan.getTestIdentifier(test1.getUniqueId().toString())).isNotNull();
}
use of org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine in project junit5 by junit-team.
the class DefaultLauncherTests method discoverEmptyTestPlanWithEngineWithoutAnyTests.
@Test
void discoverEmptyTestPlanWithEngineWithoutAnyTests() {
DefaultLauncher launcher = createLauncher(new DemoHierarchicalTestEngine());
TestPlan testPlan = launcher.discover(request().build());
assertThat(testPlan.getRoots()).hasSize(1);
}
use of org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine in project junit5 by junit-team.
the class DefaultLauncherTests method registerTestExecutionListenersWithArrayContainingNullElements.
@Test
void registerTestExecutionListenersWithArrayContainingNullElements() {
DefaultLauncher launcher = createLauncher(new DemoHierarchicalTestEngine("dummy id"));
PreconditionViolationException exception = assertThrows(PreconditionViolationException.class, () -> launcher.registerTestExecutionListeners(new TestExecutionListener[] { null }));
assertThat(exception).hasMessageContaining("individual listeners must not be null");
}
use of org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine in project junit5 by junit-team.
the class XmlReportsWritingListenerTests method writesHostNameAndTimestamp.
@Test
void writesHostNameAndTimestamp(@Root Path tempDirectory) throws Exception {
DemoHierarchicalTestEngine engine = new DemoHierarchicalTestEngine("dummy");
engine.addTest("test", () -> {
});
LocalDateTime now = LocalDateTime.parse("2016-01-28T14:02:59.123");
ZoneId zone = ZoneId.systemDefault();
executeTests(engine, tempDirectory, Clock.fixed(ZonedDateTime.of(now, zone).toInstant(), zone));
String content = readValidXmlFile(tempDirectory.resolve("TEST-dummy.xml"));
// @formatter:off
assertThat(content).containsSubsequence("<testsuite", "hostname=\"" + InetAddress.getLocalHost().getHostName() + "\"", "timestamp=\"2016-01-28T14:02:59\"", "<testcase", "</testsuite>");
// @formatter:on
}
use of org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine in project junit5 by junit-team.
the class XmlReportsWritingListenerTests method writesFileForSingleErroneousTest.
@Test
void writesFileForSingleErroneousTest(@Root Path tempDirectory) throws Exception {
DemoHierarchicalTestEngine engine = new DemoHierarchicalTestEngine("dummy");
engine.addTest("failingTest", () -> {
throw new RuntimeException("error occurred");
});
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=\"1\"", "<testcase name=\"failingTest\"", "<error message=\"error occurred\" type=\"java.lang.RuntimeException\">", "RuntimeException: error occurred", "\tat ", "</error>", "</testcase>", "</testsuite>").doesNotContain("<skipped").doesNotContain("<failure");
// @formatter:on
}
Aggregations