Search in sources :

Example 16 with TestDescriptor

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

the class VintageTestEngineDiscoveryTests method assertYieldsNoDescriptors.

private void assertYieldsNoDescriptors(LauncherDiscoveryRequest request) {
    TestDescriptor engineDescriptor = discoverTests(request);
    assertThat(engineDescriptor.getChildren()).isEmpty();
}
Also used : TestDescriptor(org.junit.platform.engine.TestDescriptor)

Example 17 with TestDescriptor

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

the class VintageTestEngineDiscoveryTests method resolvesJUnit3SuiteWithSingleTestCaseWithSingleTestWhichFails.

@Test
void resolvesJUnit3SuiteWithSingleTestCaseWithSingleTestWhichFails() throws Exception {
    Class<?> suiteClass = JUnit3SuiteWithSingleTestCaseWithSingleTestWhichFails.class;
    Class<?> testClass = PlainJUnit3TestCaseWithSingleTestWhichFails.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, "test", VintageUniqueIdBuilder.uniqueIdForClasses(suiteClass, testClass));
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) JUnit3SuiteWithSingleTestCaseWithSingleTestWhichFails(org.junit.vintage.engine.samples.junit3.JUnit3SuiteWithSingleTestCaseWithSingleTestWhichFails) 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 18 with TestDescriptor

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

the class VintageTestEngineDiscoveryTests method doesNotResolveMissingUniqueIdSelectorForSingleClass.

@Test
void doesNotResolveMissingUniqueIdSelectorForSingleClass() {
    Class<?> testClass = PlainJUnit4TestCaseWithFiveTestMethods.class;
    LauncherDiscoveryRequest discoveryRequest = request().selectors(selectUniqueId(VintageUniqueIdBuilder.uniqueIdForClass(testClass) + "/[test:doesNotExist]")).build();
    TestDescriptor engineDescriptor = discoverTests(discoveryRequest);
    TestDescriptor runnerDescriptor = getOnlyElement(engineDescriptor.getChildren());
    assertRunnerTestDescriptor(runnerDescriptor, testClass);
    TestDescriptor testDescriptor = getOnlyElement(runnerDescriptor.getChildren());
    assertInitializationError(testDescriptor, Filter.class, 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 19 with TestDescriptor

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

the class VintageTestEngineDiscoveryTests method resolvesEmptyIgnoredTestClass.

@Test
void resolvesEmptyIgnoredTestClass() {
    Class<?> testClass = EmptyIgnoredTestClass.class;
    LauncherDiscoveryRequest discoveryRequest = discoveryRequestForClass(testClass);
    TestDescriptor engineDescriptor = discoverTests(discoveryRequest);
    TestDescriptor runnerDescriptor = getOnlyElement(engineDescriptor.getChildren());
    assertFalse(runnerDescriptor.isContainer());
    assertTrue(runnerDescriptor.isTest());
    assertEquals(testClass.getName(), runnerDescriptor.getDisplayName());
    assertEquals(VintageUniqueIdBuilder.uniqueIdForClass(testClass), runnerDescriptor.getUniqueId());
    assertThat(runnerDescriptor.getChildren()).isEmpty();
}
Also used : EmptyIgnoredTestClass(org.junit.vintage.engine.samples.junit4.EmptyIgnoredTestClass) 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 20 with TestDescriptor

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

the class VintageTestEngineDiscoveryTests method resolvesJUnit4TestCaseWithOverloadedMethod.

@Test
void resolvesJUnit4TestCaseWithOverloadedMethod() {
    Class<?> testClass = JUnit4TestCaseWithOverloadedMethod.class;
    LauncherDiscoveryRequest discoveryRequest = discoveryRequestForClass(testClass);
    TestDescriptor engineDescriptor = discoverTests(discoveryRequest);
    TestDescriptor runnerDescriptor = getOnlyElement(engineDescriptor.getChildren());
    assertRunnerTestDescriptor(runnerDescriptor, testClass);
    List<TestDescriptor> testMethodDescriptors = new ArrayList<>(runnerDescriptor.getChildren());
    assertThat(testMethodDescriptors).hasSize(2);
    TestDescriptor testMethodDescriptor = testMethodDescriptors.get(0);
    assertEquals("theory", testMethodDescriptor.getDisplayName());
    assertEquals(VintageUniqueIdBuilder.uniqueIdForMethod(testClass, "theory", "0"), testMethodDescriptor.getUniqueId());
    assertClassSource(testClass, testMethodDescriptor);
    testMethodDescriptor = testMethodDescriptors.get(1);
    assertEquals("theory", testMethodDescriptor.getDisplayName());
    assertEquals(VintageUniqueIdBuilder.uniqueIdForMethod(testClass, "theory", "1"), testMethodDescriptor.getUniqueId());
    assertClassSource(testClass, testMethodDescriptor);
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) JUnit4TestCaseWithOverloadedMethod(org.junit.vintage.engine.samples.junit4.JUnit4TestCaseWithOverloadedMethod) ArrayList(java.util.ArrayList) 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)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