Package org.junit
Class ComparisonFailure
- java.lang.Object
- java.lang.Throwable
- java.lang.Error
- java.lang.AssertionError
- org.junit.ComparisonFailure
- All Implemented Interfaces:
Serializable
public class ComparisonFailure extends AssertionError
Thrown when anassertEquals(String, String)
fails. Create and throw aComparisonFailure
manually if you want to show users the difference between two complex strings. Inspired by a patch from Alex Chaffee ([email protected])- Since:
- 4.0
- See Also:
- Serialized Form
Constructor Summary
Constructors Constructor Description ComparisonFailure(String message, String expected, String actual)
Constructs a comparison failure.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getActual()
Returns the actual string valueString
getExpected()
Returns the expected string valueString
getMessage()
Returns "..." in place of common prefix and "..." in place of common suffix between expected and actual.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
Constructor Detail
ComparisonFailure
public ComparisonFailure(String message, String expected, String actual)
Constructs a comparison failure.- Parameters:
message
- the identifying message or nullexpected
- the expected string valueactual
- the actual string value
Method Detail
getMessage
public String getMessage()
Returns "..." in place of common prefix and "..." in place of common suffix between expected and actual.- Overrides:
getMessage
in classThrowable
- See Also:
Throwable.getMessage()
getExpected
public String getExpected()
Returns the expected string value- Returns:
- the expected string value