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();
}
Aggregations