Class EngineTestKit

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  EngineTestKit.Builder
      TestEngine execution builder.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private EngineTestKit()  
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static EngineDiscoveryResults discover​(java.lang.String engineId, org.junit.platform.launcher.LauncherDiscoveryRequest discoveryRequest)
      Discover tests for the given LauncherDiscoveryRequest using the TestEngine with the supplied ID.
      static EngineDiscoveryResults discover​(org.junit.platform.engine.TestEngine testEngine, org.junit.platform.launcher.LauncherDiscoveryRequest discoveryRequest)
      Discover tests for the given LauncherDiscoveryRequest using the supplied TestEngine.
      private static org.junit.platform.launcher.core.LauncherDiscoveryResult discoverUsingOrchestrator​(org.junit.platform.engine.TestEngine testEngine, org.junit.platform.launcher.LauncherDiscoveryRequest discoveryRequest)  
      static EngineTestKit.Builder engine​(java.lang.String engineId)
      Create an execution EngineTestKit.Builder for the TestEngine with the supplied ID.
      static EngineTestKit.Builder engine​(org.junit.platform.engine.TestEngine testEngine)
      Create an execution EngineTestKit.Builder for the supplied TestEngine.
      static EngineExecutionResults execute​(java.lang.String engineId, org.junit.platform.engine.EngineDiscoveryRequest discoveryRequest)
      Deprecated.
      static EngineExecutionResults execute​(java.lang.String engineId, org.junit.platform.launcher.LauncherDiscoveryRequest discoveryRequest)
      Execute tests for the given LauncherDiscoveryRequest using the TestEngine with the supplied ID.
      static EngineExecutionResults execute​(org.junit.platform.engine.TestEngine testEngine, org.junit.platform.engine.EngineDiscoveryRequest discoveryRequest)
      Deprecated.
      static EngineExecutionResults execute​(org.junit.platform.engine.TestEngine testEngine, org.junit.platform.launcher.LauncherDiscoveryRequest discoveryRequest)
      Execute tests for the given LauncherDiscoveryRequest using the supplied TestEngine.
      private static void executeDirectly​(org.junit.platform.engine.TestEngine testEngine, org.junit.platform.engine.EngineDiscoveryRequest discoveryRequest, org.junit.platform.engine.EngineExecutionListener listener)  
      private static void executeUsingLauncherOrchestration​(org.junit.platform.engine.TestEngine testEngine, org.junit.platform.launcher.LauncherDiscoveryRequest discoveryRequest, org.junit.platform.engine.EngineExecutionListener listener)  
      private static org.junit.platform.engine.TestEngine loadTestEngine​(java.lang.String engineId)  
      private static org.junit.platform.engine.support.store.NamespacedHierarchicalStore<org.junit.platform.engine.support.store.Namespace> newStore​(org.junit.platform.engine.support.store.NamespacedHierarchicalStore<org.junit.platform.engine.support.store.Namespace> parentStore)  
      private static void withRequestLevelStore​(java.util.function.Consumer<org.junit.platform.engine.support.store.NamespacedHierarchicalStore<org.junit.platform.engine.support.store.Namespace>> action)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EngineTestKit

        private EngineTestKit()
    • Method Detail

      • engine

        public static EngineTestKit.Builder engine​(java.lang.String engineId)
        Create an execution EngineTestKit.Builder for the TestEngine with the supplied ID.

        The TestEngine will be loaded via Java's ServiceLoader mechanism, analogous to the manner in which test engines are loaded in the JUnit Platform Launcher API.

        Example Usage

         EngineTestKit
             .engine("junit-jupiter")
             .selectors(selectClass(MyTests.class))
             .execute()
             .testEvents()
             .assertStatistics(stats -> stats.started(2).finished(2));
         
        Parameters:
        engineId - the ID of the TestEngine to use; must not be null or blank
        Returns:
        the engine execution Builder
        Throws:
        org.junit.platform.commons.PreconditionViolationException - if the supplied ID is null or blank, or if the TestEngine with the supplied ID cannot be loaded
        See Also:
        engine(TestEngine), execute(String, LauncherDiscoveryRequest), execute(TestEngine, LauncherDiscoveryRequest)
      • discover

        @API(status=MAINTAINED,
             since="1.13.3")
        public static EngineDiscoveryResults discover​(java.lang.String engineId,
                                                      org.junit.platform.launcher.LauncherDiscoveryRequest discoveryRequest)
        Discover tests for the given LauncherDiscoveryRequest using the TestEngine with the supplied ID.

        The TestEngine will be loaded via Java's ServiceLoader mechanism, analogous to the manner in which test engines are loaded in the JUnit Platform Launcher API.

        LauncherDiscoveryRequestBuilder provides a convenient way to build an appropriate discovery request to supply to this method. As an alternative, consider using engine(TestEngine) for a more fluent API.

        Parameters:
        engineId - the ID of the TestEngine to use; must not be null or blank
        discoveryRequest - the LauncherDiscoveryRequest to use
        Returns:
        the results of the discovery
        Throws:
        org.junit.platform.commons.PreconditionViolationException - for invalid arguments or if the TestEngine with the supplied ID cannot be loaded
        Since:
        1.13
        See Also:
        discover(TestEngine, LauncherDiscoveryRequest), engine(String), engine(TestEngine)
      • discover

        @API(status=MAINTAINED,
             since="1.13.3")
        public static EngineDiscoveryResults discover​(org.junit.platform.engine.TestEngine testEngine,
                                                      org.junit.platform.launcher.LauncherDiscoveryRequest discoveryRequest)
        Discover tests for the given LauncherDiscoveryRequest using the supplied TestEngine.

        LauncherDiscoveryRequestBuilder provides a convenient way to build an appropriate discovery request to supply to this method. As an alternative, consider using engine(TestEngine) for a more fluent API.

        Parameters:
        testEngine - the TestEngine to use; must not be null
        discoveryRequest - the EngineDiscoveryResults to use; must not be null
        Returns:
        the recorded EngineExecutionResults
        Throws:
        org.junit.platform.commons.PreconditionViolationException - for invalid arguments
        Since:
        1.13
        See Also:
        discover(String, LauncherDiscoveryRequest), engine(String), engine(TestEngine)
      • execute

        @Deprecated
        @API(status=DEPRECATED,
             since="1.7")
        public static EngineExecutionResults execute​(java.lang.String engineId,
                                                     org.junit.platform.engine.EngineDiscoveryRequest discoveryRequest)
        Deprecated.
        Execute tests for the given EngineDiscoveryRequest using the TestEngine with the supplied ID.

        The TestEngine will be loaded via Java's ServiceLoader mechanism, analogous to the manner in which test engines are loaded in the JUnit Platform Launcher API.

        Note that LauncherDiscoveryRequest from the junit-platform-launcher module is a subtype of EngineDiscoveryRequest. It is therefore quite convenient to make use of the DSL provided in LauncherDiscoveryRequestBuilder to build an appropriate discovery request to supply to this method. As an alternative, consider using engine(String) for a more fluent API.

        Parameters:
        engineId - the ID of the TestEngine to use; must not be null or blank
        discoveryRequest - the EngineDiscoveryRequest to use
        Returns:
        the results of the execution
        Throws:
        org.junit.platform.commons.PreconditionViolationException - for invalid arguments or if the TestEngine with the supplied ID cannot be loaded
        See Also:
        execute(String, LauncherDiscoveryRequest), engine(String), engine(TestEngine)
      • execute

        public static EngineExecutionResults execute​(java.lang.String engineId,
                                                     org.junit.platform.launcher.LauncherDiscoveryRequest discoveryRequest)
        Execute tests for the given LauncherDiscoveryRequest using the TestEngine with the supplied ID.

        The TestEngine will be loaded via Java's ServiceLoader mechanism, analogous to the manner in which test engines are loaded in the JUnit Platform Launcher API.

        LauncherDiscoveryRequestBuilder provides a convenient way to build an appropriate discovery request to supply to this method. As an alternative, consider using engine(TestEngine) for a more fluent API.

        Parameters:
        engineId - the ID of the TestEngine to use; must not be null or blank
        discoveryRequest - the LauncherDiscoveryRequest to use
        Returns:
        the results of the execution
        Throws:
        org.junit.platform.commons.PreconditionViolationException - for invalid arguments or if the TestEngine with the supplied ID cannot be loaded
        Since:
        1.7
        See Also:
        execute(TestEngine, LauncherDiscoveryRequest), engine(String), engine(TestEngine)
      • execute

        @Deprecated
        @API(status=DEPRECATED,
             since="1.7")
        public static EngineExecutionResults execute​(org.junit.platform.engine.TestEngine testEngine,
                                                     org.junit.platform.engine.EngineDiscoveryRequest discoveryRequest)
        Deprecated.
        Execute tests for the given EngineDiscoveryRequest using the supplied TestEngine.

        Note that LauncherDiscoveryRequest from the junit-platform-launcher module is a subtype of EngineDiscoveryRequest. It is therefore quite convenient to make use of the DSL provided in LauncherDiscoveryRequestBuilder to build an appropriate discovery request to supply to this method. As an alternative, consider using engine(TestEngine) for a more fluent API.

        Parameters:
        testEngine - the TestEngine to use; must not be null
        discoveryRequest - the EngineDiscoveryRequest to use; must not be null
        Returns:
        the recorded EngineExecutionResults
        Throws:
        org.junit.platform.commons.PreconditionViolationException - for invalid arguments
        See Also:
        execute(TestEngine, LauncherDiscoveryRequest), engine(String), engine(TestEngine)
      • execute

        public static EngineExecutionResults execute​(org.junit.platform.engine.TestEngine testEngine,
                                                     org.junit.platform.launcher.LauncherDiscoveryRequest discoveryRequest)
        Execute tests for the given LauncherDiscoveryRequest using the supplied TestEngine.

        LauncherDiscoveryRequestBuilder provides a convenient way to build an appropriate discovery request to supply to this method. As an alternative, consider using engine(TestEngine) for a more fluent API.

        Parameters:
        testEngine - the TestEngine to use; must not be null
        discoveryRequest - the LauncherDiscoveryRequest to use; must not be null
        Returns:
        the recorded EngineExecutionResults
        Throws:
        org.junit.platform.commons.PreconditionViolationException - for invalid arguments
        Since:
        1.7
        See Also:
        execute(String, LauncherDiscoveryRequest), engine(String), engine(TestEngine)
      • executeDirectly

        private static void executeDirectly​(org.junit.platform.engine.TestEngine testEngine,
                                            org.junit.platform.engine.EngineDiscoveryRequest discoveryRequest,
                                            org.junit.platform.engine.EngineExecutionListener listener)
      • executeUsingLauncherOrchestration

        private static void executeUsingLauncherOrchestration​(org.junit.platform.engine.TestEngine testEngine,
                                                              org.junit.platform.launcher.LauncherDiscoveryRequest discoveryRequest,
                                                              org.junit.platform.engine.EngineExecutionListener listener)
      • withRequestLevelStore

        private static void withRequestLevelStore​(java.util.function.Consumer<org.junit.platform.engine.support.store.NamespacedHierarchicalStore<org.junit.platform.engine.support.store.Namespace>> action)
      • newStore

        private static org.junit.platform.engine.support.store.NamespacedHierarchicalStore<org.junit.platform.engine.support.store.Namespace> newStore​(org.junit.platform.engine.support.store.NamespacedHierarchicalStore<org.junit.platform.engine.support.store.Namespace> parentStore)
      • discoverUsingOrchestrator

        private static org.junit.platform.launcher.core.LauncherDiscoveryResult discoverUsingOrchestrator​(org.junit.platform.engine.TestEngine testEngine,
                                                                                                          org.junit.platform.launcher.LauncherDiscoveryRequest discoveryRequest)
      • loadTestEngine

        private static org.junit.platform.engine.TestEngine loadTestEngine​(java.lang.String engineId)