Search in sources :

Example 11 with Execution

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

the class TimeoutExtensionTests method appliesTimeoutOnAnnotatedBeforeAllMethods.

@Test
@DisplayName("is applied on annotated @BeforeAll methods")
void appliesTimeoutOnAnnotatedBeforeAllMethods() {
    EngineExecutionResults results = executeTests(// 
    request().selectors(// 
    selectClass(TimeoutAnnotatedBeforeAllMethodTestCase.class)).configurationParameter(DEFAULT_BEFORE_ALL_METHOD_TIMEOUT_PROPERTY_NAME, // 
    "42ns").build());
    Execution execution = findExecution(results.containerEvents(), TimeoutAnnotatedBeforeAllMethodTestCase.class.getSimpleName());
    // 
    assertThat(execution.getDuration()).isGreaterThanOrEqualTo(// 
    Duration.ofMillis(10)).isLessThan(Duration.ofSeconds(1));
    // 
    assertThat(execution.getTerminationInfo().getExecutionResult().getThrowable().orElseThrow()).isInstanceOf(// 
    TimeoutException.class).hasMessage("setUp() timed out after 10 milliseconds");
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) Execution(org.junit.platform.testkit.engine.Execution) TimeoutException(java.util.concurrent.TimeoutException) RepeatedTest(org.junit.jupiter.api.RepeatedTest) DynamicTest.dynamicTest(org.junit.jupiter.api.DynamicTest.dynamicTest) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 12 with Execution

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

the class TimeoutExtensionTests method appliesTimeoutOnAnnotatedAfterAllMethods.

@Test
@DisplayName("is applied on annotated @AfterAll methods")
void appliesTimeoutOnAnnotatedAfterAllMethods() {
    EngineExecutionResults results = executeTests(// 
    request().selectors(// 
    selectClass(TimeoutAnnotatedAfterAllMethodTestCase.class)).configurationParameter(DEFAULT_AFTER_ALL_METHOD_TIMEOUT_PROPERTY_NAME, // 
    "42ns").build());
    Execution execution = findExecution(results.containerEvents(), TimeoutAnnotatedAfterAllMethodTestCase.class.getSimpleName());
    // 
    assertThat(execution.getDuration()).isGreaterThanOrEqualTo(// 
    Duration.ofMillis(10)).isLessThan(Duration.ofSeconds(1));
    // 
    assertThat(execution.getTerminationInfo().getExecutionResult().getThrowable().orElseThrow()).isInstanceOf(// 
    TimeoutException.class).hasMessage("tearDown() timed out after 10 milliseconds");
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) Execution(org.junit.platform.testkit.engine.Execution) TimeoutException(java.util.concurrent.TimeoutException) RepeatedTest(org.junit.jupiter.api.RepeatedTest) DynamicTest.dynamicTest(org.junit.jupiter.api.DynamicTest.dynamicTest) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

DisplayName (org.junit.jupiter.api.DisplayName)12 DynamicTest (org.junit.jupiter.api.DynamicTest)12 DynamicTest.dynamicTest (org.junit.jupiter.api.DynamicTest.dynamicTest)12 RepeatedTest (org.junit.jupiter.api.RepeatedTest)12 Test (org.junit.jupiter.api.Test)12 EngineExecutionResults (org.junit.platform.testkit.engine.EngineExecutionResults)12 Execution (org.junit.platform.testkit.engine.Execution)12 TimeoutException (java.util.concurrent.TimeoutException)10 PreconditionViolationException (org.junit.platform.commons.PreconditionViolationException)1