Class JUnitPlatform

  • All Implemented Interfaces:
    org.junit.runner.Describable, org.junit.runner.manipulation.Filterable

    @API(status=STABLE,
         since="1.0")
    public class JUnitPlatform
    extends org.junit.runner.Runner
    implements org.junit.runner.manipulation.Filterable
    JUnit 4 based 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.

    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).

    Since:
    1.0
    See Also:
    SuiteDisplayName, UseTechnicalNames, SelectPackages, SelectClasses, IncludeClassNamePatterns, ExcludeClassNamePatterns, IncludePackages, ExcludePackages, IncludeTags, ExcludeTags, IncludeEngines, ExcludeEngines
    • Field Detail

      • EMPTY_CLASS_ARRAY

        private static final java.lang.Class<?>[] EMPTY_CLASS_ARRAY
      • EMPTY_STRING_ARRAY

        private static final java.lang.String[] EMPTY_STRING_ARRAY
      • STANDARD_INCLUDE_PATTERN_ARRAY

        private static final java.lang.String[] STANDARD_INCLUDE_PATTERN_ARRAY
      • testClass

        private final java.lang.Class<?> testClass
      • launcher

        private final Launcher launcher
    • Constructor Detail

      • JUnitPlatform

        public JUnitPlatform​(java.lang.Class<?> testClass)
      • JUnitPlatform

        JUnitPlatform​(java.lang.Class<?> testClass,
                      Launcher launcher)
    • Method Detail

      • getDescription

        public org.junit.runner.Description getDescription()
        Specified by:
        getDescription in interface org.junit.runner.Describable
        Specified by:
        getDescription in class org.junit.runner.Runner
      • run

        public void run​(org.junit.runner.notification.RunNotifier notifier)
        Specified by:
        run in class org.junit.runner.Runner
      • getSelectorsFromAnnotations

        private java.util.List<DiscoverySelector> getSelectorsFromAnnotations()
      • getSelectedClasses

        private java.lang.Class<?>[] getSelectedClasses()
      • getSelectedPackageNames

        private java.lang.String[] getSelectedPackageNames()
      • getIncludedPackages

        private java.lang.String[] getIncludedPackages()
      • getExcludedPackages

        private java.lang.String[] getExcludedPackages()
      • getIncludedTags

        private java.lang.String[] getIncludedTags()
      • getExcludedTags

        private java.lang.String[] getExcludedTags()
      • getIncludedEngineIds

        private java.lang.String[] getIncludedEngineIds()
      • getExcludedEngineIds

        private java.lang.String[] getExcludedEngineIds()
      • getIncludeClassNamePatterns

        private java.lang.String[] getIncludeClassNamePatterns​(boolean isSuite)
      • getExcludeClassNamePatterns

        private java.lang.String[] getExcludeClassNamePatterns()
      • trimmed

        private java.lang.String[] trimmed​(java.lang.String[] patterns)
      • getValueFromAnnotation

        private <A extends java.lang.annotation.Annotation,​V> V getValueFromAnnotation​(java.lang.Class<A> annotationClass,
                                                                                             java.util.function.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 interface org.junit.runner.manipulation.Filterable
        Throws:
        org.junit.runner.manipulation.NoTestsRemainException