Package org.assertj.core.error
Class ShouldBeEqual
- java.lang.Object
-
- org.assertj.core.error.ShouldBeEqual
-
- All Implemented Interfaces:
AssertionErrorFactory
public class ShouldBeEqual extends Object implements AssertionErrorFactory
Creates anindicating that an assertion that verifies that two objects are equal failed.AssertionErrorThe built
AssertionError's message differentiatesactualandexpecteddescription if their string representation are the same (e.g. 42 float and 42 double). It also mentions the comparator in case of a custom comparator is used (instead of equals method).- Author:
- Alex Ruiz, Yvonne Wang, Joel Costigliola
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)inthashCode()AssertionErrornewAssertionError(Description description, Representation representation)Creates anindicating that an assertion that verifies that two objects are equal failed.AssertionError
Themessage is built so that it differentiatesAssertionErroractualandexpecteddescription in case their string representation are the same (like 42 float and 42 double).static AssertionErrorFactoryshouldBeEqual(Object actual, Object expected, ComparisonStrategy comparisonStrategy, Representation representation)Creates a new.ShouldBeEqualstatic AssertionErrorFactoryshouldBeEqual(Object actual, Object expected, Representation representation)Creates a new.ShouldBeEqual
-
-
-
Method Detail
-
shouldBeEqual
public static AssertionErrorFactory shouldBeEqual(Object actual, Object expected, Representation representation)
Creates a new.ShouldBeEqual- Parameters:
actual- the actual value in the failed assertion.expected- the expected value in the failed assertion.- Returns:
- the created
AssertionErrorFactory.
-
shouldBeEqual
public static AssertionErrorFactory shouldBeEqual(Object actual, Object expected, ComparisonStrategy comparisonStrategy, Representation representation)
Creates a new.ShouldBeEqual- Parameters:
actual- the actual value in the failed assertion.expected- the expected value in the failed assertion.comparisonStrategy- theComparisonStrategyused to compare actual with expected.- Returns:
- the created
AssertionErrorFactory.
-
newAssertionError
public AssertionError newAssertionError(Description description, Representation representation)
Creates anindicating that an assertion that verifies that two objects are equal failed.AssertionError
Themessage is built so that it differentiatesAssertionErroractualandexpecteddescription in case their string representation are the same (like 42 float and 42 double).If JUnit 4 is in the classpath and the description is standard (no comparator was used and
actualandexpectedstring representation were different), this method will instead create a org.junit.ComparisonFailure that highlights the difference(s) between the expected and actual objects.AssertionErrorstack trace won't show AssertJ related elements ifFailuresis configured to filter them (seeFailures.setRemoveAssertJRelatedElementsFromStackTrace(boolean)).- Specified by:
newAssertionErrorin interfaceAssertionErrorFactory- Parameters:
description- the description of the failed assertion.representation-- Returns:
- the created
AssertionError.
-
-