Search in sources :

Example 21 with EngineExecutionResults

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

the class StandardTestClassTests method moreThanOneTestClassIsExecuted.

@Test
void moreThanOneTestClassIsExecuted() {
    LauncherDiscoveryRequest request = request().selectors(selectClass(FirstOfTwoTestCases.class), selectClass(SecondOfTwoTestCases.class)).build();
    EngineExecutionResults executionResults = executeTests(request);
    Events containers = executionResults.containerEvents();
    Events tests = executionResults.testEvents();
    assertEquals(6, tests.started().count(), "# tests started");
    assertEquals(5, tests.succeeded().count(), "# tests succeeded");
    assertEquals(1, tests.failed().count(), "# tests failed");
    assertEquals(3, containers.started().count(), "# containers started");
    assertEquals(3, containers.finished().count(), "# containers finished");
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) Events(org.junit.platform.testkit.engine.Events) Test(org.junit.jupiter.api.Test)

Example 22 with EngineExecutionResults

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

the class StandardTestClassTests method testsFailWhenAfterEachFails.

@Test
void testsFailWhenAfterEachFails() {
    EngineExecutionResults executionResults = executeTestsForClass(TestCaseWithFailingAfter.class);
    Events containers = executionResults.containerEvents();
    Events tests = executionResults.testEvents();
    assertEquals(1, tests.started().count(), "# tests started");
    assertEquals(0, tests.succeeded().count(), "# tests succeeded");
    assertEquals(1, tests.failed().count(), "# tests failed");
    assertEquals(2, containers.started().count(), "# containers started");
    assertEquals(2, containers.finished().count(), "# containers finished");
    assertTrue(TestCaseWithFailingAfter.testExecuted, "test executed?");
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) Events(org.junit.platform.testkit.engine.Events) Test(org.junit.jupiter.api.Test)

Example 23 with EngineExecutionResults

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

the class StandardTestClassTests method testsFailWhenBeforeEachFails.

@Test
void testsFailWhenBeforeEachFails() {
    EngineExecutionResults executionResults = executeTestsForClass(TestCaseWithFailingBefore.class);
    Events containers = executionResults.containerEvents();
    Events tests = executionResults.testEvents();
    assertEquals(2, tests.started().count(), "# tests started");
    assertEquals(0, tests.succeeded().count(), "# tests succeeded");
    assertEquals(2, tests.failed().count(), "# tests failed");
    assertEquals(2, containers.started().count(), "# containers started");
    assertEquals(2, containers.finished().count(), "# containers finished");
    assertEquals(2, TestCaseWithFailingBefore.countBefore, "# before each calls");
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) Events(org.junit.platform.testkit.engine.Events) Test(org.junit.jupiter.api.Test)

Example 24 with EngineExecutionResults

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

the class TestInstanceLifecycleConfigurationTests method performAssertions.

private void performAssertions(Class<?> testClass, Map<String, String> configParams, int numContainers, int numFailedContainers, int numTests, String... methods) {
    // @formatter:off
    EngineExecutionResults executionResults = executeTests(request().selectors(selectClass(testClass)).configurationParameters(configParams).build());
    // @formatter:on
    // 
    executionResults.containerEvents().assertStatistics(stats -> stats.started(numContainers).finished(numContainers).failed(numFailedContainers));
    // 
    executionResults.testEvents().assertStatistics(stats -> stats.started(numTests).finished(numTests));
    assertEquals(Arrays.asList(methods), methodsInvoked);
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults)

Example 25 with EngineExecutionResults

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

the class DisabledTests method executeTestsWithDisabledTestClass.

@Test
void executeTestsWithDisabledTestClass() {
    EngineExecutionResults results = executeTestsForClass(DisabledTestClassTestCase.class);
    results.containerEvents().assertStatistics(stats -> stats.skipped(1));
    results.testEvents().assertStatistics(stats -> stats.started(0));
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) Test(org.junit.jupiter.api.Test)

Aggregations

EngineExecutionResults (org.junit.platform.testkit.engine.EngineExecutionResults)139 Test (org.junit.jupiter.api.Test)134 LauncherDiscoveryRequest (org.junit.platform.launcher.LauncherDiscoveryRequest)32 DynamicTest (org.junit.jupiter.api.DynamicTest)30 DynamicTest.dynamicTest (org.junit.jupiter.api.DynamicTest.dynamicTest)30 Events (org.junit.platform.testkit.engine.Events)27 DisplayName (org.junit.jupiter.api.DisplayName)15 RepeatedTest (org.junit.jupiter.api.RepeatedTest)15 IOException (java.io.IOException)12 Execution (org.junit.platform.testkit.engine.Execution)12 TimeoutException (java.util.concurrent.TimeoutException)10 List (java.util.List)8 ExtensionConfigurationException (org.junit.jupiter.api.extension.ExtensionConfigurationException)8 ArrayList (java.util.ArrayList)7 AfterAll (org.junit.jupiter.api.AfterAll)7 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)7 BeforeAll (org.junit.jupiter.api.BeforeAll)7 BeforeEach (org.junit.jupiter.api.BeforeEach)7 Nested (org.junit.jupiter.api.Nested)7 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)7