Package org.fest.assertions.error
Class ShouldBeEqual
- java.lang.Object
-
- org.fest.assertions.error.ShouldBeEqual
-
- All Implemented Interfaces:
AssertionErrorFactory
public class ShouldBeEqual extends java.lang.Object implements AssertionErrorFactory
Creates an
indicating that an assertion that verifies that two objects are equal failed.AssertionError
The built
AssertionError
's message differentiatesactual
andexpected
description 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 boolean
equals(java.lang.Object o)
int
hashCode()
java.lang.AssertionError
newAssertionError(Description description)
static AssertionErrorFactory
shouldBeEqual(java.lang.Object actual, java.lang.Object expected)
Creates a new
.ShouldBeEqual
static AssertionErrorFactory
shouldBeEqual(java.lang.Object actual, java.lang.Object expected, ComparisonStrategy comparisonStrategy)
Creates a new
.ShouldBeEqual
-
-
-
Method Detail
-
shouldBeEqual
public static AssertionErrorFactory shouldBeEqual(java.lang.Object actual, java.lang.Object expected)
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(java.lang.Object actual, java.lang.Object expected, ComparisonStrategy comparisonStrategy)
Creates a new
.ShouldBeEqual
- Parameters:
actual
- the actual value in the failed assertion.expected
- the expected value in the failed assertion.comparisonStrategy
- theComparisonStrategy
used to compare actual with expected.- Returns:
- the created
AssertionErrorFactory
.
-
newAssertionError
public java.lang.AssertionError newAssertionError(Description description)
Creates an
indicating that an assertion that verifies that two objects are equal failed.AssertionError
The
message is built so that it differentiatesAssertionError
actual
andexpected
description 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
actual
andexpected
string representation were differents), this method will instead create a org.junit.ComparisonFailure that highlights the difference(s) between the expected and actual objects.AssertionError
stack trace won't show Fest related elements ifFailures
is configured to filter them (seeFailures.setRemoveFestRelatedElementsFromStackTrace(boolean)
).- Specified by:
newAssertionError
in interfaceAssertionErrorFactory
- Parameters:
description
- the description of the failed assertion.- Returns:
- the created
AssertionError
.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-