Search in sources :

Example 6 with EngineDiscoveryRequest

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

the class UniqueIdSelectorResolverTests method ignoresUniqueIdsOfOtherEngines.

@Test
void ignoresUniqueIdsOfOtherEngines(LogRecordListener listener) {
    UniqueId uniqueId = UniqueId.forEngine("someEngine");
    EngineDiscoveryRequest request = requestWithSelector(selectUniqueId(uniqueId));
    new UniqueIdSelectorResolver().resolve(request, allClassesPredicate, collector);
    assertNoRequests();
    assertThat(listener.stream(UniqueIdSelectorResolver.class)).isEmpty();
}
Also used : UniqueId(org.junit.platform.engine.UniqueId) DiscoverySelectors.selectUniqueId(org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId) EngineDiscoveryRequest(org.junit.platform.engine.EngineDiscoveryRequest) Test(org.junit.jupiter.api.Test)

Example 7 with EngineDiscoveryRequest

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

the class UniqueIdSelectorResolverTests method logsWarningOnUnloadableTestClass.

@Test
void logsWarningOnUnloadableTestClass(LogRecordListener listener) {
    UniqueId uniqueId = VintageUniqueIdBuilder.uniqueIdForClass("foo.bar.UnknownClass");
    EngineDiscoveryRequest request = requestWithSelector(selectUniqueId(uniqueId));
    new UniqueIdSelectorResolver().resolve(request, allClassesPredicate, collector);
    assertNoRequests();
    assertLoggedWarning(listener, "Unresolvable Unique ID (" + uniqueId + "): Unknown class foo.bar.UnknownClass");
}
Also used : UniqueId(org.junit.platform.engine.UniqueId) DiscoverySelectors.selectUniqueId(org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId) EngineDiscoveryRequest(org.junit.platform.engine.EngineDiscoveryRequest) Test(org.junit.jupiter.api.Test)

Example 8 with EngineDiscoveryRequest

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

the class VintageDiscovererTests method packageNameFilterExcludesClasses.

@Test
void packageNameFilterExcludesClasses() {
    // @formatter:off
    EngineDiscoveryRequest request = request().selectors(selectClass(Foo.class), selectClass(Bar.class)).filters(PackageNameFilter.excludePackageNames("org.junit.vintage.engine.discovery")).build();
    // @formatter:on
    VintageDiscoverer discoverer = new VintageDiscoverer();
    TestDescriptor testDescriptor = discoverer.discover(request, engineId());
    assertThat(testDescriptor.getChildren()).isEmpty();
}
Also used : EngineDiscoveryRequest(org.junit.platform.engine.EngineDiscoveryRequest) TestDescriptor(org.junit.platform.engine.TestDescriptor) Test(org.junit.jupiter.api.Test)

Example 9 with EngineDiscoveryRequest

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

the class UniqueIdSelectorResolverTests method logsWarningForEngineUniqueId.

@Test
void logsWarningForEngineUniqueId(LogRecordListener listener) {
    String uniqueId = engineId().toString();
    EngineDiscoveryRequest request = requestWithSelector(selectUniqueId(uniqueId));
    new UniqueIdSelectorResolver().resolve(request, allClassesPredicate, collector);
    assertNoRequests();
    assertLoggedWarning(listener, "Unresolvable Unique ID (" + engineId() + "): Cannot resolve the engine's unique ID");
}
Also used : EngineDiscoveryRequest(org.junit.platform.engine.EngineDiscoveryRequest) Test(org.junit.jupiter.api.Test)

Example 10 with EngineDiscoveryRequest

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

the class UniqueIdSelectorResolverTests method requestWithSelector.

private EngineDiscoveryRequest requestWithSelector(UniqueIdSelector selector) {
    EngineDiscoveryRequest request = mock(EngineDiscoveryRequest.class);
    when(request.getSelectorsByType(UniqueIdSelector.class)).thenReturn(Collections.singletonList(selector));
    return request;
}
Also used : EngineDiscoveryRequest(org.junit.platform.engine.EngineDiscoveryRequest)

Aggregations

EngineDiscoveryRequest (org.junit.platform.engine.EngineDiscoveryRequest)13 Test (org.junit.jupiter.api.Test)12 UniqueId (org.junit.platform.engine.UniqueId)7 DiscoverySelectors.selectUniqueId (org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId)7 DynamicTest (org.junit.jupiter.api.DynamicTest)4 TestDescriptor (org.junit.platform.engine.TestDescriptor)4 LogRecord (java.util.logging.LogRecord)2 TrackLogRecords (org.junit.jupiter.engine.TrackLogRecords)2 EngineExecutionListener (org.junit.platform.engine.EngineExecutionListener)2 ExecutionRequest (org.junit.platform.engine.ExecutionRequest)2 UniqueIdSelector (org.junit.platform.engine.discovery.UniqueIdSelector)2 DemoHierarchicalTestDescriptor (org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestDescriptor)2 TestDescriptorStub (org.junit.platform.engine.test.TestDescriptorStub)2 TestEngineSpy (org.junit.platform.engine.test.TestEngineSpy)2 TestExecutionListener (org.junit.platform.launcher.TestExecutionListener)2 Method (java.lang.reflect.Method)1 Optional (java.util.Optional)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)1