use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.
the class TestIdentifierTests method inheritsIdAndNamesFromDescriptor.
@Test
void inheritsIdAndNamesFromDescriptor() {
TestDescriptor testDescriptor = new TestDescriptorStub(UniqueId.root("aType", "uniqueId"), "displayName");
TestIdentifier testIdentifier = TestIdentifier.from(testDescriptor);
assertEquals("[aType:uniqueId]", testIdentifier.getUniqueId());
assertEquals("displayName", testIdentifier.getDisplayName());
}
use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.
the class TestIdentifierTests method inheritsTypeFromDescriptor.
@Test
void inheritsTypeFromDescriptor() {
TestDescriptor descriptor = new TestDescriptorStub(UniqueId.root("aType", "uniqueId"), "displayName");
TestIdentifier identifier = TestIdentifier.from(descriptor);
assertEquals(TestDescriptor.Type.TEST, identifier.getType());
assertTrue(identifier.isTest());
assertFalse(identifier.isContainer());
descriptor.addChild(new TestDescriptorStub(UniqueId.root("aChild", "uniqueId"), "displayName"));
identifier = TestIdentifier.from(descriptor);
assertEquals(TestDescriptor.Type.CONTAINER, identifier.getType());
assertFalse(identifier.isTest());
assertTrue(identifier.isContainer());
}
use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.
the class DefaultLauncherTests method launcherWillNotExecuteEnginesExplicitlyIncludedViaMultipleCompetingEngineFilters.
@Test
void launcherWillNotExecuteEnginesExplicitlyIncludedViaMultipleCompetingEngineFilters() {
DemoHierarchicalTestEngine firstEngine = new DemoHierarchicalTestEngine("first");
TestDescriptor test1 = firstEngine.addTest("test1", noOp);
DemoHierarchicalTestEngine secondEngine = new DemoHierarchicalTestEngine("second");
TestDescriptor test2 = secondEngine.addTest("test2", noOp);
DefaultLauncher launcher = createLauncher(firstEngine, secondEngine);
// @formatter:off
TestPlan testPlan = launcher.discover(request().selectors(selectUniqueId(test1.getUniqueId()), selectUniqueId(test2.getUniqueId())).filters(includeEngines("first"), includeEngines("second")).build());
// @formatter:on
assertThat(testPlan.getRoots()).isEmpty();
}
use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.
the class DefaultLauncherTests method prunesTestDescriptorsAfterApplyingPostDiscoveryFilters.
@Test
void prunesTestDescriptorsAfterApplyingPostDiscoveryFilters() {
TestEngineSpy engine = new TestEngineSpy() {
@Override
public TestDescriptor discover(EngineDiscoveryRequest discoveryRequest, UniqueId uniqueId) {
super.discover(discoveryRequest, uniqueId);
TestDescriptorStub engineDescriptor = new TestDescriptorStub(uniqueId, uniqueId.toString());
TestDescriptorStub containerDescriptor = new TestDescriptorStub(uniqueId.append("container", "a"), "container") {
@Override
public Type getType() {
return Type.CONTAINER;
}
};
containerDescriptor.addChild(new TestDescriptorStub(containerDescriptor.getUniqueId().append("test", "b"), "test"));
engineDescriptor.addChild(containerDescriptor);
return engineDescriptor;
}
};
DefaultLauncher launcher = createLauncher(engine);
TestPlan testPlan = launcher.discover(request().filters((PostDiscoveryFilter) testDescriptor -> FilterResult.includedIf(testDescriptor.isContainer())).build());
assertThat(testPlan.getRoots()).hasSize(1);
TestIdentifier engineIdentifier = getOnlyElement(testPlan.getRoots());
assertThat(testPlan.getChildren(engineIdentifier)).isEmpty();
}
use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.
the class DefaultLauncherTests method launcherWillExecuteAllEnginesExplicitlyIncludedViaSingleEngineFilter.
@Test
void launcherWillExecuteAllEnginesExplicitlyIncludedViaSingleEngineFilter() {
DemoHierarchicalTestEngine firstEngine = new DemoHierarchicalTestEngine("first");
TestDescriptor test1 = firstEngine.addTest("test1", noOp);
DemoHierarchicalTestEngine secondEngine = new DemoHierarchicalTestEngine("second");
TestDescriptor test2 = secondEngine.addTest("test2", noOp);
DefaultLauncher launcher = createLauncher(firstEngine, secondEngine);
// @formatter:off
TestPlan testPlan = launcher.discover(request().selectors(selectUniqueId(test1.getUniqueId()), selectUniqueId(test2.getUniqueId())).filters(includeEngines("first", "second")).build());
// @formatter:on
assertThat(testPlan.getRoots()).hasSize(2);
}
Aggregations