use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.
the class DiscoveryFilterApplierTests method packageNameFilterExclude_matchingPackagesAreExcluded.
@Test
void packageNameFilterExclude_matchingPackagesAreExcluded() {
// @formatter:off
TestDescriptor engineDescriptor = engineDescriptor().with(classTestDescriptor("matching", MatchingClass.class)).build();
// @formatter:on
applyClassNamePredicate(engineDescriptor, excludePackageNames("org.junit.jupiter.engine"));
assertThat(engineDescriptor.getDescendants()).isEmpty();
}
use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.
the class TestClassWithTemplate method resolvingDynamicTestByUniqueIdAndTestFactoryByMethodSelectorResolvesTestFactory.
@Test
void resolvingDynamicTestByUniqueIdAndTestFactoryByMethodSelectorResolvesTestFactory() {
Class<?> clazz = MyTestClass.class;
UniqueId factoryUid = uniqueIdForTestFactoryMethod(clazz, "dynamicTest()");
UniqueId dynamicTestUid = factoryUid.append(DYNAMIC_TEST_SEGMENT_TYPE, "#1");
LauncherDiscoveryRequest request = //
request().selectors(selectUniqueId(dynamicTestUid), //
selectMethod(clazz, "dynamicTest")).build();
resolver.resolveSelectors(request, engineDescriptor);
assertThat(engineDescriptor.getDescendants()).hasSize(2);
assertThat(uniqueIds()).containsSequence(uniqueIdForClass(clazz), factoryUid);
TestDescriptor testClassDescriptor = getOnlyElement(engineDescriptor.getChildren());
TestDescriptor testFactoryDescriptor = getOnlyElement(testClassDescriptor.getChildren());
DynamicDescendantFilter dynamicDescendantFilter = getDynamicDescendantFilter(testFactoryDescriptor);
assertThat(dynamicDescendantFilter.test(UniqueId.root("foo", "bar"))).isTrue();
}
use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.
the class TestClassWithTemplate method resolvingDynamicTestByUniqueIdResolvesUpToParentTestFactory.
@Test
@TrackLogRecords
void resolvingDynamicTestByUniqueIdResolvesUpToParentTestFactory(LogRecordListener listener) {
Class<?> clazz = MyTestClass.class;
UniqueId factoryUid = uniqueIdForTestFactoryMethod(clazz, "dynamicTest()");
UniqueId dynamicTestUid = factoryUid.append(DYNAMIC_TEST_SEGMENT_TYPE, "#1");
UniqueId differentDynamicTestUid = factoryUid.append(DYNAMIC_TEST_SEGMENT_TYPE, "#2");
resolver.resolveSelectors(request().selectors(selectUniqueId(dynamicTestUid)).build(), engineDescriptor);
assertThat(engineDescriptor.getDescendants()).hasSize(2);
assertThat(uniqueIds()).containsSequence(uniqueIdForClass(clazz), factoryUid);
TestDescriptor testClassDescriptor = getOnlyElement(engineDescriptor.getChildren());
TestDescriptor testFactoryDescriptor = getOnlyElement(testClassDescriptor.getChildren());
DynamicDescendantFilter dynamicDescendantFilter = getDynamicDescendantFilter(testFactoryDescriptor);
assertThat(dynamicDescendantFilter.test(dynamicTestUid)).isTrue();
assertThat(dynamicDescendantFilter.test(differentDynamicTestUid)).isFalse();
assertThat(listener.stream(JavaElementsResolver.class)).isEmpty();
}
use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.
the class TestClassWithTemplate method resolvingDynamicContainerByUniqueIdResolvesUpToParentTestFactory.
@Test
@TrackLogRecords
void resolvingDynamicContainerByUniqueIdResolvesUpToParentTestFactory(LogRecordListener listener) {
Class<?> clazz = MyTestClass.class;
UniqueId factoryUid = uniqueIdForTestFactoryMethod(clazz, "dynamicTest()");
UniqueId dynamicContainerUid = factoryUid.append(DYNAMIC_CONTAINER_SEGMENT_TYPE, "#1");
UniqueId differentDynamicContainerUid = factoryUid.append(DYNAMIC_CONTAINER_SEGMENT_TYPE, "#2");
UniqueId dynamicTestUid = dynamicContainerUid.append(DYNAMIC_TEST_SEGMENT_TYPE, "#1");
UniqueId differentDynamicTestUid = dynamicContainerUid.append(DYNAMIC_TEST_SEGMENT_TYPE, "#2");
resolver.resolveSelectors(request().selectors(selectUniqueId(dynamicTestUid)).build(), engineDescriptor);
assertThat(engineDescriptor.getDescendants()).hasSize(2);
assertThat(uniqueIds()).containsSequence(uniqueIdForClass(clazz), factoryUid);
TestDescriptor testClassDescriptor = getOnlyElement(engineDescriptor.getChildren());
TestDescriptor testFactoryDescriptor = getOnlyElement(testClassDescriptor.getChildren());
DynamicDescendantFilter dynamicDescendantFilter = getDynamicDescendantFilter(testFactoryDescriptor);
assertThat(dynamicDescendantFilter.test(dynamicTestUid)).isTrue();
assertThat(dynamicDescendantFilter.test(differentDynamicContainerUid)).isFalse();
assertThat(dynamicDescendantFilter.test(differentDynamicTestUid)).isFalse();
assertThat(listener.stream(JavaElementsResolver.class)).isEmpty();
}
use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.
the class StandardTestClassTests method standardTestClassIsCorrectlyDiscovered.
@Test
void standardTestClassIsCorrectlyDiscovered() {
LauncherDiscoveryRequest request = request().selectors(selectClass(MyStandardTestCase.class)).build();
TestDescriptor engineDescriptor = discoverTests(request);
assertEquals(5, engineDescriptor.getDescendants().size(), "# resolved test descriptors");
}
Aggregations