-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Throw ComparisonFailure rather than AssertionError for all equals methods #1416
Comments
We would most likely do this by integrating with https://github.com/ota4j-team/opentest4j but we need some changes there so JUnit4 can use those APIs. See ota4j-team/opentest4j#27 |
Incidentally, the reason why this isn't so simple is you might get an exception when calling |
wow ,I want to learn,but it can't load .can you send me resoure to load the Junit4.Thanks |
my email [email protected]. |
We could put catches around the |
I'd like to propose a change that I think would make the
assertEquals
methods easier to work with - apologies if I've missed something.When a test fails in Eclipse with
assertEquals()
and the parameters are not strings, anAssertionError
is thrown. This gives a backtrace, but to see what was not equal, I have to copy and paste out the error into another editor to read the top line. Here's a screen shot:It would be great if could throw a
ComparisonFailure
. I'd still see pretty much the same failure trace:but I'd be about to double click it/click the "Compare with Expected Results" button and get this:
which would be a tremendous help to my work flow.
When looking into this I did think surely Eclipse could do something better, but I don't think it can. An
AssertionError
doesn't have the expected and actual results. They are thrown away by the call tofailNotEquals
which calls 'format' that then concatenates a single string to pass toAssertionError
So looking at
assertEquals
forObject
's could we just do away with theinstanceof
checks?The text was updated successfully, but these errors were encountered: