Search in sources :

Example 91 with LauncherDiscoveryRequest

use of org.junit.platform.launcher.LauncherDiscoveryRequest in project junit5 by junit-team.

the class VintageTestEngineDiscoveryTests method doesNotResolveMethodOfClassNotAcceptedByClassNameFilter.

@Test
void doesNotResolveMethodOfClassNotAcceptedByClassNameFilter() throws Exception {
    Class<?> testClass = PlainJUnit4TestCaseWithFiveTestMethods.class;
    // @formatter:off
    LauncherDiscoveryRequest request = request().selectors(selectMethod(testClass, testClass.getMethod("failingTest"))).filters(includeClassNamePatterns("Foo")).build();
    // @formatter:on
    assertYieldsNoDescriptors(request);
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) PlainJUnit4TestCaseWithFiveTestMethods(org.junit.vintage.engine.samples.junit4.PlainJUnit4TestCaseWithFiveTestMethods) PlainOldJavaClassWithoutAnyTest(org.junit.vintage.engine.samples.PlainOldJavaClassWithoutAnyTest) Test(org.junit.jupiter.api.Test)

Example 92 with LauncherDiscoveryRequest

use of org.junit.platform.launcher.LauncherDiscoveryRequest 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 93 with LauncherDiscoveryRequest

use of org.junit.platform.launcher.LauncherDiscoveryRequest 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)

Example 94 with LauncherDiscoveryRequest

use of org.junit.platform.launcher.LauncherDiscoveryRequest 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 95 with LauncherDiscoveryRequest

use of org.junit.platform.launcher.LauncherDiscoveryRequest 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)

Aggregations

LauncherDiscoveryRequest (org.junit.platform.launcher.LauncherDiscoveryRequest)158 Test (org.junit.jupiter.api.Test)141 ExecutionEventRecorder (org.junit.platform.engine.test.event.ExecutionEventRecorder)74 TestDescriptor (org.junit.platform.engine.TestDescriptor)54 PlainOldJavaClassWithoutAnyTest (org.junit.vintage.engine.samples.PlainOldJavaClassWithoutAnyTest)33 DynamicTest (org.junit.jupiter.api.DynamicTest)12 DynamicTest.dynamicTest (org.junit.jupiter.api.DynamicTest.dynamicTest)11 DiscoverySelectors.selectMethod (org.junit.platform.engine.discovery.DiscoverySelectors.selectMethod)11 PlainJUnit4TestCaseWithFiveTestMethods (org.junit.vintage.engine.samples.junit4.PlainJUnit4TestCaseWithFiveTestMethods)11 Method (java.lang.reflect.Method)9 Launcher (org.junit.platform.launcher.Launcher)9 PlainJUnit4TestCaseWithSingleTestWhichFails (org.junit.vintage.engine.samples.junit4.PlainJUnit4TestCaseWithSingleTestWhichFails)8 IOException (java.io.IOException)7 ArrayList (java.util.ArrayList)6 SummaryGeneratingListener (org.junit.platform.launcher.listeners.SummaryGeneratingListener)5 Path (java.nio.file.Path)4 DiscoverySelectors.selectUniqueId (org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId)4 TestExecutionListener (org.junit.platform.launcher.TestExecutionListener)4 TestIdentifier (org.junit.platform.launcher.TestIdentifier)4 TestPlan (org.junit.platform.launcher.TestPlan)4