use of org.junit.platform.launcher.LauncherDiscoveryRequest in project junit5 by junit-team.
the class VintageTestEngineDiscoveryTests method resolvesSimpleJUnit4TestClass.
@Test
void resolvesSimpleJUnit4TestClass() throws Exception {
Class<?> testClass = PlainJUnit4TestCaseWithSingleTestWhichFails.class;
LauncherDiscoveryRequest discoveryRequest = discoveryRequestForClass(testClass);
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.launcher.LauncherDiscoveryRequest in project junit5 by junit-team.
the class VintageTestEngineDiscoveryTests method resolvesTestSourceForParameterizedTests.
@Test
void resolvesTestSourceForParameterizedTests() throws Exception {
Class<?> testClass = ParameterizedTestCase.class;
LauncherDiscoveryRequest request = request().selectors(selectClass(testClass)).build();
TestDescriptor engineDescriptor = discoverTests(request);
TestDescriptor runnerDescriptor = getOnlyElement(engineDescriptor.getChildren());
assertRunnerTestDescriptor(runnerDescriptor, testClass);
TestDescriptor fooParentDescriptor = findChildByDisplayName(runnerDescriptor, "[foo]");
assertTrue(fooParentDescriptor.isContainer());
assertFalse(fooParentDescriptor.isTest());
assertThat(fooParentDescriptor.getSource()).isEmpty();
TestDescriptor testMethodDescriptor = getOnlyElement(fooParentDescriptor.getChildren());
assertEquals("test[foo]", testMethodDescriptor.getDisplayName());
assertTrue(testMethodDescriptor.isTest());
assertFalse(testMethodDescriptor.isContainer());
assertMethodSource(testClass.getMethod("test"), testMethodDescriptor);
}
use of org.junit.platform.launcher.LauncherDiscoveryRequest in project junit5 by junit-team.
the class VintageTestEngineDiscoveryTests method resolvesClassForMethodSelectorForClassWithNonFilterableRunner.
@Test
void resolvesClassForMethodSelectorForClassWithNonFilterableRunner() {
Class<?> testClass = JUnit4TestCaseWithNotFilterableRunner.class;
// @formatter:off
LauncherDiscoveryRequest request = request().selectors(selectUniqueId(VintageUniqueIdBuilder.uniqueIdForMethod(testClass, "Test #0"))).build();
// @formatter:on
TestDescriptor engineDescriptor = discoverTests(request);
TestDescriptor runnerDescriptor = getOnlyElement(engineDescriptor.getChildren());
assertEquals(testClass.getName(), runnerDescriptor.getDisplayName());
assertEquals(VintageUniqueIdBuilder.uniqueIdForClass(testClass), runnerDescriptor.getUniqueId());
assertThat(runnerDescriptor.getChildren()).isNotEmpty();
}
use of org.junit.platform.launcher.LauncherDiscoveryRequest in project junit5 by junit-team.
the class VintageTestEngineDiscoveryTests method resolvesApplyingClassNameFilters.
@Test
void resolvesApplyingClassNameFilters() throws Exception {
Path root = getClasspathRoot(PlainJUnit4TestCaseWithSingleTestWhichFails.class);
LauncherDiscoveryRequest discoveryRequest = request().selectors(selectClasspathRoots(singleton(root))).filters(includeClassNamePatterns(".*JUnit4.*"), includeClassNamePatterns(".*Plain.*")).build();
TestDescriptor engineDescriptor = discoverTests(discoveryRequest);
// @formatter:off
assertThat(engineDescriptor.getChildren()).extracting(TestDescriptor::getDisplayName).contains(PlainJUnit4TestCaseWithSingleTestWhichFails.class.getName()).doesNotContain(JUnit4TestCaseWithOverloadedMethod.class.getName()).doesNotContain(PlainJUnit3TestCaseWithSingleTestWhichFails.class.getName());
// @formatter:on
}
use of org.junit.platform.launcher.LauncherDiscoveryRequest in project junit5 by junit-team.
the class VintageTestEngineDiscoveryTests method usesCustomUniqueIdsWhenPresent.
@Test
void usesCustomUniqueIdsWhenPresent() {
Class<?> testClass = JUnit4TestCaseWithRunnerWithCustomUniqueIds.class;
LauncherDiscoveryRequest request = request().selectors(selectClass(testClass)).build();
TestDescriptor engineDescriptor = discoverTests(request);
TestDescriptor runnerDescriptor = getOnlyElement(engineDescriptor.getChildren());
assertRunnerTestDescriptor(runnerDescriptor, testClass);
TestDescriptor childDescriptor = getOnlyElement(runnerDescriptor.getChildren());
UniqueId prefix = VintageUniqueIdBuilder.uniqueIdForClass(testClass);
assertThat(childDescriptor.getUniqueId().toString()).startsWith(prefix.toString());
String customUniqueIdValue = childDescriptor.getUniqueId().getSegments().get(2).getType();
assertNotNull(Base64.getDecoder().decode(customUniqueIdValue.getBytes(StandardCharsets.UTF_8)), "is a valid Base64 encoding scheme");
}
Aggregations