use of org.junit.platform.engine.TestDescriptor in project cucumber-jvm by cucumber.
the class DiscoverySelectorResolverTest method resolveRequestWithClasspathResourceSelectorAndFilePosition.
@Test
void resolveRequestWithClasspathResourceSelectorAndFilePosition() {
String feature = "io/cucumber/junit/platform/engine/rule.feature";
FilePosition line = FilePosition.from(5);
DiscoverySelector resource = selectClasspathResource(feature, line);
EngineDiscoveryRequest discoveryRequest = new SelectorRequest(resource);
resolver.resolveSelectors(discoveryRequest, testDescriptor);
assertEquals(1L, testDescriptor.getDescendants().stream().filter(TestDescriptor::isTest).count());
}
use of org.junit.platform.engine.TestDescriptor in project cucumber-jvm by cucumber.
the class DiscoverySelectorResolverTest method resolveRequestWithFileSelectorAndPosition.
@Test
void resolveRequestWithFileSelectorAndPosition() {
String feature = "src/test/resources/io/cucumber/junit/platform/engine/rule.feature";
FilePosition line = FilePosition.from(5);
DiscoverySelector resource = selectFile(feature, line);
EngineDiscoveryRequest discoveryRequest = new SelectorRequest(resource);
resolver.resolveSelectors(discoveryRequest, testDescriptor);
assertEquals(1L, testDescriptor.getDescendants().stream().filter(TestDescriptor::isTest).count());
}
use of org.junit.platform.engine.TestDescriptor in project cucumber-jvm by cucumber.
the class DiscoverySelectorResolverTest method resolveRequestWithClasspathResourceSelectorAndFilePositionOfContainer.
@Test
void resolveRequestWithClasspathResourceSelectorAndFilePositionOfContainer() {
String feature = "io/cucumber/junit/platform/engine/rule.feature";
FilePosition line = FilePosition.from(3);
DiscoverySelector resource = selectClasspathResource(feature, line);
EngineDiscoveryRequest discoveryRequest = new SelectorRequest(resource);
resolver.resolveSelectors(discoveryRequest, testDescriptor);
assertEquals(2L, testDescriptor.getDescendants().stream().filter(TestDescriptor::isTest).count());
}
use of org.junit.platform.engine.TestDescriptor in project graylog2-server by Graylog2.
the class ContainerMatrixMethodSelectorResolver method resolve.
private Resolution resolve(Context context, List<Class<?>> enclosingClasses, Class<?> testClass, Supplier<Method> methodSupplier) {
if (!testClassPredicate.test(testClass)) {
return unresolved();
}
Method method = methodSupplier.get();
// @formatter:off
Set<Match> matches = Arrays.stream(ContainerMatrixMethodSelectorResolver.MethodType.values()).map(methodType -> methodType.resolve(enclosingClasses, testClass, method, context, configuration)).filter(Optional::isPresent).map(Optional::get).map(testDescriptor -> Match.exact(testDescriptor, expansionCallback(testDescriptor))).collect(toSet());
// @formatter:on
if (matches.size() > 1) {
logger.warn(() -> {
Stream<TestDescriptor> testDescriptors = matches.stream().map(Match::getTestDescriptor);
return f("Possible configuration error: method [%s] resulted in multiple TestDescriptors %s. " + "This is typically the result of annotating a method with multiple competing annotations " + "such as @Test, @RepeatedTest, @ParameterizedTest, @TestFactory, etc.", method.toGenericString(), testDescriptors.map(d -> d.getClass().getName()).collect(toList()));
});
}
return matches.isEmpty() ? unresolved() : matches(matches);
}
use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.
the class AtypicalJvmMethodNameTests method kotlinTestWithMethodNameContainingSpecialCharacters.
@Test
void kotlinTestWithMethodNameContainingSpecialCharacters() {
EngineExecutionResults executionResults = executeTestsForClass(ArbitraryNamingKotlinTestCase.class);
assertThat(executionResults.testEvents().started().count()).isEqualTo(2);
TestDescriptor testDescriptor1 = executionResults.testEvents().succeeded().list().get(0).getTestDescriptor();
assertAll(//
() -> assertEquals(METHOD_NAME + "()", testDescriptor1.getDisplayName()), () -> assertEquals(METHOD_NAME + "()", testDescriptor1.getLegacyReportingName()));
TestDescriptor testDescriptor2 = executionResults.testEvents().succeeded().list().get(1).getTestDescriptor();
assertAll(//
() -> assertEquals("test name ends with parentheses()()", testDescriptor2.getDisplayName()), () -> assertEquals("test name ends with parentheses()()", testDescriptor2.getLegacyReportingName()));
}
Aggregations