Search in sources :

Example 21 with TestDescriptor

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

the class VintageTestEngineDiscoveryTests method resolvesUniqueIdSelectorOfSingleClassWithinSuite.

@Test
void resolvesUniqueIdSelectorOfSingleClassWithinSuite() throws Exception {
    Class<?> suiteClass = JUnit4SuiteWithTwoTestCases.class;
    Class<?> testClass = PlainJUnit4TestCaseWithSingleTestWhichFails.class;
    LauncherDiscoveryRequest discoveryRequest = request().selectors(selectUniqueId(VintageUniqueIdBuilder.uniqueIdForClasses(suiteClass, testClass))).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, "failingTest", VintageUniqueIdBuilder.uniqueIdForClasses(suiteClass, testClass));
}
Also used : PlainJUnit4TestCaseWithSingleTestWhichFails(org.junit.vintage.engine.samples.junit4.PlainJUnit4TestCaseWithSingleTestWhichFails) 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 22 with TestDescriptor

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

the class VintageTestEngineDiscoveryTests method resolvesClassesWithInheritedMethods.

@Test
void resolvesClassesWithInheritedMethods() throws Exception {
    Class<?> superclass = PlainJUnit4TestCaseWithSingleTestWhichFails.class;
    Class<?> testClass = PlainJUnit4TestCaseWithSingleInheritedTestWhichFails.class;
    LauncherDiscoveryRequest discoveryRequest = discoveryRequestForClass(testClass);
    TestDescriptor engineDescriptor = discoverTests(discoveryRequest);
    TestDescriptor runnerDescriptor = getOnlyElement(engineDescriptor.getChildren());
    assertEquals(testClass.getName(), runnerDescriptor.getDisplayName());
    assertClassSource(testClass, runnerDescriptor);
    TestDescriptor testDescriptor = getOnlyElement(runnerDescriptor.getChildren());
    assertEquals("failingTest", testDescriptor.getDisplayName());
    assertMethodSource(superclass.getMethod("failingTest"), testDescriptor);
}
Also used : PlainJUnit4TestCaseWithSingleTestWhichFails(org.junit.vintage.engine.samples.junit4.PlainJUnit4TestCaseWithSingleTestWhichFails) PlainJUnit4TestCaseWithSingleInheritedTestWhichFails(org.junit.vintage.engine.samples.junit4.PlainJUnit4TestCaseWithSingleInheritedTestWhichFails) 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 23 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 24 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 25 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)

Aggregations

TestDescriptor (org.junit.platform.engine.TestDescriptor)143 Test (org.junit.jupiter.api.Test)103 LauncherDiscoveryRequest (org.junit.platform.launcher.LauncherDiscoveryRequest)58 UniqueId (org.junit.platform.engine.UniqueId)33 PlainOldJavaClassWithoutAnyTest (org.junit.vintage.engine.samples.PlainOldJavaClassWithoutAnyTest)31 ClassTestDescriptor (org.junit.jupiter.engine.descriptor.ClassTestDescriptor)19 TestMethodTestDescriptor (org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor)17 DiscoverySelectors.selectUniqueId (org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId)14 TestTemplateInvocationTestDescriptor (org.junit.jupiter.engine.descriptor.TestTemplateInvocationTestDescriptor)12 ArrayList (java.util.ArrayList)11 List (java.util.List)11 Set (java.util.Set)11 DynamicTest (org.junit.jupiter.api.DynamicTest)11 NestedClassTestDescriptor (org.junit.jupiter.engine.descriptor.NestedClassTestDescriptor)11 AbstractTestDescriptor (org.junit.platform.engine.support.descriptor.AbstractTestDescriptor)11 Optional (java.util.Optional)10 ExecutionRequest (org.junit.platform.engine.ExecutionRequest)10 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)9 EngineDiscoveryRequest (org.junit.platform.engine.EngineDiscoveryRequest)9 DemoHierarchicalTestEngine (org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine)9