-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Fix for issue #687: handle AssertionErrors and AssumptionViolatedExceptions by default again #711
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
Conversation
Sounds good to me. @stefanbirkner, one last chance to argue we should maintain the 4.11 behavior, rather than reverting to 4.10's behavior? |
I changed the name of one of the test classes but now I see that the old name better reflects what is tested.
@dsaff @stefanbirkner I added another commit that just changes of the name of one of the test classes because the renaming I did while implementing this pull request made no sense (but I only realised this today :-/) |
AssertionError and AssumptionViolatedException are two exceptions, which are used by JUnit to influence the test run. An AssertionError signals the JUnit framework that an assertion does not apply to the current test. An AssumptionViolatedException signals the JUnit framework that it should skip a test. The ExpectedException rule handles exceptions but IMHO it should not handle AssertionError and AssumptionViolatedException because this intercepts the messaging between the test and the JUnit framework. AssumptionViolatedException The following test should be skipped (like in JUnit 4.11):
But the following test should be successful, because someone explicitly tests for AssumptionViolatedException:
AssertionError The following test should fail because of 'just another reason' (like in JUnit 4.11):
But the following test should run successful, because someone explicitly tests for AssertionError:
Fix |
The fix is already done. I still revise the documentation of ExpectedException. Hopefully it will be finished on Monday. |
It's done. See #720. |
@stefanbirkner, sorry, it's been a busy couple of weeks. I think what we want is a situation in which ExpectedException catches all exceptions, and evaluates them against its matcher. If the exception matches its expectation, it returns normally (the test passes). If the exception does not match its expectation, then it throws something:
(Optionally, we could create a method that would allow customization of which exceptions fall into category #1 and #2) This would seem to simultaneously resolve the desires in bug #687 and also #121. Have I convinced everyone? :-) |
@stefanbirkner, ah, yes, you're right. I overskimmed #720. I'll comment more there. |
I think #720 completely supersedes this one now. |
Thanks for re-starting the discussion--it was really valuable. |
Change the default behaviour of the
ExpectedException
rule back to handlingAssertionError
s andAssumptionViolatedException
s by default to fix issue #687, i.e. one does not have to callExpectedException#handleAssertionErrors()
orExpectedException#handleAssumptionViolatedExceptions()
to make the rule handle those exceptions.