use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.
the class VintageTestEngineDiscoveryTests method resolvesMethodSelectorForSingleMethod.
@Test
void resolvesMethodSelectorForSingleMethod() throws Exception {
Class<?> testClass = PlainJUnit4TestCaseWithFiveTestMethods.class;
LauncherDiscoveryRequest discoveryRequest = request().selectors(selectMethod(testClass, testClass.getMethod("failingTest"))).build();
TestDescriptor engineDescriptor = discoverTests(discoveryRequest);
TestDescriptor runnerDescriptor = getOnlyElement(engineDescriptor.getChildren());
assertRunnerTestDescriptor(runnerDescriptor, testClass);
TestDescriptor childDescriptor = getOnlyElement(runnerDescriptor.getChildren());
assertTestMethodDescriptor(childDescriptor, testClass, "failingTest", VintageUniqueIdBuilder.uniqueIdForClass(testClass));
}
use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.
the class RunListenerAdapter method registerDynamicTestDescriptor.
private VintageTestDescriptor registerDynamicTestDescriptor(Description description) {
// workaround for dynamic children as used by Spock's Runner
TestDescriptor parent = findParent(description);
UniqueId uniqueId = parent.getUniqueId().append(SEGMENT_TYPE_DYNAMIC, uniqueIdExtractor.apply(description));
VintageTestDescriptor dynamicDescriptor = new VintageTestDescriptor(uniqueId, description);
parent.addChild(dynamicDescriptor);
testRun.registerDynamicTest(dynamicDescriptor);
dynamicTestRegistered(dynamicDescriptor);
return dynamicDescriptor;
}
use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.
the class VintageDiscovererTests method classNameFilterExcludesClass.
@Test
void classNameFilterExcludesClass() {
// @formatter:off
EngineDiscoveryRequest request = request().selectors(selectClass(Foo.class), selectClass(Bar.class)).filters(ClassNameFilter.includeClassNamePatterns(".*Foo")).build();
// @formatter:on
VintageDiscoverer discoverer = new VintageDiscoverer();
TestDescriptor testDescriptor = discoverer.discover(request, engineId());
assertThat(testDescriptor.getChildren()).hasSize(1);
assertThat(getOnlyElement(testDescriptor.getChildren()).getUniqueId().toString()).contains(Foo.class.getName());
}
use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.
the class DiscoveryFilterApplierTests method packageNameFilterInclude_nonMatchingPackagesAreExcluded.
@Test
void packageNameFilterInclude_nonMatchingPackagesAreExcluded() {
// @formatter:off
TestDescriptor engineDescriptor = engineDescriptor().with(classTestDescriptor("matching", MatchingClass.class)).build();
// @formatter:on
applyClassNamePredicate(engineDescriptor, includePackageNames("org.junit.jupiter.engine.unknown"));
assertThat(engineDescriptor.getDescendants()).isEmpty();
}
use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.
the class DiscoveryFilterApplierTests method packageNameFilterExclude_nonMatchingPackagesAreIncluded.
@Test
void packageNameFilterExclude_nonMatchingPackagesAreIncluded() {
// @formatter:off
TestDescriptor engineDescriptor = engineDescriptor().with(classTestDescriptor("matching", MatchingClass.class)).build();
applyClassNamePredicate(engineDescriptor, excludePackageNames("org.junit.jupiter.engine.unknown"));
assertThat(engineDescriptor.getDescendants()).extracting(TestDescriptor::getUniqueId).containsExactly(UniqueId.root("class", "matching"));
// @formatter:on
}
Aggregations