Search in sources :

Example 66 with EngineExecutionResults

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

the class ProgrammaticExtensionRegistrationTests method assertClassFails.

private void assertClassFails(Class<?> testClass, Condition<Throwable> causeCondition) {
    EngineExecutionResults executionResults = executeTestsForClass(testClass);
    executionResults.containerEvents().assertThatEvents().haveExactly(1, finishedWithFailure(causeCondition));
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults)

Example 67 with EngineExecutionResults

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

the class BeforeAndAfterTestExecutionCallbackTests method beforeAndAfterTestExecutionCallbacksDeclaredOnSuperclassAndSubclass.

@Test
void beforeAndAfterTestExecutionCallbacksDeclaredOnSuperclassAndSubclass() {
    EngineExecutionResults executionResults = executeTestsForClass(ChildTestCase.class);
    assertEquals(1, executionResults.testEvents().started().count(), "# tests started");
    assertEquals(1, executionResults.testEvents().succeeded().count(), "# tests succeeded");
    assertEquals(0, executionResults.testEvents().skipped().count(), "# tests skipped");
    assertEquals(0, executionResults.testEvents().aborted().count(), "# tests aborted");
    assertEquals(0, executionResults.testEvents().failed().count(), "# tests failed");
    // @formatter:off
    assertEquals(asList("fooBeforeTestExecutionCallback", "barBeforeTestExecutionCallback", "testChild", "barAfterTestExecutionCallback", "fooAfterTestExecutionCallback"), callSequence, "wrong call sequence");
// @formatter:on
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) Test(org.junit.jupiter.api.Test)

Example 68 with EngineExecutionResults

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

the class BeforeAndAfterTestExecutionCallbackTests method beforeAndAfterTestExecutionCallbacksDeclaredOnInterfaceAndClass.

@Test
void beforeAndAfterTestExecutionCallbacksDeclaredOnInterfaceAndClass() {
    EngineExecutionResults executionResults = executeTestsForClass(TestInterfaceTestCase.class);
    assertEquals(2, executionResults.testEvents().started().count(), "# tests started");
    assertEquals(2, executionResults.testEvents().succeeded().count(), "# tests succeeded");
    assertEquals(0, executionResults.testEvents().skipped().count(), "# tests skipped");
    assertEquals(0, executionResults.testEvents().aborted().count(), "# tests aborted");
    assertEquals(0, executionResults.testEvents().failed().count(), "# tests failed");
    // @formatter:off
    assertEquals(asList(// Test Interface
    "fooBeforeTestExecutionCallback", "barBeforeTestExecutionCallback", "defaultTestMethod", "barAfterTestExecutionCallback", "fooAfterTestExecutionCallback", // Test Class
    "fooBeforeTestExecutionCallback", "barBeforeTestExecutionCallback", "localTestMethod", "barAfterTestExecutionCallback", "fooAfterTestExecutionCallback"), callSequence, "wrong call sequence");
// @formatter:on
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) Test(org.junit.jupiter.api.Test)

Example 69 with EngineExecutionResults

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

the class BeforeAndAfterTestExecutionCallbackTests method testMethodThrowsAnException.

@Test
void testMethodThrowsAnException() {
    EngineExecutionResults executionResults = executeTestsForClass(ExceptionInTestMethodTestCase.class);
    assertEquals(1, executionResults.testEvents().started().count(), "# tests started");
    assertEquals(0, executionResults.testEvents().succeeded().count(), "# tests succeeded");
    assertEquals(0, executionResults.testEvents().skipped().count(), "# tests skipped");
    assertEquals(0, executionResults.testEvents().aborted().count(), "# tests aborted");
    assertEquals(1, executionResults.testEvents().failed().count(), "# tests failed");
    // @formatter:off
    assertEquals(asList("beforeEachMethod", "fooBeforeTestExecutionCallback", // throws an exception.
    "test", "fooAfterTestExecutionCallback", "afterEachMethod"), callSequence, "wrong call sequence");
    // @formatter:on
    assertNotNull(actualExceptionInAfterTestExecution, "test exception");
    assertTrue(actualExceptionInAfterTestExecution.isPresent(), "test exception should be present");
    assertEquals(EnigmaException.class, actualExceptionInAfterTestExecution.get().getClass());
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) Test(org.junit.jupiter.api.Test)

Example 70 with EngineExecutionResults

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

the class BeforeAndAfterTestExecutionCallbackTests method beforeAndAfterTestExecutionCallbacks.

@Test
void beforeAndAfterTestExecutionCallbacks() {
    EngineExecutionResults executionResults = executeTestsForClass(OuterTestCase.class);
    assertEquals(2, executionResults.testEvents().started().count(), "# tests started");
    assertEquals(2, executionResults.testEvents().succeeded().count(), "# tests succeeded");
    assertEquals(0, executionResults.testEvents().skipped().count(), "# tests skipped");
    assertEquals(0, executionResults.testEvents().aborted().count(), "# tests aborted");
    assertEquals(0, executionResults.testEvents().failed().count(), "# tests failed");
    // @formatter:off
    assertEquals(asList(// OuterTestCase
    "beforeEachMethodOuter", "fooBeforeTestExecutionCallback", "barBeforeTestExecutionCallback", "testOuter", "barAfterTestExecutionCallback", "fooAfterTestExecutionCallback", "afterEachMethodOuter", // InnerTestCase
    "beforeEachMethodOuter", "beforeEachMethodInner", "fooBeforeTestExecutionCallback", "barBeforeTestExecutionCallback", "fizzBeforeTestExecutionCallback", "testInner", "fizzAfterTestExecutionCallback", "barAfterTestExecutionCallback", "fooAfterTestExecutionCallback", "afterEachMethodInner", "afterEachMethodOuter"), callSequence, "wrong call sequence");
// @formatter:on
}
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