Search in sources :

Example 91 with TestDescriptor

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

the class TestTemplateInvocationTests method parentChildRelationshipIsEstablished.

@Test
void parentChildRelationshipIsEstablished() {
    LauncherDiscoveryRequest request = request().selectors(selectMethod(MyTestTemplateTestCase.class, "templateWithSingleRegisteredExtension")).build();
    ExecutionEventRecorder eventRecorder = executeTests(request);
    TestDescriptor templateMethodDescriptor = findTestDescriptor(eventRecorder, container("templateWithSingleRegisteredExtension"));
    TestDescriptor invocationDescriptor = findTestDescriptor(eventRecorder, test("test-template-invocation:#1"));
    assertThat(invocationDescriptor.getParent()).hasValue(templateMethodDescriptor);
    assertThat(templateMethodDescriptor.getChildren()).isEqualTo(singleton(invocationDescriptor));
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) TestDescriptor(org.junit.platform.engine.TestDescriptor) TestTemplateInvocationTestDescriptor(org.junit.jupiter.engine.descriptor.TestTemplateInvocationTestDescriptor) Test(org.junit.jupiter.api.Test)

Example 92 with TestDescriptor

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

the class NestedTestClassesTests method doublyNestedTestsAreCorrectlyDiscovered.

@Test
void doublyNestedTestsAreCorrectlyDiscovered() {
    LauncherDiscoveryRequest request = request().selectors(selectClass(TestCaseWithDoubleNesting.class)).build();
    TestDescriptor engineDescriptor = discoverTests(request);
    assertEquals(8, 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 93 with TestDescriptor

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

the class AbstractJupiterTestEngineTests method executeTests.

protected ExecutionEventRecorder executeTests(LauncherDiscoveryRequest request) {
    TestDescriptor testDescriptor = discoverTests(request);
    ExecutionEventRecorder eventRecorder = new ExecutionEventRecorder();
    engine.execute(new ExecutionRequest(testDescriptor, eventRecorder, request.getConfigurationParameters()));
    return eventRecorder;
}
Also used : ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) ExecutionRequest(org.junit.platform.engine.ExecutionRequest) TestDescriptor(org.junit.platform.engine.TestDescriptor)

Example 94 with TestDescriptor

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

the class TestClassWithTemplate method twoMethodResolutionsByUniqueId.

@Test
void twoMethodResolutionsByUniqueId() {
    UniqueIdSelector selector1 = selectUniqueId(uniqueIdForMethod(MyTestClass.class, "test1()").toString());
    UniqueIdSelector selector2 = selectUniqueId(uniqueIdForMethod(MyTestClass.class, "test2()").toString());
    // adding same selector twice should have no effect
    resolver.resolveSelectors(request().selectors(selector1, selector2, selector2).build(), engineDescriptor);
    assertEquals(3, engineDescriptor.getDescendants().size());
    List<UniqueId> uniqueIds = uniqueIds();
    assertThat(uniqueIds).contains(uniqueIdForClass(MyTestClass.class));
    assertThat(uniqueIds).contains(uniqueIdForMethod(MyTestClass.class, "test1()"));
    assertThat(uniqueIds).contains(uniqueIdForMethod(MyTestClass.class, "test2()"));
    TestDescriptor classFromMethod1 = descriptorByUniqueId(uniqueIdForMethod(MyTestClass.class, "test1()")).getParent().get();
    TestDescriptor classFromMethod2 = descriptorByUniqueId(uniqueIdForMethod(MyTestClass.class, "test2()")).getParent().get();
    assertEquals(classFromMethod1, classFromMethod2);
    assertSame(classFromMethod1, classFromMethod2);
}
Also used : UniqueIdSelector(org.junit.platform.engine.discovery.UniqueIdSelector) DiscoverySelectors.selectUniqueId(org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId) UniqueId(org.junit.platform.engine.UniqueId) TestDescriptor(org.junit.platform.engine.TestDescriptor) TestTemplateInvocationTestDescriptor(org.junit.jupiter.engine.descriptor.TestTemplateInvocationTestDescriptor) JupiterTestDescriptor(org.junit.jupiter.engine.descriptor.JupiterTestDescriptor) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Example 95 with TestDescriptor

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

the class DiscoveryTests method discoverMethodByUniqueIdForOverloadedMethodVariantThatAcceptsArguments.

@Test
void discoverMethodByUniqueIdForOverloadedMethodVariantThatAcceptsArguments() {
    LauncherDiscoveryRequest request = request().selectors(selectUniqueId(JupiterUniqueIdBuilder.uniqueIdForMethod(LocalTestCase.class, "test4(" + TestInfo.class.getName() + ")"))).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

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