Search in sources :

Example 16 with TestDescription

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)"));
}
Also used : TestDescription(org.assertj.core.internal.TestDescription) Test(org.junit.Test)

Example 17 with TestDescription

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)"));
}
Also used : TestDescription(org.assertj.core.internal.TestDescription) Test(org.junit.Test)

Example 18 with TestDescription

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)"));
}
Also used : TestDescription(org.assertj.core.internal.TestDescription) Test(org.junit.Test)

Example 19 with TestDescription

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\"]>"));
}
Also used : CaseInsensitiveStringComparator(org.assertj.core.util.CaseInsensitiveStringComparator) TestDescription(org.assertj.core.internal.TestDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 20 with TestDescription

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");
}
Also used : Description(org.assertj.core.description.Description) TestDescription(org.assertj.core.internal.TestDescription) TestDescription(org.assertj.core.internal.TestDescription) Test(org.junit.Test)

Aggregations

TestDescription (org.assertj.core.internal.TestDescription)126 Test (org.junit.Test)112 StandardRepresentation (org.assertj.core.presentation.StandardRepresentation)48 URI (java.net.URI)27 URL (java.net.URL)24 CompletableFuture (java.util.concurrent.CompletableFuture)9 Before (org.junit.Before)9 Description (org.assertj.core.description.Description)4 Path (java.nio.file.Path)2 EmptyTextDescription.emptyDescription (org.assertj.core.description.EmptyTextDescription.emptyDescription)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 AtomicStampedReference (java.util.concurrent.atomic.AtomicStampedReference)1 ShouldHaveToString.shouldHaveToString (org.assertj.core.error.ShouldHaveToString.shouldHaveToString)1 Representation (org.assertj.core.presentation.Representation)1 CaseInsensitiveStringComparator (org.assertj.core.util.CaseInsensitiveStringComparator)1