use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.
the class VintageTestEngineDiscoveryTests method resolvesMultipleUniqueIdSelectorsForMethodsOfSameClass.
@Test
void resolvesMultipleUniqueIdSelectorsForMethodsOfSameClass() throws Exception {
Class<?> testClass = PlainJUnit4TestCaseWithTwoTestMethods.class;
LauncherDiscoveryRequest discoveryRequest = request().selectors(selectUniqueId(VintageUniqueIdBuilder.uniqueIdForMethod(testClass, "successfulTest")), selectUniqueId(VintageUniqueIdBuilder.uniqueIdForMethod(testClass, "failingTest"))).build();
TestDescriptor engineDescriptor = discoverTests(discoveryRequest);
TestDescriptor runnerDescriptor = getOnlyElement(engineDescriptor.getChildren());
assertRunnerTestDescriptor(runnerDescriptor, testClass);
List<TestDescriptor> testMethodDescriptors = new ArrayList<>(runnerDescriptor.getChildren());
assertThat(testMethodDescriptors).hasSize(2);
assertTestMethodDescriptor(testMethodDescriptors.get(0), testClass, "failingTest", VintageUniqueIdBuilder.uniqueIdForClass(testClass));
assertTestMethodDescriptor(testMethodDescriptors.get(1), testClass, "successfulTest", VintageUniqueIdBuilder.uniqueIdForClass(testClass));
}
use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.
the class VintageTestEngineDiscoveryTests method resolvesUniqueIdSelectorForSingleMethod.
@Test
void resolvesUniqueIdSelectorForSingleMethod() throws Exception {
Class<?> testClass = PlainJUnit4TestCaseWithFiveTestMethods.class;
LauncherDiscoveryRequest discoveryRequest = request().selectors(selectUniqueId(VintageUniqueIdBuilder.uniqueIdForMethod(testClass, "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 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.engine.TestDescriptor 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.engine.TestDescriptor 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();
}
Aggregations