Search in sources :

Example 71 with TestDescriptor

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));
}
Also used : PlainJUnit4TestCaseWithTwoTestMethods(org.junit.vintage.engine.samples.junit4.PlainJUnit4TestCaseWithTwoTestMethods) LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ArrayList(java.util.ArrayList) TestDescriptor(org.junit.platform.engine.TestDescriptor) PlainOldJavaClassWithoutAnyTest(org.junit.vintage.engine.samples.PlainOldJavaClassWithoutAnyTest) Test(org.junit.jupiter.api.Test)

Example 72 with TestDescriptor

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));
}
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 73 with TestDescriptor

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));
}
Also used : 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 74 with TestDescriptor

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);
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ParameterizedTestCase(org.junit.vintage.engine.samples.junit4.ParameterizedTestCase) TestDescriptor(org.junit.platform.engine.TestDescriptor) PlainOldJavaClassWithoutAnyTest(org.junit.vintage.engine.samples.PlainOldJavaClassWithoutAnyTest) Test(org.junit.jupiter.api.Test)

Example 75 with TestDescriptor

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();
}
Also used : JUnit4TestCaseWithNotFilterableRunner(org.junit.vintage.engine.samples.junit4.JUnit4TestCaseWithNotFilterableRunner) 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)

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