Search in sources :

Example 1 with LauncherDiscoveryListener

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

the class LauncherDiscoveryRequestBuilder method getLauncherDiscoveryListener.

private LauncherDiscoveryListener getLauncherDiscoveryListener(ConfigurationParameters configurationParameters) {
    LauncherDiscoveryListener defaultDiscoveryListener = getDefaultLauncherDiscoveryListener(configurationParameters);
    if (discoveryListeners.isEmpty()) {
        return defaultDiscoveryListener;
    }
    if (discoveryListeners.contains(defaultDiscoveryListener)) {
        return LauncherDiscoveryListeners.composite(discoveryListeners);
    }
    List<LauncherDiscoveryListener> allDiscoveryListeners = new ArrayList<>(discoveryListeners.size() + 1);
    allDiscoveryListeners.addAll(discoveryListeners);
    allDiscoveryListeners.add(defaultDiscoveryListener);
    return LauncherDiscoveryListeners.composite(allDiscoveryListeners);
}
Also used : ArrayList(java.util.ArrayList) LauncherDiscoveryListener(org.junit.platform.launcher.LauncherDiscoveryListener)

Example 2 with LauncherDiscoveryListener

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

the class LauncherDiscoveryRequestBuilder method build.

/**
 * Build the {@link LauncherDiscoveryRequest} that has been configured via
 * this builder.
 */
public LauncherDiscoveryRequest build() {
    LauncherConfigurationParameters launcherConfigurationParameters = buildLauncherConfigurationParameters();
    LauncherDiscoveryListener discoveryListener = getLauncherDiscoveryListener(launcherConfigurationParameters);
    return new DefaultDiscoveryRequest(this.selectors, this.engineFilters, this.discoveryFilters, this.postDiscoveryFilters, launcherConfigurationParameters, discoveryListener);
}
Also used : LauncherDiscoveryListener(org.junit.platform.launcher.LauncherDiscoveryListener)

Example 3 with LauncherDiscoveryListener

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

the class EngineDiscoveryOrchestrator method discover.

private Map<TestEngine, TestDescriptor> discover(LauncherDiscoveryRequest request, Phase phase, Function<String, UniqueId> uniqueIdCreator) {
    LauncherDiscoveryListener listener = getLauncherDiscoveryListener(request);
    listener.launcherDiscoveryStarted(request);
    try {
        return discoverSafely(request, phase, listener, uniqueIdCreator);
    } finally {
        listener.launcherDiscoveryFinished(request);
    }
}
Also used : LauncherDiscoveryListener(org.junit.platform.launcher.LauncherDiscoveryListener)

Example 4 with LauncherDiscoveryListener

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

the class EngineDiscoveryOrchestrator method discoverSafely.

private Map<TestEngine, TestDescriptor> discoverSafely(LauncherDiscoveryRequest request, Phase phase, LauncherDiscoveryListener listener, Function<String, UniqueId> uniqueIdCreator) {
    Map<TestEngine, TestDescriptor> testEngineDescriptors = new LinkedHashMap<>();
    for (TestEngine testEngine : this.testEngines) {
        boolean engineIsExcluded = // 
        request.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 %s phase.", testEngine.getId(), phase));
            continue;
        }
        logger.debug(() -> String.format("Discovering tests during Launcher %s phase in engine '%s'.", phase, testEngine.getId()));
        TestDescriptor rootDescriptor = discoverEngineRoot(testEngine, request, listener, uniqueIdCreator);
        testEngineDescriptors.put(testEngine, rootDescriptor);
    }
    List<PostDiscoveryFilter> filters = new LinkedList<>(postDiscoveryFilters);
    filters.addAll(request.getPostDiscoveryFilters());
    applyPostDiscoveryFilters(testEngineDescriptors, filters);
    prune(testEngineDescriptors);
    return testEngineDescriptors;
}
Also used : Filter.composeFilters(org.junit.platform.engine.Filter.composeFilters) FilterResult(org.junit.platform.engine.FilterResult) TestEngine(org.junit.platform.engine.TestEngine) Filter(org.junit.platform.engine.Filter) INTERNAL(org.apiguardian.api.API.Status.INTERNAL) Function(java.util.function.Function) LoggerFactory(org.junit.platform.commons.logging.LoggerFactory) LinkedHashMap(java.util.LinkedHashMap) EngineDiscoveryResult(org.junit.platform.launcher.EngineDiscoveryResult) EngineExecutionListener(org.junit.platform.engine.EngineExecutionListener) Collectors.toMap(java.util.stream.Collectors.toMap) Locale(java.util.Locale) Map(java.util.Map) LauncherDiscoveryListener(org.junit.platform.launcher.LauncherDiscoveryListener) LinkedList(java.util.LinkedList) PostDiscoveryFilter(org.junit.platform.launcher.PostDiscoveryFilter) Logger(org.junit.platform.commons.logging.Logger) Collection(java.util.Collection) JUnitException(org.junit.platform.commons.JUnitException) LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) API(org.apiguardian.api.API) UniqueId(org.junit.platform.engine.UniqueId) Collectors.joining(java.util.stream.Collectors.joining) List(java.util.List) UnrecoverableExceptions(org.junit.platform.commons.util.UnrecoverableExceptions) Entry(java.util.Map.Entry) Optional(java.util.Optional) TestDescriptor(org.junit.platform.engine.TestDescriptor) PostDiscoveryFilter(org.junit.platform.launcher.PostDiscoveryFilter) TestEngine(org.junit.platform.engine.TestEngine) FilterResult(org.junit.platform.engine.FilterResult) TestDescriptor(org.junit.platform.engine.TestDescriptor) LinkedList(java.util.LinkedList) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

LauncherDiscoveryListener (org.junit.platform.launcher.LauncherDiscoveryListener)4 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Locale (java.util.Locale)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Optional (java.util.Optional)1 Function (java.util.function.Function)1 Collectors.joining (java.util.stream.Collectors.joining)1 Collectors.toMap (java.util.stream.Collectors.toMap)1 API (org.apiguardian.api.API)1 INTERNAL (org.apiguardian.api.API.Status.INTERNAL)1 JUnitException (org.junit.platform.commons.JUnitException)1 Logger (org.junit.platform.commons.logging.Logger)1 LoggerFactory (org.junit.platform.commons.logging.LoggerFactory)1 UnrecoverableExceptions (org.junit.platform.commons.util.UnrecoverableExceptions)1 EngineExecutionListener (org.junit.platform.engine.EngineExecutionListener)1