Search in sources :

Example 46 with EngineExecutionResults

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

the class LifecycleMethodExecutionExceptionHandlerTests method classLevelExceptionHandlersConvertException.

@Test
void classLevelExceptionHandlersConvertException() {
    LauncherDiscoveryRequest request = request().selectors(selectClass(ConvertingTestCase.class)).build();
    EngineExecutionResults executionResults = executeTests(request);
    assertEquals(1, ConvertExceptionHandler.beforeAllCalls, "Exception should handled in @BeforeAll");
    assertEquals(1, ConvertExceptionHandler.afterAllCalls, "Exception should handled in @AfterAll");
    // 
    executionResults.allEvents().assertEventsMatchExactly(// 
    event(engine(), started()), // 
    event(container(ConvertingTestCase.class), started()), // 
    event(container(ConvertingTestCase.class), finishedWithFailure(instanceOf(IOException.class))), event(engine(), finishedSuccessfully()));
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) IOException(java.io.IOException) Test(org.junit.jupiter.api.Test)

Example 47 with EngineExecutionResults

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

the class LifecycleMethodExecutionExceptionHandlerTests method multipleHandlersAreCalledInOrder.

@Test
void multipleHandlersAreCalledInOrder() {
    LauncherDiscoveryRequest request = request().selectors(selectClass(MultipleHandlersTestCase.class)).build();
    EngineExecutionResults executionResults = executeTests(request);
    // 
    executionResults.allEvents().assertEventsMatchExactly(// 
    event(engine(), started()), // 
    event(container(MultipleHandlersTestCase.class), started()), // 
    event(test("aTest"), started()), // 
    event(test("aTest"), finishedSuccessfully()), // 
    event(test("aTest2"), started()), // 
    event(test("aTest2"), finishedSuccessfully()), // 
    event(container(MultipleHandlersTestCase.class), finishedSuccessfully()), // 
    event(engine(), finishedSuccessfully()));
    assertEquals(Arrays.asList(// BeforeAll chain (class level only)
    "RethrowExceptionBeforeAll", "SwallowExceptionBeforeAll", // BeforeEach chain for aTest (test + class level)
    "ConvertExceptionBeforeEach", "RethrowExceptionBeforeEach", "SwallowExceptionBeforeEach", // AfterEach chain for aTest  (test + class level)
    "ConvertExceptionAfterEach", "RethrowExceptionAfterEach", "SwallowExceptionAfterEach", // BeforeEach chain for aTest2 (class level only)
    "RethrowExceptionBeforeEach", "SwallowExceptionBeforeEach", // AfterEach chain for aTest2 (class level only)
    "RethrowExceptionAfterEach", "SwallowExceptionAfterEach", // 
    "RethrowExceptionAfterAll", // 
    "SwallowExceptionAfterAll"), handlerCalls, "Wrong order of handler calls");
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) Test(org.junit.jupiter.api.Test)

Example 48 with EngineExecutionResults

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

the class ParameterResolverTests method constructorInjectionWithAnnotatedParameter.

@Test
void constructorInjectionWithAnnotatedParameter() {
    EngineExecutionResults executionResults = executeTestsForClass(AnnotatedParameterConstructorInjectionTestCase.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");
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) Test(org.junit.jupiter.api.Test)

Example 49 with EngineExecutionResults

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

the class ParameterResolverTests method executeTestsForPrimitiveIntegerMethodInjectionCases.

@Test
void executeTestsForPrimitiveIntegerMethodInjectionCases() {
    EngineExecutionResults executionResults = executeTestsForClass(PrimitiveIntegerMethodInjectionTestCase.class);
    assertEquals(1, executionResults.testEvents().started().count(), "# tests started");
    assertEquals(1, executionResults.testEvents().succeeded().count(), "# tests succeeded");
    assertEquals(0, executionResults.testEvents().failed().count(), "# tests failed");
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) Test(org.junit.jupiter.api.Test)

Example 50 with EngineExecutionResults

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

the class ParameterResolverTests method executeTestsForMethodInjectionInBeforeAndAfterEachMethods.

@Test
void executeTestsForMethodInjectionInBeforeAndAfterEachMethods() {
    EngineExecutionResults executionResults = executeTestsForClass(BeforeAndAfterMethodInjectionTestCase.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");
}
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