Search in sources :

Example 16 with TestAbortedException

use of org.opentest4j.TestAbortedException in project cucumber-jvm by cucumber.

the class RerunFormatterTest method should_leave_report_empty_when_exit_code_is_zero.

@Test
void should_leave_report_empty_when_exit_code_is_zero() {
    Feature feature = TestFeatureParser.parse("classpath:path/test.feature", "" + "Feature: feature name\n" + "  Scenario: passed scenario\n" + "    Given passed step\n" + "  Scenario: skipped scenario\n" + "    Given skipped step\n");
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Runtime.builder().withFeatureSupplier(new StubFeatureSupplier(feature)).withAdditionalPlugins(new RerunFormatter(out)).withBackendSupplier(new StubBackendSupplier(new StubStepDefinition("passed step"), new StubStepDefinition("skipped step", new TestAbortedException()))).build().run();
    assertThat(out, isBytesEqualTo(""));
}
Also used : StubBackendSupplier(io.cucumber.core.runtime.StubBackendSupplier) StubFeatureSupplier(io.cucumber.core.runtime.StubFeatureSupplier) TestAbortedException(org.opentest4j.TestAbortedException) StubStepDefinition(io.cucumber.core.backend.StubStepDefinition) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Feature(io.cucumber.core.gherkin.Feature) Test(org.junit.jupiter.api.Test)

Example 17 with TestAbortedException

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

the class EpollSocketChannelConfigTest method testRandomTcpNotSentLowAt.

@Test
public void testRandomTcpNotSentLowAt() {
    final long expected = randLong(0, 0xFFFFFFFFL);
    final long actual;
    try {
        ch.config().setTcpNotSentLowAt(expected);
        actual = ch.config().getTcpNotSentLowAt();
    } catch (RuntimeException e) {
        throw new TestAbortedException("assumeNoException", e);
    }
    assertEquals(expected, actual);
}
Also used : TestAbortedException(org.opentest4j.TestAbortedException) RepeatedIfExceptionsTest(io.github.artsok.RepeatedIfExceptionsTest) Test(org.junit.jupiter.api.Test)

Example 18 with TestAbortedException

use of org.opentest4j.TestAbortedException in project GDSC-SMLM by aherbert.

the class HelpUrlsTest method canReachUrls.

/**
 * Connects to the online documentation, downloads the pages and tests the links and anchors are
 * reachable.
 *
 * @throws TestAbortedException the test aborted exception
 */
@Test
void canReachUrls() throws TestAbortedException {
    // Test we are online
    Assumptions.assumeTrue(testInternetAvailable());
    // Iterate all the URLs and test we can connect.
    // URLs may have anchor tags so build the pages and all their anchors.
    final HashMap<String, Set<String>> pages = new HashMap<>();
    HelpUrls.forEach((k, v) -> {
        // Strip anchor tags
        final int index = v.indexOf('#');
        if (index < 0) {
            pages.computeIfAbsent(v, key -> new HashSet<>());
        } else {
            final String page = v.substring(0, index);
            final String anchor = v.substring(index + 1);
            pages.computeIfAbsent(page, key -> new HashSet<>()).add(anchor);
        }
    });
    // Obtain each page. Then download the page html and check the named anchor tag exists.
    pages.forEach((page, anchors) -> {
        // Use Jsoup library to get the HTML as a document...
        final Document doc = connectToUrl(page);
        anchors.forEach(anchor -> {
            final Elements e = doc.select("a[href=#" + anchor + "]");
            Assertions.assertTrue(e.size() > 0, () -> "Missing " + page + "#" + anchor);
        });
    });
}
Also used : Socket(java.net.Socket) Properties(java.util.Properties) TestAbortedException(org.opentest4j.TestAbortedException) Set(java.util.Set) IOException(java.io.IOException) HashMap(java.util.HashMap) InetSocketAddress(java.net.InetSocketAddress) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test) Assumptions(org.junit.jupiter.api.Assumptions) Document(org.jsoup.nodes.Document) Assertions(org.junit.jupiter.api.Assertions) Jsoup(org.jsoup.Jsoup) Elements(org.jsoup.select.Elements) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) Document(org.jsoup.nodes.Document) Elements(org.jsoup.select.Elements) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 19 with TestAbortedException

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

the class StandaloneTests method testOnJava8.

@Test
@Order(3)
void testOnJava8() throws IOException {
    var result = // 
    Request.builder().setTool(// 
    new Java()).setJavaHome(// 
    Helper.getJavaHome("8").orElseThrow(TestAbortedException::new)).setProject(// 
    "standalone").addArguments(// 
    "--show-version").addArguments(// 
    "-enableassertions").addArguments(// 
    "-Djava.util.logging.config.file=logging.properties").addArguments("-jar", // 
    MavenRepo.jar("junit-platform-console-standalone")).addArguments(// 
    "--scan-class-path").addArguments(// 
    "--disable-banner").addArguments("--include-classname", // 
    "standalone.*").addArguments("--classpath", "bin").build().run(false);
    assertEquals(1, result.getExitCode(), String.join("\n", result.getOutputLines("out")));
    var workspace = Request.WORKSPACE.resolve("standalone");
    var expectedOutLines = Files.readAllLines(workspace.resolve("expected-out.txt"));
    var expectedErrLines = Files.readAllLines(workspace.resolve("expected-err.txt"));
    assertLinesMatch(expectedOutLines, result.getOutputLines("out"));
    assertLinesMatch(expectedErrLines, result.getOutputLines("err"));
    var jupiterVersion = Helper.version("junit-jupiter-engine");
    var vintageVersion = Helper.version("junit-vintage-engine");
    assertTrue(result.getOutput("err").contains("junit-jupiter" + " (group ID: org.junit.jupiter, artifact ID: junit-jupiter-engine, version: " + jupiterVersion));
    assertTrue(result.getOutput("err").contains("junit-vintage" + " (group ID: org.junit.vintage, artifact ID: junit-vintage-engine, version: " + vintageVersion));
}
Also used : Java(de.sormuras.bartholdy.tool.Java) TestAbortedException(org.opentest4j.TestAbortedException) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 20 with TestAbortedException

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

the class ExceptionHandlingTests method failureInAfterAllTakesPrecedenceOverTestAbortedExceptionInBeforeAll.

@Test
void failureInAfterAllTakesPrecedenceOverTestAbortedExceptionInBeforeAll() {
    FailureTestCase.exceptionToThrowInBeforeAll = Optional.of(new TestAbortedException("aborted"));
    FailureTestCase.exceptionToThrowInAfterAll = Optional.of(new IOException("checked"));
    EngineExecutionResults executionResults = executeTests(selectMethod(FailureTestCase.class, "succeedingTest"));
    // 
    executionResults.allEvents().assertEventsMatchExactly(// 
    event(engine(), started()), // 
    event(container(FailureTestCase.class), started()), event(container(FailureTestCase.class), finishedWithFailure(instanceOf(IOException.class), message("checked"), // 
    suppressed(0, instanceOf(TestAbortedException.class), message("aborted")))), event(engine(), finishedSuccessfully()));
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) TestAbortedException(org.opentest4j.TestAbortedException) IOException(java.io.IOException) 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