Search in sources :

Example 26 with LauncherDiscoveryRequest

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

the class TestInstancePostProcessorTests method testSpecificTestInstancePostProcessorIsCalled.

@Test
void testSpecificTestInstancePostProcessorIsCalled() {
    LauncherDiscoveryRequest request = request().selectors(selectClass(TestCaseWithTestSpecificTestInstancePostProcessor.class)).build();
    ExecutionEventRecorder eventRecorder = executeTests(request);
    assertEquals(1, eventRecorder.getTestStartedCount(), "# tests started");
    assertEquals(1, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
    assertThat(callSequence).containsExactly("fooPostProcessTestInstance:TestCaseWithTestSpecificTestInstancePostProcessor", "beforeEachMethod", "test");
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) Test(org.junit.jupiter.api.Test)

Example 27 with LauncherDiscoveryRequest

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

the class DiscoveryTests method discoverTestTemplateMethodByUniqueId.

@Test
void discoverTestTemplateMethodByUniqueId() {
    LauncherDiscoveryRequest spec = request().selectors(selectUniqueId(uniqueIdForTestTemplateMethod(TestTemplateClass.class, "testTemplate()"))).build();
    TestDescriptor engineDescriptor = discoverTests(spec);
    assertEquals(2, engineDescriptor.getDescendants().size(), "# resolved test descriptors");
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) TestDescriptor(org.junit.platform.engine.TestDescriptor) Test(org.junit.jupiter.api.Test)

Example 28 with LauncherDiscoveryRequest

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

the class DiscoveryTests method discoverTestClass.

@Test
void discoverTestClass() {
    LauncherDiscoveryRequest request = request().selectors(selectClass(LocalTestCase.class)).build();
    TestDescriptor engineDescriptor = discoverTests(request);
    assertEquals(7, engineDescriptor.getDescendants().size(), "# resolved test descriptors");
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) TestDescriptor(org.junit.platform.engine.TestDescriptor) Test(org.junit.jupiter.api.Test)

Example 29 with LauncherDiscoveryRequest

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

the class DiscoveryTests method discoverMethodByMethodReference.

@Test
void discoverMethodByMethodReference() throws NoSuchMethodException {
    Method testMethod = LocalTestCase.class.getDeclaredMethod("test3", new Class<?>[0]);
    LauncherDiscoveryRequest request = request().selectors(selectMethod(LocalTestCase.class, testMethod)).build();
    TestDescriptor engineDescriptor = discoverTests(request);
    assertEquals(2, engineDescriptor.getDescendants().size(), "# resolved test descriptors");
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) DiscoverySelectors.selectMethod(org.junit.platform.engine.discovery.DiscoverySelectors.selectMethod) JupiterUniqueIdBuilder.uniqueIdForTestTemplateMethod(org.junit.jupiter.engine.discovery.JupiterUniqueIdBuilder.uniqueIdForTestTemplateMethod) Method(java.lang.reflect.Method) TestDescriptor(org.junit.platform.engine.TestDescriptor) Test(org.junit.jupiter.api.Test)

Example 30 with LauncherDiscoveryRequest

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

the class DiscoveryTests method discoverMethodByUniqueIdForOverloadedMethod.

@Test
void discoverMethodByUniqueIdForOverloadedMethod() {
    LauncherDiscoveryRequest request = request().selectors(selectUniqueId(JupiterUniqueIdBuilder.uniqueIdForMethod(LocalTestCase.class, "test4()"))).build();
    TestDescriptor engineDescriptor = discoverTests(request);
    assertEquals(2, engineDescriptor.getDescendants().size(), "# resolved test descriptors");
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) TestDescriptor(org.junit.platform.engine.TestDescriptor) Test(org.junit.jupiter.api.Test)

Aggregations

LauncherDiscoveryRequest (org.junit.platform.launcher.LauncherDiscoveryRequest)167 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 Launcher (org.junit.platform.launcher.Launcher)16 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)10 PlainJUnit4TestCaseWithSingleTestWhichFails (org.junit.vintage.engine.samples.junit4.PlainJUnit4TestCaseWithSingleTestWhichFails)8 IOException (java.io.IOException)7 SummaryGeneratingListener (org.junit.platform.launcher.listeners.SummaryGeneratingListener)7 ArrayList (java.util.ArrayList)6 TestExecutionListener (org.junit.platform.launcher.TestExecutionListener)6 TestIdentifier (org.junit.platform.launcher.TestIdentifier)5 TestPlan (org.junit.platform.launcher.TestPlan)5 Path (java.nio.file.Path)4 DiscoverySelectors.selectUniqueId (org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId)4