use of org.opentest4j.AssertionFailedError in project junit5 by junit-team.
the class AssertTimeoutAssertionsTests method assertTimeoutPreemptivelyWithMessageSupplierForExecutableThatCompletesAfterTheTimeout.
@Test
void assertTimeoutPreemptivelyWithMessageSupplierForExecutableThatCompletesAfterTheTimeout() {
AssertionFailedError error = assertThrows(AssertionFailedError.class, () -> assertTimeoutPreemptively(PREEMPTIVE_TIMEOUT, this::waitForInterrupt, () -> "Tempus" + " " + "Fugit"));
assertMessageEquals(error, "Tempus Fugit ==> execution timed out after " + PREEMPTIVE_TIMEOUT.toMillis() + " ms");
assertMessageStartsWith(error.getCause(), "Execution timed out in ");
assertStackTraceContains(error.getCause().getStackTrace(), "CountDownLatch", "await");
}
use of org.opentest4j.AssertionFailedError in project junit5 by junit-team.
the class AssertTimeoutAssertionsTests method assertTimeoutForSupplierThatThrowsAnAssertionFailedError.
@Test
void assertTimeoutForSupplierThatThrowsAnAssertionFailedError() {
AssertionFailedError exception = assertThrows(AssertionFailedError.class, () -> {
assertTimeout(ofMillis(500), () -> {
fail("enigma");
return "Tempus Fugit";
});
});
assertMessageEquals(exception, "enigma");
}
use of org.opentest4j.AssertionFailedError in project junit5 by junit-team.
the class AssertTimeoutAssertionsTests method assertTimeoutForExecutableThatCompletesAfterTheTimeout.
@Test
void assertTimeoutForExecutableThatCompletesAfterTheTimeout() {
AssertionFailedError error = assertThrows(AssertionFailedError.class, () -> assertTimeout(ofMillis(10), this::nap));
assertMessageStartsWith(error, "execution exceeded timeout of 10 ms by");
}
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());
}
}
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>");
}
Aggregations