Package org.junit
Class ComparisonFailure
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Error
-
- java.lang.AssertionError
-
- org.junit.ComparisonFailure
-
- All Implemented Interfaces:
java.io.Serializable
public class ComparisonFailure extends java.lang.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 (alex@purpletech.com)- Since:
- 4.0
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
ComparisonFailure.ComparisonCompactor
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
fActual
private java.lang.String
fExpected
private static int
MAX_CONTEXT_LENGTH
The maximum length for expected and actual strings.private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description ComparisonFailure(java.lang.String message, java.lang.String expected, java.lang.String actual)
Constructs a comparison failure.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getActual()
Returns the actual string valuejava.lang.String
getExpected()
Returns the expected string valuejava.lang.String
getMessage()
Returns "..." in place of common prefix and "..." in place of common suffix between expected and actual.
-
-
-
Field Detail
-
MAX_CONTEXT_LENGTH
private static final int MAX_CONTEXT_LENGTH
The maximum length for expected and actual strings. If it is exceeded, the strings should be shortened.
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
fExpected
private java.lang.String fExpected
-
fActual
private java.lang.String fActual
-
-
Method Detail
-
getMessage
public java.lang.String getMessage()
Returns "..." in place of common prefix and "..." in place of common suffix between expected and actual.- Overrides:
getMessage
in classjava.lang.Throwable
- See Also:
Throwable.getMessage()
-
getActual
public java.lang.String getActual()
Returns the actual string value- Returns:
- the actual string value
-
getExpected
public java.lang.String getExpected()
Returns the expected string value- Returns:
- the expected string value
-
-