use of org.opentest4j.AssertionFailedError in project assertj-core by assertj.
the class DefaultAssertionErrorCollector_Test method decorated_AssertionFailedError_should_not_have_null_actual_and_expected_values_when_not_populated.
@Test
void decorated_AssertionFailedError_should_not_have_null_actual_and_expected_values_when_not_populated() {
// GIVEN
AssertionError error = new AssertionFailedError("boom");
defaultAssertionErrorCollector.collectAssertionError(error);
// WHEN
AssertionError decoratedError = defaultAssertionErrorCollector.assertionErrorsCollected().get(0);
// THEN
then(decoratedError).isInstanceOf(AssertionFailedError.class).hasMessageContainingAll(error.getMessage(), "(DefaultAssertionErrorCollector_Test.java:69)");
AssertionFailedError decoratedAssertionFailedError = (AssertionFailedError) decoratedError;
then(decoratedAssertionFailedError.isActualDefined()).isFalse();
then(decoratedAssertionFailedError.isExpectedDefined()).isFalse();
}
use of org.opentest4j.AssertionFailedError in project assertj-core by assertj.
the class AbstractAssert_failWithActualExpectedAndMessage_Test method should_keep_specific_error_message_and_description_set_by_user.
@Test
void should_keep_specific_error_message_and_description_set_by_user() {
// WHEN
AssertionFailedError afe = expectAssertionFailedError(() -> assertion.as("test context").overridingErrorMessage("my %d errors %s", 5, "!").failWithActualExpectedAndMessage(actual, expected, "%d %s", 5, "time"));
// THEN
then(afe).hasMessage("[test context] my 5 errors !");
then(afe.getActual().getEphemeralValue()).isSameAs(actual);
then(afe.getExpected().getEphemeralValue()).isSameAs(expected);
}
use of org.opentest4j.AssertionFailedError in project assertj-core by assertj.
the class AbstractAssert_failWithActualExpectedAndMessage_Test method should_fail_with_simple_message.
@Test
void should_fail_with_simple_message() {
// WHEN
AssertionFailedError afe = expectAssertionFailedError(() -> assertion.failWithActualExpectedAndMessage(actual, expected, "fail"));
// THEN
then(afe).hasMessage("fail");
then(afe.getActual().getEphemeralValue()).isSameAs(actual);
then(afe.getExpected().getEphemeralValue()).isSameAs(expected);
}
use of org.opentest4j.AssertionFailedError in project assertj-core by assertj.
the class AbstractAssert_failWithActualExpectedAndMessage_Test method should_keep_description_set_by_user.
@Test
void should_keep_description_set_by_user() {
// WHEN
AssertionFailedError afe = expectAssertionFailedError(() -> assertion.as("user description").failWithActualExpectedAndMessage(actual, expected, "fail %d %s", 5, "times"));
// THEN
then(afe).hasMessage("[user description] fail 5 times");
then(afe.getActual().getEphemeralValue()).isSameAs(actual);
then(afe.getExpected().getEphemeralValue()).isSameAs(expected);
}
use of org.opentest4j.AssertionFailedError in project assertj-core by assertj.
the class OptionalIntAssert_hasValue_Test method should_fail_if_OptionalInt_does_not_have_expected_value.
@Test
void should_fail_if_OptionalInt_does_not_have_expected_value() {
// GIVEN
OptionalInt actual = OptionalInt.of(5);
int expectedValue = 10;
// WHEN
AssertionFailedError error = catchThrowableOfType(() -> assertThat(actual).hasValue(expectedValue), AssertionFailedError.class);
// THEN
assertThat(error).hasMessage(shouldContain(actual, expectedValue).create());
assertThat(error.getActual().getStringRepresentation()).isEqualTo(String.valueOf(actual.getAsInt()));
assertThat(error.getExpected().getStringRepresentation()).isEqualTo(String.valueOf(expectedValue));
}
Aggregations