Search in sources :

Example 6 with UniqueIdSelector

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

the class TestClassWithTemplate method staticNestedClassResolutionByUniqueId.

@Test
void staticNestedClassResolutionByUniqueId() {
    UniqueIdSelector selector = selectUniqueId(uniqueIdForClass(OtherTestClass.NestedTestClass.class).toString());
    resolver.resolveSelectors(request().selectors(selector).build(), engineDescriptor);
    assertEquals(3, engineDescriptor.getDescendants().size());
    List<UniqueId> uniqueIds = uniqueIds();
    assertThat(uniqueIds).contains(uniqueIdForClass(OtherTestClass.NestedTestClass.class));
    assertThat(uniqueIds).contains(uniqueIdForMethod(OtherTestClass.NestedTestClass.class, "test5()"));
    assertThat(uniqueIds).contains(uniqueIdForMethod(OtherTestClass.NestedTestClass.class, "test6()"));
}
Also used : UniqueIdSelector(org.junit.platform.engine.discovery.UniqueIdSelector) DiscoverySelectors.selectUniqueId(org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId) UniqueId(org.junit.platform.engine.UniqueId) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Example 7 with UniqueIdSelector

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

the class TestClassWithTemplate method resolvingUniqueIdOfNonTestMethodResolvesNothing.

@Test
void resolvingUniqueIdOfNonTestMethodResolvesNothing() {
    UniqueIdSelector selector = selectUniqueId(uniqueIdForMethod(MyTestClass.class, "notATest()"));
    EngineDiscoveryRequest request = request().selectors(selector).build();
    resolver.resolveSelectors(request, engineDescriptor);
    assertTrue(engineDescriptor.getDescendants().isEmpty());
}
Also used : UniqueIdSelector(org.junit.platform.engine.discovery.UniqueIdSelector) EngineDiscoveryRequest(org.junit.platform.engine.EngineDiscoveryRequest) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Example 8 with UniqueIdSelector

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

the class TestClassWithTemplate method methodResolutionByUniqueIdWithMissingParameters.

@Test
void methodResolutionByUniqueIdWithMissingParameters() {
    UniqueIdSelector selector = selectUniqueId(uniqueIdForMethod(getClass(), "methodName"));
    assertMethodDoesNotMatchPattern(selector);
}
Also used : UniqueIdSelector(org.junit.platform.engine.discovery.UniqueIdSelector) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Example 9 with UniqueIdSelector

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

the class TestClassWithTemplate method nestedTestResolutionFromUniqueId.

@Test
void nestedTestResolutionFromUniqueId() {
    UniqueIdSelector selector = selectUniqueId(uniqueIdForClass(TestCaseWithNesting.NestedTestCase.DoubleNestedTestCase.class).toString());
    resolver.resolveSelectors(request().selectors(selector).build(), engineDescriptor);
    List<UniqueId> uniqueIds = uniqueIds();
    assertEquals(4, uniqueIds.size());
    assertThat(uniqueIds).contains(uniqueIdForClass(TestCaseWithNesting.class));
    assertThat(uniqueIds).contains(uniqueIdForClass(TestCaseWithNesting.NestedTestCase.class));
    assertThat(uniqueIds).contains(uniqueIdForClass(TestCaseWithNesting.NestedTestCase.DoubleNestedTestCase.class));
    assertThat(uniqueIds).contains(uniqueIdForMethod(TestCaseWithNesting.NestedTestCase.DoubleNestedTestCase.class, "testC()"));
}
Also used : UniqueIdSelector(org.junit.platform.engine.discovery.UniqueIdSelector) DiscoverySelectors.selectUniqueId(org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId) UniqueId(org.junit.platform.engine.UniqueId) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Example 10 with UniqueIdSelector

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

the class TestClassWithTemplate method methodResolutionByUniqueIdWithParams.

@Test
@TrackLogRecords
void methodResolutionByUniqueIdWithParams(LogRecordListener listener) {
    UniqueIdSelector selector = selectUniqueId(uniqueIdForMethod(HerTestClass.class, "test7(java.lang.String)").toString());
    resolver.resolveSelectors(request().selectors(selector).build(), engineDescriptor);
    assertEquals(2, engineDescriptor.getDescendants().size());
    List<UniqueId> uniqueIds = uniqueIds();
    assertThat(uniqueIds).contains(uniqueIdForClass(HerTestClass.class));
    assertThat(uniqueIds).contains(uniqueIdForMethod(HerTestClass.class, "test7(java.lang.String)"));
    assertThat(listener.stream(JavaElementsResolver.class)).isEmpty();
}
Also used : UniqueIdSelector(org.junit.platform.engine.discovery.UniqueIdSelector) DiscoverySelectors.selectUniqueId(org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId) UniqueId(org.junit.platform.engine.UniqueId) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest) TrackLogRecords(org.junit.jupiter.engine.TrackLogRecords)

Aggregations

DynamicTest (org.junit.jupiter.api.DynamicTest)14 Test (org.junit.jupiter.api.Test)14 UniqueIdSelector (org.junit.platform.engine.discovery.UniqueIdSelector)14 UniqueId (org.junit.platform.engine.UniqueId)10 DiscoverySelectors.selectUniqueId (org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId)10 TrackLogRecords (org.junit.jupiter.engine.TrackLogRecords)2 EngineDiscoveryRequest (org.junit.platform.engine.EngineDiscoveryRequest)2 LogRecord (java.util.logging.LogRecord)1 JupiterTestDescriptor (org.junit.jupiter.engine.descriptor.JupiterTestDescriptor)1 TestTemplateInvocationTestDescriptor (org.junit.jupiter.engine.descriptor.TestTemplateInvocationTestDescriptor)1 JUnitException (org.junit.platform.commons.JUnitException)1 PreconditionViolationException (org.junit.platform.commons.util.PreconditionViolationException)1 TestDescriptor (org.junit.platform.engine.TestDescriptor)1