Search in sources :

Example 81 with LauncherDiscoveryRequest

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

the class VintageTestEngineDiscoveryTests method resolvesJUnit3TestCase.

@Test
void resolvesJUnit3TestCase() throws Exception {
    Class<?> testClass = PlainJUnit3TestCaseWithSingleTestWhichFails.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, "test", VintageUniqueIdBuilder.uniqueIdForClass(testClass));
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) 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 82 with LauncherDiscoveryRequest

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

the class VintageTestEngineDiscoveryTests method resolvesCategoriesIntoTags.

@Test
void resolvesCategoriesIntoTags() {
    Class<?> testClass = PlainJUnit4TestCaseWithFiveTestMethods.class;
    LauncherDiscoveryRequest discoveryRequest = discoveryRequestForClass(testClass);
    TestDescriptor engineDescriptor = discoverTests(discoveryRequest);
    TestDescriptor runnerDescriptor = getOnlyElement(engineDescriptor.getChildren());
    assertThat(runnerDescriptor.getTags()).containsOnly(TestTag.create(Plain.class.getName()));
    TestDescriptor failingTest = findChildByDisplayName(runnerDescriptor, "failingTest");
    // 
    assertThat(failingTest.getTags()).containsOnly(// 
    TestTag.create(Plain.class.getName()), TestTag.create(Failing.class.getName()));
    TestDescriptor ignoredWithoutReason = findChildByDisplayName(runnerDescriptor, "ignoredTest1_withoutReason");
    // 
    assertThat(ignoredWithoutReason.getTags()).containsOnly(// 
    TestTag.create(Plain.class.getName()), TestTag.create(Skipped.class.getName()));
    TestDescriptor ignoredWithReason = findChildByDisplayName(runnerDescriptor, "ignoredTest2_withReason");
    // 
    assertThat(ignoredWithReason.getTags()).containsOnly(// 
    TestTag.create(Plain.class.getName()), // 
    TestTag.create(Skipped.class.getName()), TestTag.create(SkippedWithReason.class.getName()));
}
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 83 with LauncherDiscoveryRequest

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

the class VintageLauncherIntegrationTests method execute.

private Map<TestIdentifier, TestExecutionResult> execute(LauncherDiscoveryRequestBuilder requestBuilder) {
    Map<TestIdentifier, TestExecutionResult> results = new LinkedHashMap<>();
    LauncherDiscoveryRequest request = toRequest(requestBuilder);
    Launcher launcher = LauncherFactory.create();
    launcher.execute(request, new TestExecutionListener() {

        @Override
        public void executionFinished(TestIdentifier testIdentifier, TestExecutionResult testExecutionResult) {
            results.put(testIdentifier, testExecutionResult);
        }
    });
    return results;
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) TestExecutionListener(org.junit.platform.launcher.TestExecutionListener) Launcher(org.junit.platform.launcher.Launcher) TestIdentifier(org.junit.platform.launcher.TestIdentifier) TestExecutionResult(org.junit.platform.engine.TestExecutionResult) LinkedHashMap(java.util.LinkedHashMap)

Example 84 with LauncherDiscoveryRequest

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

the class VintageDiscovererTests method doesNotResolve.

private void doesNotResolve(LogRecordListener listener, Class<?> testClass) {
    LauncherDiscoveryRequest request = request().selectors(selectClass(testClass)).build();
    VintageDiscoverer discoverer = new VintageDiscoverer();
    TestDescriptor testDescriptor = discoverer.discover(request, engineId());
    assertThat(testDescriptor.getChildren()).isEmpty();
    assertThat(listener.stream(VintageDiscoverer.class)).isEmpty();
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) TestDescriptor(org.junit.platform.engine.TestDescriptor)

Example 85 with LauncherDiscoveryRequest

use of org.junit.platform.launcher.LauncherDiscoveryRequest in project tutorials by eugenp.

the class TestLauncher method main.

public static void main(String[] args) {
    // @formatter:off
    LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request().selectors(selectClass("com.baeldung.EmployeesTest")).configurationParameter("junit.conditions.deactivate", "com.baeldung.extensions.*").configurationParameter("junit.extensions.autodetection.enabled", "true").build();
    // @formatter:on
    TestPlan plan = LauncherFactory.create().discover(request);
    Launcher launcher = LauncherFactory.create();
    SummaryGeneratingListener summaryGeneratingListener = new SummaryGeneratingListener();
    launcher.execute(request, new TestExecutionListener[] { summaryGeneratingListener });
    launcher.execute(request);
    summaryGeneratingListener.getSummary().printTo(new PrintWriter(System.out));
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) TestPlan(org.junit.platform.launcher.TestPlan) SummaryGeneratingListener(org.junit.platform.launcher.listeners.SummaryGeneratingListener) Launcher(org.junit.platform.launcher.Launcher) PrintWriter(java.io.PrintWriter)

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