Search in sources :

Example 46 with TestDescriptor

use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.

the class VintageTestEngineDiscoveryTests method resolvesUniqueIdSelectorForSingleClass.

@Test
void resolvesUniqueIdSelectorForSingleClass() {
    Class<?> testClass = PlainJUnit4TestCaseWithFiveTestMethods.class;
    LauncherDiscoveryRequest discoveryRequest = request().selectors(selectUniqueId(VintageUniqueIdBuilder.uniqueIdForClass(testClass))).build();
    TestDescriptor engineDescriptor = discoverTests(discoveryRequest);
    TestDescriptor runnerDescriptor = getOnlyElement(engineDescriptor.getChildren());
    assertRunnerTestDescriptor(runnerDescriptor, testClass);
    assertThat(runnerDescriptor.getChildren()).hasSize(5);
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) TestDescriptor(org.junit.platform.engine.TestDescriptor) PlainJUnit4TestCaseWithFiveTestMethods(org.junit.vintage.engine.samples.junit4.PlainJUnit4TestCaseWithFiveTestMethods) PlainOldJavaClassWithoutAnyTest(org.junit.vintage.engine.samples.PlainOldJavaClassWithoutAnyTest) Test(org.junit.jupiter.api.Test)

Example 47 with TestDescriptor

use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.

the class VintageTestEngineDiscoveryTests method ignoresRedundantSelector.

@Test
void ignoresRedundantSelector() throws Exception {
    Class<?> testClass = PlainJUnit4TestCaseWithFiveTestMethods.class;
    LauncherDiscoveryRequest discoveryRequest = // 
    request().selectors(// 
    selectMethod(testClass, testClass.getMethod("failingTest")), selectUniqueId(// 
    VintageUniqueIdBuilder.uniqueIdForMethod(testClass, "failingTest"))).build();
    TestDescriptor engineDescriptor = discoverTests(discoveryRequest);
    TestDescriptor runnerDescriptor = getOnlyElement(engineDescriptor.getChildren());
    assertRunnerTestDescriptor(runnerDescriptor, testClass);
    TestDescriptor testMethodDescriptor = getOnlyElement(runnerDescriptor.getChildren());
    assertTestMethodDescriptor(testMethodDescriptor, testClass, "failingTest", VintageUniqueIdBuilder.uniqueIdForClass(testClass));
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) TestDescriptor(org.junit.platform.engine.TestDescriptor) PlainJUnit4TestCaseWithFiveTestMethods(org.junit.vintage.engine.samples.junit4.PlainJUnit4TestCaseWithFiveTestMethods) PlainOldJavaClassWithoutAnyTest(org.junit.vintage.engine.samples.PlainOldJavaClassWithoutAnyTest) Test(org.junit.jupiter.api.Test)

Example 48 with TestDescriptor

use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.

the class VintageTestEngineDiscoveryTests method resolvesUniqueIdSelectorOfSingleMethodWithinSuite.

@Test
void resolvesUniqueIdSelectorOfSingleMethodWithinSuite() throws Exception {
    Class<?> suiteClass = JUnit4SuiteWithTwoTestCases.class;
    Class<?> testClass = PlainJUnit4TestCaseWithTwoTestMethods.class;
    LauncherDiscoveryRequest discoveryRequest = request().selectors(selectUniqueId(VintageUniqueIdBuilder.uniqueIdForMethod(VintageUniqueIdBuilder.uniqueIdForClasses(suiteClass, testClass), testClass, "successfulTest"))).build();
    TestDescriptor engineDescriptor = discoverTests(discoveryRequest);
    TestDescriptor suiteDescriptor = getOnlyElement(engineDescriptor.getChildren());
    assertRunnerTestDescriptor(suiteDescriptor, suiteClass);
    TestDescriptor testClassDescriptor = getOnlyElement(suiteDescriptor.getChildren());
    assertContainerTestDescriptor(testClassDescriptor, suiteClass, testClass);
    TestDescriptor testMethodDescriptor = getOnlyElement(testClassDescriptor.getChildren());
    assertTestMethodDescriptor(testMethodDescriptor, testClass, "successfulTest", VintageUniqueIdBuilder.uniqueIdForClasses(suiteClass, testClass));
}
Also used : PlainJUnit4TestCaseWithTwoTestMethods(org.junit.vintage.engine.samples.junit4.PlainJUnit4TestCaseWithTwoTestMethods) LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) TestDescriptor(org.junit.platform.engine.TestDescriptor) JUnit4SuiteWithTwoTestCases(org.junit.vintage.engine.samples.junit4.JUnit4SuiteWithTwoTestCases) PlainOldJavaClassWithoutAnyTest(org.junit.vintage.engine.samples.PlainOldJavaClassWithoutAnyTest) Test(org.junit.jupiter.api.Test)

