Skip to content

1.x 2.x Use IDE friendly assertion failed statements  #5249

@mtiidla

Description

@mtiidla

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions