use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.
the class RunListenerAdapterTests method newSourcelessChildIdentifierWithParent.
private static TestIdentifier newSourcelessChildIdentifierWithParent(TestPlan testPlan, String parentDisplay, TestSource parentTestSource) {
// A parent test identifier with a name.
TestDescriptor parent = mock(TestDescriptor.class);
when(parent.getUniqueId()).thenReturn(newId());
when(parent.getDisplayName()).thenReturn(parentDisplay);
when(parent.getLegacyReportingName()).thenReturn(parentDisplay);
when(parent.getSource()).thenReturn(Optional.ofNullable(parentTestSource));
when(parent.getType()).thenReturn(Type.CONTAINER);
TestIdentifier parentId = TestIdentifier.from(parent);
// The (child) test case that is to be executed as part of a test plan.
TestDescriptor child = mock(TestDescriptor.class);
when(child.getUniqueId()).thenReturn(newId());
when(child.getType()).thenReturn(Type.TEST);
when(child.getLegacyReportingName()).thenReturn("child");
// Ensure the child source is null yet that there is a parent -- the special case to be tested.
when(child.getSource()).thenReturn(Optional.empty());
when(child.getParent()).thenReturn(Optional.of(parent));
TestIdentifier childId = TestIdentifier.from(child);
testPlan.add(childId);
testPlan.add(parentId);
return childId;
}
use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.
the class DefaultLauncher method execute.
private void execute(Root root, ConfigurationParameters configurationParameters, TestExecutionListener... listeners) {
TestExecutionListenerRegistry listenerRegistry = buildListenerRegistryForExecution(listeners);
TestPlan testPlan = TestPlan.from(root.getEngineDescriptors());
TestExecutionListener testExecutionListener = listenerRegistry.getCompositeTestExecutionListener();
testExecutionListener.testPlanExecutionStarted(testPlan);
ExecutionListenerAdapter engineExecutionListener = new ExecutionListenerAdapter(testPlan, testExecutionListener);
for (TestEngine testEngine : root.getTestEngines()) {
TestDescriptor testDescriptor = root.getTestDescriptorFor(testEngine);
execute(testEngine, new ExecutionRequest(testDescriptor, engineExecutionListener, configurationParameters));
}
testExecutionListener.testPlanExecutionFinished(testPlan);
}
use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.
the class ExecutionEventRecorder method execute.
public static void execute(TestEngine testEngine, EngineDiscoveryRequest discoveryRequest, EngineExecutionListener listener) {
TestDescriptor engineTestDescriptor = testEngine.discover(discoveryRequest, UniqueId.forEngine(testEngine.getId()));
testEngine.execute(new ExecutionRequest(engineTestDescriptor, listener, discoveryRequest.getConfigurationParameters()));
}
use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.
the class DiscoveryFilterApplierTests method nestedTestClassesAreAlwaysIncludedWhenTheirParentIs.
@Test
void nestedTestClassesAreAlwaysIncludedWhenTheirParentIs() {
// @formatter:off
TestDescriptor engineDescriptor = engineDescriptor().with(classTestDescriptor("matching", MatchingClass.class).with(nestedClassTestDescriptor("nested", MatchingClass.NestedClass.class))).build();
applyClassNamePredicate(engineDescriptor, includeClassNamePatterns(".*\\$MatchingClass"));
assertThat(engineDescriptor.getDescendants()).extracting(TestDescriptor::getUniqueId).containsExactlyInAnyOrder(UniqueId.root("class", "matching"), UniqueId.root("nested-class", "nested"));
// @formatter:on
}
use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.
the class DiscoveryFilterApplierTests method nonMatchingClassesAreExcluded.
@Test
void nonMatchingClassesAreExcluded() {
// @formatter:off
TestDescriptor engineDescriptor = engineDescriptor().with(classTestDescriptor("matching", MatchingClass.class), classTestDescriptor("other", OtherClass.class)).build();
applyClassNamePredicate(engineDescriptor, includeClassNamePatterns(".*\\$MatchingClass"));
assertThat(engineDescriptor.getDescendants()).extracting(TestDescriptor::getUniqueId).containsExactly(UniqueId.root("class", "matching"));
// @formatter:on
}
Aggregations