1.x 2.x Use IDE friendly assertion failed statements
Currently the assertItem prints by the following statements, focus on "expected to be"
private void assertItem(T expected, int i) {
T actual = values.get(i);
if (expected == null) {
// check for null equality
if (actual != null) {
assertionError("Value at index: " + i + " expected to be [null] but was: [" + actual + "]\n");
}
} else if (!expected.equals(actual)) {
assertionError("Value at index: " + i
+ " expected to be [" + expected + "] (" + expected.getClass().getSimpleName()
+ ") but was: [" + actual + "] (" + (actual != null ? actual.getClass().getSimpleName() : "null") + ")\n");
}
}
However, it does not match any of the IntelliJ assertion regex patterns, thus making it very difficult to visually compare expected and actual values. We forked assertItem() using one of the following patterns from this and could immediately see the <Click to see difference> link in the IDE.
PR welcome.
@mtiidla is 2.x also affected?
@akarnokd Could you please choose the most pleasing pattern from the IntelliJ class I linked to? If you don't have any preference, then I would go with EXPECTED_BUT_WAS_PATTERN as JUnit4 is using it "expected:<" + expected + "> but was:<" + actual + ">"
@vanniktech The output is different, but also not recognized, for example the following code:
Observable.just("Test").test().assertValue("test");
produces: Expected: test (class: String), Actual: Test (class: String) and there is no link presented by IntelliJ to compare the output. (I have also edited the Issue title with 2.x)
The JUnit pattern is fine with me.