use of org.opentest4j.AssertionFailedError in project scylla by bptlab.
the class TestUtils method getAttribute.
public static Object getAttribute(Object o, String attributeName) {
try {
Field field = getFieldNamed(o.getClass(), attributeName);
field.setAccessible(true);
return field.get(o);
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
throw new AssertionFailedError("Attribute " + attributeName + " in class named " + o.getClass().getSimpleName() + " was not found.");
}
}
use of org.opentest4j.AssertionFailedError in project scylla by bptlab.
the class TestUtils method assertAttribute.
public static void assertAttribute(Object o, String attributeName, Object expectedValue) {
try {
Object actualValue = getAttribute(o, attributeName);
assertEquals(expectedValue, actualValue);
} catch (SecurityException | IllegalArgumentException e) {
throw new AssertionFailedError("Could not validate attribute " + attributeName + " in class named " + o.getClass().getSimpleName() + ": Not existent or not accessible!", e);
}
}
use of org.opentest4j.AssertionFailedError in project junit5 by junit-team.
the class AssertTimeoutAssertionsTests method assertTimeoutPreemptivelyForExecutableThatCompletesAfterTheTimeout.
@Test
void assertTimeoutPreemptivelyForExecutableThatCompletesAfterTheTimeout() {
AssertionFailedError error = assertThrows(AssertionFailedError.class, () -> assertTimeoutPreemptively(PREEMPTIVE_TIMEOUT, this::waitForInterrupt));
assertMessageEquals(error, "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 assertTimeoutPreemptivelyWithMessageSupplierForSupplierThatCompletesAfterTheTimeout.
@Test
void assertTimeoutPreemptivelyWithMessageSupplierForSupplierThatCompletesAfterTheTimeout() {
AssertionFailedError error = assertThrows(AssertionFailedError.class, () -> {
assertTimeoutPreemptively(PREEMPTIVE_TIMEOUT, () -> {
waitForInterrupt();
return "Tempus Fugit";
}, () -> "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 assertTimeoutForSupplierThatCompletesAfterTheTimeout.
@Test
void assertTimeoutForSupplierThatCompletesAfterTheTimeout() {
AssertionFailedError error = assertThrows(AssertionFailedError.class, () -> {
assertTimeout(ofMillis(10), () -> {
nap();
return "Tempus Fugit";
});
});
assertMessageStartsWith(error, "execution exceeded timeout of 10 ms by");
}
Aggregations