Class JUnitPlatform
- All Implemented Interfaces:
org.junit.runner.Describable
,org.junit.runner.manipulation.Filterable
Runner
which runs tests on the JUnit Platform in a
JUnit 4 environment.
Annotating a class with @RunWith(JUnitPlatform.class)
allows it
to be run with IDEs and build systems that support JUnit 4 but do not yet
support the JUnit Platform directly.
Please note that test classes and suites annotated with
@RunWith(JUnitPlatform.class)
cannot be executed directly on
the JUnit Platform (or as a "JUnit 5" test as documented in some IDEs). Such
classes and suites can only be executed using JUnit 4 infrastructure.
Consult the various annotations in the org.junit.platform.suite.api
package for configuration options.
If you do not use any configuration annotations from the
org.junit.platform.suite.api
package, you can simply use this runner
on a test class whose programming model is supported on the JUnit Platform
— for example, a JUnit Jupiter test class. Note, however, that any test
class run with this runner must be public
in order to be picked up by
IDEs and build tools.
When used on a class that serves as a test suite and the
@IncludeClassNamePatterns
annotation is not
present, the default include pattern
"^(Test.*|.+[.$]Test.*|.*Tests?)$"
will be used in order to avoid loading classes unnecessarily (see ClassNameFilter#STANDARD_INCLUDE_PATTERN
).
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionJUnitPlatform
(Class<?> testClass) JUnitPlatform
(Class<?> testClass, Launcher launcher) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addExcludeClassNamePatternFilter
(LauncherDiscoveryRequestBuilder requestBuilder) private void
addExcludedEnginesFilter
(LauncherDiscoveryRequestBuilder requestBuilder) private void
addExcludedTagsFilter
(LauncherDiscoveryRequestBuilder requestBuilder) private void
addExcludePackagesFilter
(LauncherDiscoveryRequestBuilder requestBuilder) private void
addFiltersFromAnnotations
(LauncherDiscoveryRequestBuilder requestBuilder, boolean isSuite) private void
addIncludeClassNamePatternFilter
(LauncherDiscoveryRequestBuilder requestBuilder, boolean isSuite) private void
addIncludedEnginesFilter
(LauncherDiscoveryRequestBuilder requestBuilder) private void
addIncludedTagsFilter
(LauncherDiscoveryRequestBuilder requestBuilder) private void
addIncludePackagesFilter
(LauncherDiscoveryRequestBuilder requestBuilder) private LauncherDiscoveryRequest
private LauncherDiscoveryRequest
createDiscoveryRequestForUniqueIds
(Set<TestIdentifier> testIdentifiers) void
filter
(org.junit.runner.manipulation.Filter filter) private JUnitPlatformTestTree
generateTestTree
(LauncherDiscoveryRequest discoveryRequest) org.junit.runner.Description
private String[]
private String[]
private String[]
private String[]
private String[]
getIncludeClassNamePatterns
(boolean isSuite) private String[]
private String[]
private String[]
private Class<?>[]
private String[]
private List<DiscoverySelector>
private <A extends Annotation,
V>
VgetValueFromAnnotation
(Class<A> annotationClass, Function<A, V> extractor, V defaultValue) void
run
(org.junit.runner.notification.RunNotifier notifier) private <T> List<DiscoverySelector>
transform
(T[] sourceElements, Function<T, DiscoverySelector> transformer) private String[]
Methods inherited from class org.junit.runner.Runner
testCount
-
Field Details
-
EMPTY_CLASS_ARRAY
-
EMPTY_STRING_ARRAY
-
STANDARD_INCLUDE_PATTERN_ARRAY
-
testClass
-
launcher
-
testTree
-
-
Constructor Details
-
JUnitPlatform
-
JUnitPlatform
-
-
Method Details
-
getDescription
public org.junit.runner.Description getDescription()- Specified by:
getDescription
in interfaceorg.junit.runner.Describable
- Specified by:
getDescription
in classorg.junit.runner.Runner
-
run
public void run(org.junit.runner.notification.RunNotifier notifier) - Specified by:
run
in classorg.junit.runner.Runner
-
generateTestTree
-
createDiscoveryRequest
-
addFiltersFromAnnotations
private void addFiltersFromAnnotations(LauncherDiscoveryRequestBuilder requestBuilder, boolean isSuite) -
getSelectorsFromAnnotations
-
transform
private <T> List<DiscoverySelector> transform(T[] sourceElements, Function<T, DiscoverySelector> transformer) -
addIncludeClassNamePatternFilter
private void addIncludeClassNamePatternFilter(LauncherDiscoveryRequestBuilder requestBuilder, boolean isSuite) -
addExcludeClassNamePatternFilter
-
addIncludePackagesFilter
-
addExcludePackagesFilter
-
addIncludedTagsFilter
-
addExcludedTagsFilter
-
addIncludedEnginesFilter
-
addExcludedEnginesFilter
-
getSelectedClasses
-
getSelectedPackageNames
-
getIncludedPackages
-
getExcludedPackages
-
getIncludedTags
-
getExcludedTags
-
getIncludedEngineIds
-
getExcludedEngineIds
-
getIncludeClassNamePatterns
-
getExcludeClassNamePatterns
-
trimmed
-
getValueFromAnnotation
private <A extends Annotation,V> V getValueFromAnnotation(Class<A> annotationClass, Function<A, V> extractor, V defaultValue) -
filter
public void filter(org.junit.runner.manipulation.Filter filter) throws org.junit.runner.manipulation.NoTestsRemainException - Specified by:
filter
in interfaceorg.junit.runner.manipulation.Filterable
- Throws:
org.junit.runner.manipulation.NoTestsRemainException
-
createDiscoveryRequestForUniqueIds
private LauncherDiscoveryRequest createDiscoveryRequestForUniqueIds(Set<TestIdentifier> testIdentifiers)
-