Search in sources :

Example 1 with DemoHierarchicalTestDescriptor

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();
}
Also used : TestPlan(org.junit.platform.launcher.TestPlan) DemoHierarchicalTestDescriptor(org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestDescriptor) PostDiscoveryFilter(org.junit.platform.launcher.PostDiscoveryFilter) DemoHierarchicalTestEngine(org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine) PostDiscoveryFilterStub(org.junit.platform.launcher.PostDiscoveryFilterStub) Test(org.junit.jupiter.api.Test)

Example 2 with DemoHierarchicalTestDescriptor

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
}
Also used : DemoHierarchicalTestDescriptor(org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestDescriptor) DemoHierarchicalTestEngine(org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)2 DemoHierarchicalTestDescriptor (org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestDescriptor)2 DemoHierarchicalTestEngine (org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine)2 PostDiscoveryFilter (org.junit.platform.launcher.PostDiscoveryFilter)1 PostDiscoveryFilterStub (org.junit.platform.launcher.PostDiscoveryFilterStub)1 TestPlan (org.junit.platform.launcher.TestPlan)1