use of org.assertj.core.internal.TestDescription in project assertj-core by joel-costigliola.
the class ShouldBeEqualWithinPercentage_create_Test method should_create_error_message_with_double_percentage_displayed_as_int.
@Test
public void should_create_error_message_with_double_percentage_displayed_as_int() {
factory = shouldBeEqualWithinPercentage(12.0, 10.0, withPercentage(10.0), 2d);
String message = factory.create(new TestDescription("Test"));
assertThat(message).isEqualTo(format("[Test] %n" + "Expecting:%n" + " <12.0>%n" + "to be close to:%n" + " <10.0>%n" + "by less than 10%% but difference was 20.0%%.%n" + "(a difference of exactly 10%% being considered valid)"));
}
use of org.assertj.core.internal.TestDescription in project assertj-core by joel-costigliola.
the class ShouldBeEqualWithinPercentage_create_Test method should_create_error_message_with_int_percentage_displayed_as_int.
@Test
public void should_create_error_message_with_int_percentage_displayed_as_int() {
factory = shouldBeEqualWithinPercentage(12.0, 10.0, withPercentage(10), 2d);
String message = factory.create(new TestDescription("Test"));
assertThat(message).isEqualTo(format("[Test] %n" + "Expecting:%n" + " <12.0>%n" + "to be close to:%n" + " <10.0>%n" + "by less than 10%% but difference was 20.0%%.%n" + "(a difference of exactly 10%% being considered valid)"));
}
use of org.assertj.core.internal.TestDescription in project assertj-core by joel-costigliola.
the class ShouldBeEqualWithinPercentage_create_Test method should_create_error_message_with_percentage_as_double.
@Test
public void should_create_error_message_with_percentage_as_double() {
factory = shouldBeEqualWithinPercentage(12.0, 10.0, withPercentage(0.5), 2d);
String message = factory.create(new TestDescription("Test"));
assertThat(message).isEqualTo(format("[Test] %n" + "Expecting:%n" + " <12.0>%n" + "to be close to:%n" + " <10.0>%n" + "by less than 0.5%% but difference was 20.0%%.%n" + "(a difference of exactly 0.5%% being considered valid)"));
}
use of org.assertj.core.internal.TestDescription in project assertj-core by joel-costigliola.
the class ShouldBeSortedAccordingToComparator_create_Test method should_create_error_message_with_comparator.
@Test
public void should_create_error_message_with_comparator() {
ErrorMessageFactory factory = shouldBeSortedAccordingToGivenComparator(1, array("b", "c", "A"), new CaseInsensitiveStringComparator());
String message = factory.create(new TestDescription("Test"), new StandardRepresentation());
assertThat(message).isEqualTo(format("[Test] %ngroup is not sorted according to CaseInsensitiveStringComparator comparator because element 1:%n <\"c\">%nis not less or equal than element 2:%n <\"A\">%ngroup was:%n <[\"b\", \"c\", \"A\"]>"));
}
use of org.assertj.core.internal.TestDescription in project assertj-core by joel-costigliola.
the class Failures_failure_with_ErrorMessage_Test method should_use_ErrorMessage_when_overriding_error_message_is_not_specified.
@Test
public void should_use_ErrorMessage_when_overriding_error_message_is_not_specified() {
Description description = new TestDescription("description");
info.description(description);
when(errorMessage.create(description, info.representation())).thenReturn("[description] my message");
AssertionError failure = failures.failure(info, errorMessage);
assertThat(failure).hasMessage("[description] my message");
}
Aggregations