Search in sources :

Example 21 with TestAbortedException

use of org.opentest4j.TestAbortedException in project junit5 by junit-team.

the class SubclassedAssumptionsTests method assumeFalseWithBooleanTrue.

@Test
void assumeFalseWithBooleanTrue() {
    TestAbortedException exception = assertThrows(TestAbortedException.class, () -> assumeFalse(true));
    assertEquals("Assumption failed: assumption is not false", exception.getMessage());
}
Also used : TestAbortedException(org.opentest4j.TestAbortedException) Test(org.junit.jupiter.api.Test)

Example 22 with TestAbortedException

use of org.opentest4j.TestAbortedException in project junit5 by junit-team.

the class HierarchicalTestExecutorTests method exceptionInAfterIsReportedInsteadOfEarlierTestAbortedException.

@Test
void exceptionInAfterIsReportedInsteadOfEarlierTestAbortedException() throws Exception {
    var child = spy(new MyLeaf(UniqueId.root("leaf", "leaf")));
    Exception exceptionInExecute = new TestAbortedException("execute");
    Exception exceptionInAfter = new RuntimeException("after");
    doThrow(exceptionInExecute).when(child).execute(eq(rootContext), any());
    doThrow(exceptionInAfter).when(child).after(eq(rootContext));
    root.addChild(child);
    var inOrder = inOrder(listener, child);
    executor.execute();
    var childExecutionResult = ArgumentCaptor.forClass(TestExecutionResult.class);
    inOrder.verify(child).execute(eq(rootContext), any());
    inOrder.verify(child).after(eq(rootContext));
    inOrder.verify(listener).executionFinished(eq(child), childExecutionResult.capture());
    assertThat(childExecutionResult.getValue().getStatus()).isEqualTo(FAILED);
    assertThat(childExecutionResult.getValue().getThrowable().get()).isSameAs(exceptionInAfter).hasSuppressedException(exceptionInExecute);
}
Also used : TestAbortedException(org.opentest4j.TestAbortedException) TestAbortedException(org.opentest4j.TestAbortedException) Test(org.junit.jupiter.api.Test)

Aggregations

TestAbortedException (org.opentest4j.TestAbortedException)22 Test (org.junit.jupiter.api.Test)16 RepeatedIfExceptionsTest (io.github.artsok.RepeatedIfExceptionsTest)3 TestExecutionResult (org.junit.platform.engine.TestExecutionResult)3 Java (de.sormuras.bartholdy.tool.Java)2 StubStepDefinition (io.cucumber.core.backend.StubStepDefinition)2 Feature (io.cucumber.core.gherkin.Feature)2 StubBackendSupplier (io.cucumber.core.runtime.StubBackendSupplier)2 StubFeatureSupplier (io.cucumber.core.runtime.StubFeatureSupplier)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 Properties (java.util.Properties)2 Order (org.junit.jupiter.api.Order)2 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)2 InOrder (org.mockito.InOrder)2 Session (com.datastax.driver.core.Session)1 TimeServiceEventBus (io.cucumber.core.runtime.TimeServiceEventBus)1 Result (io.cucumber.plugin.event.Result)1 TestCaseFinished (io.cucumber.plugin.event.TestCaseFinished)1 TestCaseStarted (io.cucumber.plugin.event.TestCaseStarted)1