Search in sources :

Example 21 with DemoHierarchicalTestEngine

use of org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine in project junit5 by junit-team.

the class DefaultLauncherTests method discoverTestPlanForSingleEngine.

@Test
void discoverTestPlanForSingleEngine() {
    DemoHierarchicalTestEngine engine = new DemoHierarchicalTestEngine("myEngine");
    engine.addTest("test1", noOp);
    engine.addTest("test2", noOp);
    DefaultLauncher launcher = createLauncher(engine);
    TestPlan testPlan = launcher.discover(request().selectors(selectPackage("any")).build());
    assertThat(testPlan.getRoots()).hasSize(1);
    TestIdentifier rootIdentifier = testPlan.getRoots().iterator().next();
    assertThat(testPlan.getChildren(rootIdentifier.getUniqueId())).hasSize(2);
    assertThat(testPlan.getChildren("[engine:myEngine]")).hasSize(2);
}
Also used : TestPlan(org.junit.platform.launcher.TestPlan) DemoHierarchicalTestEngine(org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine) TestIdentifier(org.junit.platform.launcher.TestIdentifier) Test(org.junit.jupiter.api.Test)

Example 22 with DemoHierarchicalTestEngine

use of org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine in project junit5 by junit-team.

the class DefaultLauncherTests method launcherWillNotExecuteEnginesIfNotIncludedByAnEngineFilter.

@Test
void launcherWillNotExecuteEnginesIfNotIncludedByAnEngineFilter() {
    DemoHierarchicalTestEngine firstEngine = new DemoHierarchicalTestEngine("first");
    TestDescriptor test1 = firstEngine.addTest("test1", noOp);
    DemoHierarchicalTestEngine secondEngine = new DemoHierarchicalTestEngine("second");
    TestDescriptor test2 = secondEngine.addTest("test2", noOp);
    DefaultLauncher launcher = createLauncher(firstEngine, secondEngine);
    // @formatter:off
    TestPlan testPlan = launcher.discover(request().selectors(selectUniqueId(test1.getUniqueId()), selectUniqueId(test2.getUniqueId())).filters(includeEngines("first")).build());
    // @formatter:on
    assertThat(testPlan.getRoots()).hasSize(1);
    TestIdentifier rootIdentifier = testPlan.getRoots().iterator().next();
    assertThat(testPlan.getChildren(rootIdentifier.getUniqueId())).hasSize(1);
    assertThat(testPlan.getChildren(UniqueId.forEngine("first").toString())).hasSize(1);
}
Also used : TestPlan(org.junit.platform.launcher.TestPlan) DemoHierarchicalTestEngine(org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine) TestIdentifier(org.junit.platform.launcher.TestIdentifier) DemoHierarchicalTestDescriptor(org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestDescriptor) TestDescriptor(org.junit.platform.engine.TestDescriptor) Test(org.junit.jupiter.api.Test)

Example 23 with DemoHierarchicalTestEngine

use of org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine in project junit5 by junit-team.

the class DefaultLauncherTests method launcherWillNotExecuteEnginesExplicitlyExcludedByAnEngineFilter.

@Test
void launcherWillNotExecuteEnginesExplicitlyExcludedByAnEngineFilter() {
    DemoHierarchicalTestEngine firstEngine = new DemoHierarchicalTestEngine("first");
    TestDescriptor test1 = firstEngine.addTest("test1", noOp);
    DemoHierarchicalTestEngine secondEngine = new DemoHierarchicalTestEngine("second");
    TestDescriptor test2 = secondEngine.addTest("test2", noOp);
    DefaultLauncher launcher = createLauncher(firstEngine, secondEngine);
    // @formatter:off
    TestPlan testPlan = launcher.discover(request().selectors(selectUniqueId(test1.getUniqueId()), selectUniqueId(test2.getUniqueId())).filters(excludeEngines("second")).build());
    // @formatter:on
    assertThat(testPlan.getRoots()).hasSize(1);
    TestIdentifier rootIdentifier = testPlan.getRoots().iterator().next();
    assertThat(testPlan.getChildren(rootIdentifier.getUniqueId())).hasSize(1);
    assertThat(testPlan.getChildren(UniqueId.forEngine("first").toString())).hasSize(1);
}
Also used : TestPlan(org.junit.platform.launcher.TestPlan) DemoHierarchicalTestEngine(org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine) TestIdentifier(org.junit.platform.launcher.TestIdentifier) DemoHierarchicalTestDescriptor(org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestDescriptor) TestDescriptor(org.junit.platform.engine.TestDescriptor) Test(org.junit.jupiter.api.Test)

Example 24 with DemoHierarchicalTestEngine

use of org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine in project junit5 by junit-team.

the class DefaultLauncherTests method discoverTestPlanForMultipleEngines.

@Test
void discoverTestPlanForMultipleEngines() {
    DemoHierarchicalTestEngine firstEngine = new DemoHierarchicalTestEngine("engine1");
    TestDescriptor test1 = firstEngine.addTest("test1", noOp);
    DemoHierarchicalTestEngine secondEngine = new DemoHierarchicalTestEngine("engine2");
    TestDescriptor test2 = secondEngine.addTest("test2", noOp);
    DefaultLauncher launcher = createLauncher(firstEngine, secondEngine);
    TestPlan testPlan = launcher.discover(request().selectors(selectUniqueId(test1.getUniqueId()), selectUniqueId(test2.getUniqueId())).build());
    assertThat(testPlan.getRoots()).hasSize(2);
    assertThat(testPlan.getChildren(UniqueId.forEngine("engine1").toString())).hasSize(1);
    assertThat(testPlan.getChildren(UniqueId.forEngine("engine2").toString())).hasSize(1);
}
Also used : TestPlan(org.junit.platform.launcher.TestPlan) DemoHierarchicalTestEngine(org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine) DemoHierarchicalTestDescriptor(org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestDescriptor) TestDescriptor(org.junit.platform.engine.TestDescriptor) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)24 DemoHierarchicalTestEngine (org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine)24 TestPlan (org.junit.platform.launcher.TestPlan)9 DemoHierarchicalTestDescriptor (org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestDescriptor)8 TestDescriptor (org.junit.platform.engine.TestDescriptor)6 TestIdentifier (org.junit.platform.launcher.TestIdentifier)4 PreconditionViolationException (org.junit.platform.commons.util.PreconditionViolationException)3 TestExecutionListener (org.junit.platform.launcher.TestExecutionListener)2 AssertionFailedError (org.opentest4j.AssertionFailedError)2 LocalDateTime (java.time.LocalDateTime)1 ZoneId (java.time.ZoneId)1 JUnitException (org.junit.platform.commons.JUnitException)1 PostDiscoveryFilter (org.junit.platform.launcher.PostDiscoveryFilter)1 PostDiscoveryFilterStub (org.junit.platform.launcher.PostDiscoveryFilterStub)1