use of org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestDescriptor 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.DemoHierarchicalTestDescriptor 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
}
Aggregations