Exception message improvements
Brought to you by:
tammofreese
Take this code:
public class EasyMockMessages {
interface ISomething { public int someOperation(String s); } @Test public void someTest() throws Exception { ISomething something = EasyMock.createMock(ISomething.class); EasyMock.expect(something.someOperation("hello")).andReturn(42); EasyMock.replay(something); something.someOperation("hello\t"); }
}
This gives the following error now
java.lang.AssertionError:
Unexpected method call someOperation("hello "):
someOperation("hello"): expected: 1, actual: 0
This error could be more helpful by:
- Using a ComparisonFailure exception which would allow to compare the actual and expected method in a Result Comparison Diff in Eclipse IDE (ComparisonFailure still allows a custom plain text message, fake screenshot attached)
- Having the text "Expected method call" in front of the 3rd line (I think this would clarify the message)
- Quoting special characters as "\t", "\n" to make tiny but important differences regarding "invisible" characters visible
ComparisonFailure for EasyMock?