Search in sources :

Example 1 with TestEngine

use of org.junit.platform.engine.TestEngine in project junit5 by junit-team.

the class DefaultLauncher method execute.

private void execute(Root root, ConfigurationParameters configurationParameters, TestExecutionListener... listeners) {
    TestExecutionListenerRegistry listenerRegistry = buildListenerRegistryForExecution(listeners);
    TestPlan testPlan = TestPlan.from(root.getEngineDescriptors());
    TestExecutionListener testExecutionListener = listenerRegistry.getCompositeTestExecutionListener();
    testExecutionListener.testPlanExecutionStarted(testPlan);
    ExecutionListenerAdapter engineExecutionListener = new ExecutionListenerAdapter(testPlan, testExecutionListener);
    for (TestEngine testEngine : root.getTestEngines()) {
        TestDescriptor testDescriptor = root.getTestDescriptorFor(testEngine);
        execute(testEngine, new ExecutionRequest(testDescriptor, engineExecutionListener, configurationParameters));
    }
    testExecutionListener.testPlanExecutionFinished(testPlan);
}
Also used : TestPlan(org.junit.platform.launcher.TestPlan) TestExecutionListener(org.junit.platform.launcher.TestExecutionListener) TestEngine(org.junit.platform.engine.TestEngine) ExecutionRequest(org.junit.platform.engine.ExecutionRequest) TestDescriptor(org.junit.platform.engine.TestDescriptor)

Example 2 with TestEngine

use of org.junit.platform.engine.TestEngine in project junit5 by junit-team.

the class TestEngineTests method defaults.

@Test
void defaults() {
    TestEngine engine = new DefaultEngine();
    assertEquals(Optional.empty(), engine.getGroupId());
    assertEquals(Optional.empty(), engine.getArtifactId());
    assertEquals(Optional.of("DEVELOPMENT"), engine.getVersion());
}
Also used : TestEngine(org.junit.platform.engine.TestEngine) Test(org.junit.jupiter.api.Test)

Example 3 with TestEngine

use of org.junit.platform.engine.TestEngine in project junit5 by junit-team.

the class DefaultLauncherTests method discoverTestPlanForEngineThatThrowsAnErrorInDiscoverPhase.

@Test
void discoverTestPlanForEngineThatThrowsAnErrorInDiscoverPhase() {
    TestEngine engine = new TestEngineStub() {

        @Override
        public TestDescriptor discover(org.junit.platform.engine.EngineDiscoveryRequest discoveryRequest, UniqueId uniqueId) {
            throw new Error("ignored");
        }
    };
    TestPlan testPlan = createLauncher(engine).discover(request().build());
    assertThat(testPlan.getRoots()).hasSize(0);
}
Also used : UniqueId(org.junit.platform.engine.UniqueId) DiscoverySelectors.selectUniqueId(org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId) TestPlan(org.junit.platform.launcher.TestPlan) DemoHierarchicalTestEngine(org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine) TestEngine(org.junit.platform.engine.TestEngine) EngineDiscoveryRequest(org.junit.platform.engine.EngineDiscoveryRequest) TestEngineStub(org.junit.platform.engine.test.TestEngineStub) Test(org.junit.jupiter.api.Test)

Example 4 with TestEngine

use of org.junit.platform.engine.TestEngine in project junit5 by junit-team.

the class DefaultLauncherTests method discoverTestPlanForEngineThatThrowsRuntimeExceptionInDiscoverPhase.

@Test
void discoverTestPlanForEngineThatThrowsRuntimeExceptionInDiscoverPhase() {
    TestEngine engine = new TestEngineStub() {

        @Override
        public TestDescriptor discover(org.junit.platform.engine.EngineDiscoveryRequest discoveryRequest, UniqueId uniqueId) {
            throw new RuntimeException("ignored");
        }
    };
    TestPlan testPlan = createLauncher(engine).discover(request().build());
    assertThat(testPlan.getRoots()).hasSize(0);
}
Also used : UniqueId(org.junit.platform.engine.UniqueId) DiscoverySelectors.selectUniqueId(org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId) TestPlan(org.junit.platform.launcher.TestPlan) DemoHierarchicalTestEngine(org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine) TestEngine(org.junit.platform.engine.TestEngine) EngineDiscoveryRequest(org.junit.platform.engine.EngineDiscoveryRequest) TestEngineStub(org.junit.platform.engine.test.TestEngineStub) Test(org.junit.jupiter.api.Test)

Example 5 with TestEngine

use of org.junit.platform.engine.TestEngine in project junit5 by junit-team.

the class DefaultLauncherTests method discoverTestPlanForEngineThatReturnsNullForItsRootDescriptor.

@Test
void discoverTestPlanForEngineThatReturnsNullForItsRootDescriptor() {
    TestEngine engine = new TestEngineStub() {

        @Override
        public TestDescriptor discover(org.junit.platform.engine.EngineDiscoveryRequest discoveryRequest, UniqueId uniqueId) {
            return null;
        }
    };
    TestPlan testPlan = createLauncher(engine).discover(request().build());
    assertThat(testPlan.getRoots()).hasSize(0);
}
Also used : UniqueId(org.junit.platform.engine.UniqueId) DiscoverySelectors.selectUniqueId(org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId) TestPlan(org.junit.platform.launcher.TestPlan) DemoHierarchicalTestEngine(org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine) TestEngine(org.junit.platform.engine.TestEngine) EngineDiscoveryRequest(org.junit.platform.engine.EngineDiscoveryRequest) TestEngineStub(org.junit.platform.engine.test.TestEngineStub) Test(org.junit.jupiter.api.Test)

Aggregations

TestEngine (org.junit.platform.engine.TestEngine)6 TestPlan (org.junit.platform.launcher.TestPlan)5 Test (org.junit.jupiter.api.Test)4 UniqueId (org.junit.platform.engine.UniqueId)4 EngineDiscoveryRequest (org.junit.platform.engine.EngineDiscoveryRequest)3 DiscoverySelectors.selectUniqueId (org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId)3 DemoHierarchicalTestEngine (org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine)3 TestEngineStub (org.junit.platform.engine.test.TestEngineStub)3 ExecutionRequest (org.junit.platform.engine.ExecutionRequest)2 TestDescriptor (org.junit.platform.engine.TestDescriptor)2 TestExecutionListener (org.junit.platform.launcher.TestExecutionListener)2 HashSet (java.util.HashSet)1 Optional (java.util.Optional)1 Set (java.util.Set)1 JUnitException (org.junit.platform.commons.JUnitException)1 Logger (org.junit.platform.commons.logging.Logger)1 LoggerFactory (org.junit.platform.commons.logging.LoggerFactory)1 BlacklistedExceptions (org.junit.platform.commons.util.BlacklistedExceptions)1 Preconditions (org.junit.platform.commons.util.Preconditions)1 ConfigurationParameters (org.junit.platform.engine.ConfigurationParameters)1