Example 49 with TestDescriptor

use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.

the class VintageTestEngineDiscoveryTests method resolvesPackageSelectorForJUnit3SamplesPackage.

@Test
void resolvesPackageSelectorForJUnit3SamplesPackage() {
    Class<?> testClass = PlainJUnit3TestCaseWithSingleTestWhichFails.class;
    LauncherDiscoveryRequest discoveryRequest = request().selectors(selectPackage(testClass.getPackage().getName())).build();
    TestDescriptor engineDescriptor = discoverTests(discoveryRequest);
    // @formatter:off
    assertThat(engineDescriptor.getChildren()).extracting(TestDescriptor::getDisplayName).contains(testClass.getName()).doesNotContain(PlainJUnit4TestCaseWithSingleTestWhichFails.class.getName());
// @formatter:on
}
Also used : PlainJUnit4TestCaseWithSingleTestWhichFails(org.junit.vintage.engine.samples.junit4.PlainJUnit4TestCaseWithSingleTestWhichFails) LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) PlainJUnit3TestCaseWithSingleTestWhichFails(org.junit.vintage.engine.samples.junit3.PlainJUnit3TestCaseWithSingleTestWhichFails) TestDescriptor(org.junit.platform.engine.TestDescriptor) PlainOldJavaClassWithoutAnyTest(org.junit.vintage.engine.samples.PlainOldJavaClassWithoutAnyTest) Test(org.junit.jupiter.api.Test)

Example 50 with TestDescriptor

use of org.junit.platform.engine.TestDescriptor in project junit5 by junit-team.

the class VintageTestEngineDiscoveryTests method resolvesCombinationOfMethodAndUniqueIdSelector.

@Test
void resolvesCombinationOfMethodAndUniqueIdSelector() throws Exception {
    Class<?> testClass = PlainJUnit4TestCaseWithFiveTestMethods.class;
    LauncherDiscoveryRequest discoveryRequest = // 
    request().selectors(// 
    selectMethod(testClass, testClass.getMethod("failingTest")), selectUniqueId(// 
    VintageUniqueIdBuilder.uniqueIdForMethod(testClass, "abortedTest"))).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, "abortedTest", VintageUniqueIdBuilder.uniqueIdForClass(testClass));
    assertTestMethodDescriptor(testMethodDescriptors.get(1), testClass, "failingTest", VintageUniqueIdBuilder.uniqueIdForClass(testClass));
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ArrayList(java.util.ArrayList) TestDescriptor(org.junit.platform.engine.TestDescriptor) PlainJUnit4TestCaseWithFiveTestMethods(org.junit.vintage.engine.samples.junit4.PlainJUnit4TestCaseWithFiveTestMethods) PlainOldJavaClassWithoutAnyTest(org.junit.vintage.engine.samples.PlainOldJavaClassWithoutAnyTest) Test(org.junit.jupiter.api.Test)

Aggregations

TestDescriptor (org.junit.platform.engine.TestDescriptor)120 Test (org.junit.jupiter.api.Test)96 LauncherDiscoveryRequest (org.junit.platform.launcher.LauncherDiscoveryRequest)54 PlainOldJavaClassWithoutAnyTest (org.junit.vintage.engine.samples.PlainOldJavaClassWithoutAnyTest)31 UniqueId (org.junit.platform.engine.UniqueId)22 TestPlan (org.junit.platform.launcher.TestPlan)14 EngineDiscoveryRequest (org.junit.platform.engine.EngineDiscoveryRequest)12 ExecutionRequest (org.junit.platform.engine.ExecutionRequest)10 Optional (java.util.Optional)9 DemoHierarchicalTestDescriptor (org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestDescriptor)9 TestIdentifier (org.junit.platform.launcher.TestIdentifier)9 PlainJUnit4TestCaseWithFiveTestMethods (org.junit.vintage.engine.samples.junit4.PlainJUnit4TestCaseWithFiveTestMethods)9 ArrayList (java.util.ArrayList)8 Set (java.util.Set)8 ClassTestDescriptor (org.junit.jupiter.engine.descriptor.ClassTestDescriptor)8 DiscoverySelectors.selectUniqueId (org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId)8 ExecutionEventRecorder (org.junit.platform.engine.test.event.ExecutionEventRecorder)8 PlainJUnit4TestCaseWithSingleTestWhichFails (org.junit.vintage.engine.samples.junit4.PlainJUnit4TestCaseWithSingleTestWhichFails)8 List (java.util.List)7 DynamicTest (org.junit.jupiter.api.DynamicTest)7