| 1 |
/* |
| 2 |
* Copyright 2015-2024 the original author or authors. |
| 3 |
* |
| 4 |
* All rights reserved. This program and the accompanying materials are |
| 5 |
* made available under the terms of the Eclipse Public License v2.0 which |
| 6 |
* accompanies this distribution and is available at |
| 7 |
* |
| 8 |
* https://www.eclipse.org/legal/epl-v20.html |
| 9 |
*/ |
| 10 |
|
| 11 |
package org.junit.platform.engine; |
| 12 |
|
| 13 |
import static org.apiguardian.api.API.Status.STABLE; |
| 14 |
|
| 15 |
import java.util.List; |
| 16 |
|
| 17 |
import org.apiguardian.api.API; |
| 18 |
|
| 19 |
/** |
| 20 |
* {@code EngineDiscoveryRequest} provides a {@link TestEngine} access to the |
| 21 |
* information necessary to discover tests and containers. |
| 22 |
* |
| 23 |
* <p>A request is comprised of {@linkplain DiscoverySelector selectors} and |
| 24 |
* {@linkplain DiscoveryFilter filters}. While the former <em>select</em> |
| 25 |
* resources that engines can use to discover tests, the latter specify how |
| 26 |
* such resources are to be <em>filtered</em>. All of the <em>filters</em> |
| 27 |
* have to include a resource for it to end up in the test plan. |
| 28 |
* |
| 29 |
* <p>In addition, the supplied {@linkplain ConfigurationParameters |
| 30 |
* configuration parameters} can be used to influence the discovery process. |
| 31 |
* |
| 32 |
* @since 1.0 |
| 33 |
* @see TestEngine |
| 34 |
* @see TestDescriptor |
| 35 |
* @see DiscoverySelector |
| 36 |
* @see DiscoveryFilter |
| 37 |
* @see ConfigurationParameters |
| 38 |
*/ |
| 39 |
@API(status = STABLE, since = "1.0") |
| 40 |
public interface EngineDiscoveryRequest { |
| 41 |
|
| 42 |
/** |
| 43 |
* Get the {@link DiscoverySelector DiscoverySelectors} for this request, |
| 44 |
* filtered by a particular type. |
| 45 |
* |
| 46 |
* @param selectorType the type of {@link DiscoverySelector} to filter by |
| 47 |
* @return all selectors of this request that are instances of |
| 48 |
* {@code selectorType}; never {@code null} but potentially empty |
| 49 |
*/ |
| 50 |
<T extends DiscoverySelector> List<T> getSelectorsByType(Class<T> selectorType); |
| 51 |
|
| 52 |
/** |
| 53 |
* Get the {@link DiscoveryFilter DiscoveryFilters} for this request, |
| 54 |
* filtered by a particular type. |
| 55 |
* |
| 56 |
* <p>The returned filters are to be combined using AND semantics, i.e. all |
| 57 |
* of them have to include a resource for it to end up in the test plan. |
| 58 |
* |
| 59 |
* @param filterType the type of {@link DiscoveryFilter} to filter by |
| 60 |
* @return all filters of this request that are instances of |
| 61 |
* {@code filterType}; never {@code null} but potentially empty |
| 62 |
*/ |
| 63 |
<T extends DiscoveryFilter<?>> List<T> getFiltersByType(Class<T> filterType); |
| 64 |
|
| 65 |
/** |
| 66 |
* Get the {@link ConfigurationParameters} for this request. |
| 67 |
* |
| 68 |
* @return the configuration parameters; never {@code null} |
| 69 |
*/ |
| 70 |
ConfigurationParameters getConfigurationParameters(); |
| 71 |
|
| 72 |
/** |
| 73 |
* Get the {@link EngineDiscoveryListener} for this request. |
| 74 |
* |
| 75 |
* <p>The default implementation returns a no-op listener that ignores all |
| 76 |
* calls so that engines that call this methods can be used with an earlier |
| 77 |
* version of the JUnit Platform that did not yet include this API. |
| 78 |
* |
| 79 |
* @return the discovery listener; never {@code null} |
| 80 |
* @since 1.6 |
| 81 |
*/ |
| 82 |
@API(status = STABLE, since = "1.10") |
| 83 |
default EngineDiscoveryListener getDiscoveryListener() { |
| 84 |
return EngineDiscoveryListener.NOOP; |
| 85 |
} |
| 86 |
|
| 87 |
} |