Search in sources :

Example 1 with PostDiscoveryFilterStub

use of org.junit.platform.launcher.PostDiscoveryFilterStub 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)

Aggregations

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