Search in sources :

Example 1 with FilterResult

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

the class TestMethodFilterTests method includesTestDescriptorWithClassSource.

@Test
void includesTestDescriptorWithClassSource() throws Exception {
    FilterResult result = filter.apply(newClassTestDescriptor());
    assertTrue(result.included());
    assertFalse(result.excluded());
}
Also used : FilterResult(org.junit.platform.engine.FilterResult) Test(org.junit.jupiter.api.Test)

Example 2 with FilterResult

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

the class DefaultLauncher method discoverRoot.

private Root discoverRoot(LauncherDiscoveryRequest discoveryRequest, String phase) {
    Root root = new Root();
    for (TestEngine testEngine : this.testEngines) {
        // @formatter:off
        boolean engineIsExcluded = discoveryRequest.getEngineFilters().stream().map(engineFilter -> engineFilter.apply(testEngine)).anyMatch(FilterResult::excluded);
        if (engineIsExcluded) {
            logger.debug(() -> String.format("Test discovery for engine '%s' was skipped due to an EngineFilter in phase '%s'.", testEngine.getId(), phase));
            continue;
        }
        logger.debug(() -> String.format("Discovering tests during Launcher %s phase in engine '%s'.", phase, testEngine.getId()));
        Optional<TestDescriptor> engineRoot = discoverEngineRoot(testEngine, discoveryRequest);
        engineRoot.ifPresent(rootDescriptor -> root.add(testEngine, rootDescriptor));
    }
    root.applyPostDiscoveryFilters(discoveryRequest);
    root.prune();
    return root;
}
Also used : Preconditions(org.junit.platform.commons.util.Preconditions) Launcher(org.junit.platform.launcher.Launcher) ConfigurationParameters(org.junit.platform.engine.ConfigurationParameters) TestPlan(org.junit.platform.launcher.TestPlan) Logger(org.junit.platform.commons.logging.Logger) JUnitException(org.junit.platform.commons.JUnitException) LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) FilterResult(org.junit.platform.engine.FilterResult) TestEngine(org.junit.platform.engine.TestEngine) Set(java.util.Set) BlacklistedExceptions(org.junit.platform.commons.util.BlacklistedExceptions) UniqueId(org.junit.platform.engine.UniqueId) LoggerFactory(org.junit.platform.commons.logging.LoggerFactory) HashSet(java.util.HashSet) Optional(java.util.Optional) ExecutionRequest(org.junit.platform.engine.ExecutionRequest) TestDescriptor(org.junit.platform.engine.TestDescriptor) TestExecutionListener(org.junit.platform.launcher.TestExecutionListener) TestEngine(org.junit.platform.engine.TestEngine) FilterResult(org.junit.platform.engine.FilterResult) TestDescriptor(org.junit.platform.engine.TestDescriptor)

Example 3 with FilterResult

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

the class TestMethodFilterTests method includesBasedOnTestListResolver.

@Test
void includesBasedOnTestListResolver() throws Exception {
    when(resolver.shouldRun(toClassFileName(TestClass.class), "testMethod")).thenReturn(true);
    FilterResult result = filter.apply(newTestMethodDescriptor());
    assertTrue(result.included());
    assertFalse(result.excluded());
}
Also used : FilterResult(org.junit.platform.engine.FilterResult) Test(org.junit.jupiter.api.Test)

Example 4 with FilterResult

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

the class TestMethodFilterTests method excludesBasedOnTestListResolver.

@Test
void excludesBasedOnTestListResolver() throws Exception {
    when(resolver.shouldRun(toClassFileName(TestClass.class), "testMethod")).thenReturn(false);
    FilterResult result = filter.apply(newTestMethodDescriptor());
    assertFalse(result.included());
    assertTrue(result.excluded());
}
Also used : FilterResult(org.junit.platform.engine.FilterResult) Test(org.junit.jupiter.api.Test)

Aggregations

FilterResult (org.junit.platform.engine.FilterResult)4 Test (org.junit.jupiter.api.Test)3 HashSet (java.util.HashSet)1 Optional (java.util.Optional)1 Set (java.util.Set)1 JUnitException (org.junit.platform.commons.JUnitException)1 Logger (org.junit.platform.commons.logging.Logger)1 LoggerFactory (org.junit.platform.commons.logging.LoggerFactory)1 BlacklistedExceptions (org.junit.platform.commons.util.BlacklistedExceptions)1 Preconditions (org.junit.platform.commons.util.Preconditions)1 ConfigurationParameters (org.junit.platform.engine.ConfigurationParameters)1 ExecutionRequest (org.junit.platform.engine.ExecutionRequest)1 TestDescriptor (org.junit.platform.engine.TestDescriptor)1 TestEngine (org.junit.platform.engine.TestEngine)1 UniqueId (org.junit.platform.engine.UniqueId)1 Launcher (org.junit.platform.launcher.Launcher)1 LauncherDiscoveryRequest (org.junit.platform.launcher.LauncherDiscoveryRequest)1 TestExecutionListener (org.junit.platform.launcher.TestExecutionListener)1 TestPlan (org.junit.platform.launcher.TestPlan)1