Search in sources :

Example 1 with DemoHierarchicalTestEngine

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

the class DefaultLauncherTests method registerTestExecutionListenersWithEmptyArray.

@Test
void registerTestExecutionListenersWithEmptyArray() {
    DefaultLauncher launcher = createLauncher(new DemoHierarchicalTestEngine("dummy id"));
    PreconditionViolationException exception = assertThrows(PreconditionViolationException.class, () -> launcher.registerTestExecutionListeners(new TestExecutionListener[0]));
    assertThat(exception).hasMessageContaining("listeners array must not be null or empty");
}
Also used : TestExecutionListener(org.junit.platform.launcher.TestExecutionListener) DemoHierarchicalTestEngine(org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine) PreconditionViolationException(org.junit.platform.commons.util.PreconditionViolationException) Test(org.junit.jupiter.api.Test)

Example 2 with DemoHierarchicalTestEngine

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

the class DefaultLauncherTests method constructLauncherWithMultipleTestEnginesWithDuplicateIds.

@Test
void constructLauncherWithMultipleTestEnginesWithDuplicateIds() {
    JUnitException exception = assertThrows(JUnitException.class, () -> createLauncher(new DemoHierarchicalTestEngine("dummy id"), new DemoHierarchicalTestEngine("dummy id")));
    assertThat(exception).hasMessageContaining("multiple engines with the same ID");
}
Also used : JUnitException(org.junit.platform.commons.JUnitException) DemoHierarchicalTestEngine(org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine) Test(org.junit.jupiter.api.Test)

Example 3 with DemoHierarchicalTestEngine

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

the class DefaultLauncherTests method registerTestExecutionListenersWithNullArray.

@Test
void registerTestExecutionListenersWithNullArray() {
    DefaultLauncher launcher = createLauncher(new DemoHierarchicalTestEngine("dummy id"));
    PreconditionViolationException exception = assertThrows(PreconditionViolationException.class, () -> launcher.registerTestExecutionListeners((TestExecutionListener[]) null));
    assertThat(exception).hasMessageContaining("listeners array must not be null or empty");
}
Also used : DemoHierarchicalTestEngine(org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestEngine) PreconditionViolationException(org.junit.platform.commons.util.PreconditionViolationException) Test(org.junit.jupiter.api.Test)

Example 4 with DemoHierarchicalTestEngine

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

the class DefaultLauncherTests method launcherWillNotExecuteEnginesExplicitlyIncludedViaMultipleCompetingEngineFilters.

@Test
void launcherWillNotExecuteEnginesExplicitlyIncludedViaMultipleCompetingEngineFilters() {
    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"), includeEngines("second")).build());
    // @formatter:on
    assertThat(testPlan.getRoots()).isEmpty();
}
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)

Example 5 with DemoHierarchicalTestEngine

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

the class DefaultLauncherTests method launcherWillExecuteAllEnginesExplicitlyIncludedViaSingleEngineFilter.

@Test
void launcherWillExecuteAllEnginesExplicitlyIncludedViaSingleEngineFilter() {
    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", "second")).build());
    // @formatter:on
    assertThat(testPlan.getRoots()).hasSize(2);
}
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