public class ShouldBeEqual extends java.lang.Object implements AssertionErrorFactory
AssertionError indicating that an assertion that verifies that two objects are equal failed.
The built AssertionError's message differentiates actual and expected 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).
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.Object |
actual |
protected java.lang.Object |
expected |
| Modifier and Type | Method and 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
. |
static AssertionErrorFactory |
shouldBeEqual(java.lang.Object actual,
java.lang.Object expected,
ComparisonStrategy comparisonStrategy)
Creates a new
. |
protected final java.lang.Object actual
protected final java.lang.Object expected
public static AssertionErrorFactory shouldBeEqual(java.lang.Object actual, java.lang.Object expected)
ShouldBeEqual.actual - the actual value in the failed assertion.expected - the expected value in the failed assertion.AssertionErrorFactory.public static AssertionErrorFactory shouldBeEqual(java.lang.Object actual, java.lang.Object expected, ComparisonStrategy comparisonStrategy)
ShouldBeEqual.actual - the actual value in the failed assertion.expected - the expected value in the failed assertion.comparisonStrategy - the ComparisonStrategy used to compare actual with expected.AssertionErrorFactory.public java.lang.AssertionError newAssertionError(Description description)
AssertionError indicating that an assertion that verifies that two objects are equal failed.AssertionError message is built so that it differentiates actual and expected
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 and
expected 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 if Failures is configured to filter them (see
Failures.setRemoveFestRelatedElementsFromStackTrace(boolean)).newAssertionError in interface AssertionErrorFactorydescription - the description of the failed assertion.AssertionError.public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.ObjectCopyright © 2007–2018. All rights reserved.