Search in sources :

Example 66 with TestDescriptor

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

the class VintageTestEngineDiscoveryTests method resolvesJUnit4SuiteWithPlainJUnit4TestCaseWithSingleTestWhichIsIgnored.

@Test
void resolvesJUnit4SuiteWithPlainJUnit4TestCaseWithSingleTestWhichIsIgnored() throws Exception {
    Class<?> suiteClass = JUnit4SuiteWithPlainJUnit4TestCaseWithSingleTestWhichIsIgnored.class;
    Class<?> testClass = PlainJUnit4TestCaseWithSingleTestWhichIsIgnored.class;
    LauncherDiscoveryRequest discoveryRequest = discoveryRequestForClass(suiteClass);
    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, "ignoredTest", VintageUniqueIdBuilder.uniqueIdForClasses(suiteClass, testClass));
}
Also used : PlainJUnit4TestCaseWithSingleTestWhichIsIgnored(org.junit.vintage.engine.samples.junit4.PlainJUnit4TestCaseWithSingleTestWhichIsIgnored) JUnit4SuiteWithPlainJUnit4TestCaseWithSingleTestWhichIsIgnored(org.junit.vintage.engine.samples.junit4.JUnit4SuiteWithPlainJUnit4TestCaseWithSingleTestWhichIsIgnored) LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) JUnit4SuiteWithPlainJUnit4TestCaseWithSingleTestWhichIsIgnored(org.junit.vintage.engine.samples.junit4.JUnit4SuiteWithPlainJUnit4TestCaseWithSingleTestWhichIsIgnored) TestDescriptor(org.junit.platform.engine.TestDescriptor) PlainOldJavaClassWithoutAnyTest(org.junit.vintage.engine.samples.PlainOldJavaClassWithoutAnyTest) Test(org.junit.jupiter.api.Test)

Example 67 with TestDescriptor

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

the class VintageTestEngineDiscoveryTests method resolvesApplyingPackageNameFilters.

@Test
void resolvesApplyingPackageNameFilters() throws Exception {
    Path root = getClasspathRoot(PlainJUnit4TestCaseWithSingleTestWhichFails.class);
    LauncherDiscoveryRequest discoveryRequest = request().selectors(selectClasspathRoots(singleton(root))).filters(includePackageNames("org"), includePackageNames("org.junit")).build();
    TestDescriptor engineDescriptor = discoverTests(discoveryRequest);
    // @formatter:off
    assertThat(engineDescriptor.getChildren()).extracting(TestDescriptor::getDisplayName).contains(PlainJUnit4TestCaseWithSingleTestWhichFails.class.getName());
// @formatter:on
}
Also used : Path(java.nio.file.Path) PlainJUnit4TestCaseWithSingleTestWhichFails(org.junit.vintage.engine.samples.junit4.PlainJUnit4TestCaseWithSingleTestWhichFails) LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) TestDescriptor(org.junit.platform.engine.TestDescriptor) PlainOldJavaClassWithoutAnyTest(org.junit.vintage.engine.samples.PlainOldJavaClassWithoutAnyTest) Test(org.junit.jupiter.api.Test)

Example 68 with TestDescriptor

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

the class VintageTestEngineDiscoveryTests method resolvesClasspathSelector.

@Test
void resolvesClasspathSelector() throws Exception {
    Path root = getClasspathRoot(PlainJUnit4TestCaseWithSingleTestWhichFails.class);
    LauncherDiscoveryRequest discoveryRequest = request().selectors(selectClasspathRoots(singleton(root))).build();
    TestDescriptor engineDescriptor = discoverTests(discoveryRequest);
    // @formatter:off
    assertThat(engineDescriptor.getChildren()).extracting(TestDescriptor::getDisplayName).contains(PlainJUnit4TestCaseWithSingleTestWhichFails.class.getName()).contains(PlainJUnit3TestCaseWithSingleTestWhichFails.class.getName()).doesNotContain(PlainOldJavaClassWithoutAnyTest.class.getName());
// @formatter:on
}
Also used : Path(java.nio.file.Path) PlainJUnit4TestCaseWithSingleTestWhichFails(org.junit.vintage.engine.samples.junit4.PlainJUnit4TestCaseWithSingleTestWhichFails) LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) PlainOldJavaClassWithoutAnyTest(org.junit.vintage.engine.samples.PlainOldJavaClassWithoutAnyTest) TestDescriptor(org.junit.platform.engine.TestDescriptor) PlainOldJavaClassWithoutAnyTest(org.junit.vintage.engine.samples.PlainOldJavaClassWithoutAnyTest) Test(org.junit.jupiter.api.Test)

Example 69 with TestDescriptor

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

the class VintageTestEngineDiscoveryTests method resolvesMethodOfIgnoredJUnit4TestClass.

@Test
void resolvesMethodOfIgnoredJUnit4TestClass() throws Exception {
    Class<?> testClass = IgnoredJUnit4TestCase.class;
    LauncherDiscoveryRequest discoveryRequest = request().selectors(selectMethod(testClass, testClass.getMethod("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));
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) IgnoredJUnit4TestCase(org.junit.vintage.engine.samples.junit4.IgnoredJUnit4TestCase) TestDescriptor(org.junit.platform.engine.TestDescriptor) PlainOldJavaClassWithoutAnyTest(org.junit.vintage.engine.samples.PlainOldJavaClassWithoutAnyTest) Test(org.junit.jupiter.api.Test)

Example 70 with TestDescriptor

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

the class VintageTestEngineDiscoveryTests method ignoresMoreFineGrainedSelectorsWhenClassIsSelectedAsWell.

@Test
void ignoresMoreFineGrainedSelectorsWhenClassIsSelectedAsWell() throws Exception {
    Class<?> testClass = PlainJUnit4TestCaseWithFiveTestMethods.class;
    LauncherDiscoveryRequest discoveryRequest = // 
    request().selectors(// 
    selectMethod(testClass, testClass.getMethod("failingTest")), // 
    selectUniqueId(VintageUniqueIdBuilder.uniqueIdForMethod(testClass, "abortedTest")), // 
    selectClass(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)

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