Search in sources :

Example 16 with AssertionFailedError

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

the class AssertTimeoutAssertionsTests method assertTimeoutWithMessageSupplierForSupplierThatCompletesAfterTheTimeout.

@Test
void assertTimeoutWithMessageSupplierForSupplierThatCompletesAfterTheTimeout() {
    AssertionFailedError error = assertThrows(AssertionFailedError.class, () -> {
        assertTimeout(ofMillis(10), () -> {
            nap();
            return "Tempus Fugit";
        }, () -> "Tempus" + " " + "Fugit");
    });
    assertMessageStartsWith(error, "Tempus Fugit ==> execution exceeded timeout of 10 ms by");
}
Also used : AssertionFailedError(org.opentest4j.AssertionFailedError)

Example 17 with AssertionFailedError

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

the class AssertDoesNotThrowAssertionsTests method assertDoesNotThrowWithExecutableThatThrowsACheckedException.

@Test
void assertDoesNotThrowWithExecutableThatThrowsACheckedException() {
    try {
        assertDoesNotThrow((Executable) () -> {
            throw new IOException();
        });
        expectAssertionFailedError();
    } catch (AssertionFailedError ex) {
        assertMessageEquals(ex, "Unexpected exception thrown: " + IOException.class.getName());
    }
}
Also used : IOException(java.io.IOException) AssertionFailedError(org.opentest4j.AssertionFailedError) AssertionTestUtils.expectAssertionFailedError(org.junit.jupiter.api.AssertionTestUtils.expectAssertionFailedError)

Example 18 with AssertionFailedError

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

the class AssertEqualsAssertionsTests method assertEqualsFloatWithDeltaWithUnequalValuesAndMessage.

@Test
void assertEqualsFloatWithDeltaWithUnequalValuesAndMessage() {
    Executable assertion = () -> assertEquals(0.5f, 0.45f, 0.03f, "message");
    AssertionFailedError e = assertThrows(AssertionFailedError.class, assertion);
    assertMessageStartsWith(e, "message");
    assertMessageEndsWith(e, "expected: <0.5> but was: <0.45>");
    assertExpectedAndActualValues(e, 0.5f, 0.45f);
}
Also used : Executable(org.junit.jupiter.api.function.Executable) AssertionFailedError(org.opentest4j.AssertionFailedError) AssertionTestUtils.expectAssertionFailedError(org.junit.jupiter.api.AssertionTestUtils.expectAssertionFailedError)

Example 19 with AssertionFailedError

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

the class AssertEqualsAssertionsTests method assertEqualsDoubleWithIllegalDelta.

@Test
void assertEqualsDoubleWithIllegalDelta() {
    AssertionFailedError e1 = assertThrows(AssertionFailedError.class, () -> assertEquals(1.1d, 1.11d, -0.5d));
    assertMessageEndsWith(e1, "positive delta expected but was: <-0.5>");
    AssertionFailedError e2 = assertThrows(AssertionFailedError.class, () -> assertEquals(.55d, .56d, -10.5d));
    assertMessageEndsWith(e2, "positive delta expected but was: <-10.5>");
    AssertionFailedError e3 = assertThrows(AssertionFailedError.class, () -> assertEquals(1.1d, 1.1d, Double.NaN));
    assertMessageEndsWith(e3, "positive delta expected but was: <NaN>");
}
Also used : AssertionFailedError(org.opentest4j.AssertionFailedError) AssertionTestUtils.expectAssertionFailedError(org.junit.jupiter.api.AssertionTestUtils.expectAssertionFailedError)

Example 20 with AssertionFailedError

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

the class AssertEqualsAssertionsTests method assertEqualsFloatWithDeltaWithUnequalValuesAndMessageSupplier.

@Test
void assertEqualsFloatWithDeltaWithUnequalValuesAndMessageSupplier() {
    Executable assertion = () -> assertEquals(0.5f, 0.45f, 0.03f, () -> "message");
    AssertionFailedError e = assertThrows(AssertionFailedError.class, assertion);
    assertMessageStartsWith(e, "message");
    assertMessageEndsWith(e, "expected: <0.5> but was: <0.45>");
    assertExpectedAndActualValues(e, 0.5f, 0.45f);
}
Also used : Executable(org.junit.jupiter.api.function.Executable) AssertionFailedError(org.opentest4j.AssertionFailedError) AssertionTestUtils.expectAssertionFailedError(org.junit.jupiter.api.AssertionTestUtils.expectAssertionFailedError)

Aggregations

AssertionFailedError (org.opentest4j.AssertionFailedError)140 Test (org.junit.jupiter.api.Test)67 AssertionTestUtils.expectAssertionFailedError (org.junit.jupiter.api.AssertionTestUtils.expectAssertionFailedError)12 AlertIntegrationTest (com.synopsys.integration.alert.util.AlertIntegrationTest)8 IOException (java.io.IOException)8 URI (java.net.URI)8 WithMockUser (org.springframework.security.test.context.support.WithMockUser)8 MockHttpServletRequestBuilder (org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder)8 Collectors (java.util.stream.Collectors)5 ThrowingCallable (org.assertj.core.api.ThrowableAssert.ThrowingCallable)4 GeneCentricEntry (org.uniprot.core.genecentric.GeneCentricEntry)4 GeneCentricDocument (org.uniprot.store.search.document.genecentric.GeneCentricDocument)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 SettingsProxyModel (com.synopsys.integration.alert.common.rest.model.SettingsProxyModel)3 Search (io.zulia.client.command.builder.Search)3 SearchResult (io.zulia.client.result.SearchResult)3 Assertions (org.junit.jupiter.api.Assertions)3 Order (org.junit.jupiter.api.Order)3 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)3 MultipleFailuresError (org.opentest4j.MultipleFailuresError)3