Search in sources :

Example 6 with TestAbortedException

use of org.opentest4j.TestAbortedException in project netty by netty.

the class KQueueSocketChannelConfigTest method testRandomSndLowAt.

@Test
public void testRandomSndLowAt() {
    final int expected = Math.min(BSD_SND_LOW_AT_MAX, Math.abs(rand.nextInt()));
    final int actual;
    try {
        ch.config().setSndLowAt(expected);
        actual = ch.config().getSndLowAt();
    } catch (RuntimeException e) {
        throw new TestAbortedException("assumeNoException", e);
    }
    assertEquals(expected, actual);
}
Also used : TestAbortedException(org.opentest4j.TestAbortedException) Test(org.junit.jupiter.api.Test)

Example 7 with TestAbortedException

use of org.opentest4j.TestAbortedException in project spock by spockframework.

the class PendingFeatureBaseInterceptor method testAborted.

protected TestAbortedException testAborted(StackTraceElement[] stackTrace) {
    TestAbortedException testAbortedException = new TestAbortedException("Feature not yet implemented correctly." + ("".equals(reason) ? "" : " Reason: " + reason));
    testAbortedException.setStackTrace(stackTrace);
    return testAbortedException;
}
Also used : TestAbortedException(org.opentest4j.TestAbortedException)

Example 8 with TestAbortedException

use of org.opentest4j.TestAbortedException in project zipkin by openzipkin.

the class KafkaExtension method prepareTopics.

void prepareTopics(String topics, int partitions) {
    Properties config = new Properties();
    config.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServer());
    List<NewTopic> newTopics = new ArrayList<>();
    for (String topic : topics.split(",")) {
        if ("".equals(topic))
            continue;
        newTopics.add(new NewTopic(topic, partitions, (short) 1));
    }
    try (AdminClient adminClient = AdminClient.create(config)) {
        adminClient.createTopics(newTopics).all().get();
    } catch (InterruptedException | ExecutionException e) {
        if (e.getCause() != null && e.getCause() instanceof TopicExistsException)
            return;
        throw new TestAbortedException("Topics could not be created " + newTopics + ": " + e.getMessage(), e);
    }
}
Also used : ArrayList(java.util.ArrayList) TestAbortedException(org.opentest4j.TestAbortedException) NewTopic(org.apache.kafka.clients.admin.NewTopic) Properties(java.util.Properties) ExecutionException(java.util.concurrent.ExecutionException) TopicExistsException(org.apache.kafka.common.errors.TopicExistsException) AdminClient(org.apache.kafka.clients.admin.AdminClient)

Example 9 with TestAbortedException

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

the class HierarchicalTestExecutorTests method abortInContainerBeforeAll.

@Test
void abortInContainerBeforeAll() throws Exception {
    MyContainer child = spy(new MyContainer(UniqueId.root("container", "child container")));
    root.addChild(child);
    TestAbortedException anAbortedException = new TestAbortedException("in BeforeAll");
    when(root.before(rootContext)).thenThrow(anAbortedException);
    InOrder inOrder = inOrder(listener, root, child);
    executor.execute();
    ArgumentCaptor<TestExecutionResult> rootExecutionResult = ArgumentCaptor.forClass(TestExecutionResult.class);
    inOrder.verify(root).prepare(rootContext);
    inOrder.verify(root).shouldBeSkipped(rootContext);
    inOrder.verify(listener).executionStarted(root);
    inOrder.verify(root).before(rootContext);
    inOrder.verify(root).after(rootContext);
    inOrder.verify(listener).executionFinished(eq(root), rootExecutionResult.capture());
    assertThat(rootExecutionResult.getValue().getStatus()).isEqualTo(ABORTED);
    assertThat(rootExecutionResult.getValue().getThrowable()).containsSame(anAbortedException);
    verifyNoMoreInteractions(child);
}
Also used : InOrder(org.mockito.InOrder) TestAbortedException(org.opentest4j.TestAbortedException) TestExecutionResult(org.junit.platform.engine.TestExecutionResult) Test(org.junit.jupiter.api.Test)

Example 10 with TestAbortedException

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

the class HierarchicalTestExecutorTests method abortInLeafExecute.

@Test
void abortInLeafExecute() throws Exception {
    MyLeaf child = spy(new MyLeaf(UniqueId.root("leaf", "leaf")));
    TestAbortedException anAbortedException = new TestAbortedException("in test");
    when(child.execute(eq(rootContext), any())).thenThrow(anAbortedException);
    root.addChild(child);
    InOrder inOrder = inOrder(listener, root, child);
    executor.execute();
    ArgumentCaptor<TestExecutionResult> childExecutionResult = ArgumentCaptor.forClass(TestExecutionResult.class);
    inOrder.verify(listener).executionStarted(root);
    inOrder.verify(root).before(rootContext);
    inOrder.verify(listener).executionStarted(child);
    inOrder.verify(child).execute(eq(rootContext), any());
    inOrder.verify(listener).executionFinished(eq(child), childExecutionResult.capture());
    inOrder.verify(root).after(rootContext);
    inOrder.verify(listener).executionFinished(eq(root), any(TestExecutionResult.class));
    assertThat(childExecutionResult.getValue().getStatus()).isEqualTo(ABORTED);
    assertThat(childExecutionResult.getValue().getThrowable()).containsSame(anAbortedException);
}
Also used : InOrder(org.mockito.InOrder) TestAbortedException(org.opentest4j.TestAbortedException) TestExecutionResult(org.junit.platform.engine.TestExecutionResult) 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