-
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
Assumptions don't work in tests with expected exceptions #121
Comments
It would also be nice if ExpectException didn't wrap AssertionError. I would expect the following test to fail with an AssertionError, but it fails with an Exception instead:
The stack trace is: java.lang.Exception: Unexpected exception, expected<java.lang.UnsupportedOperationException> but was<java.lang.AssertionError> |
The same problem appears when using rules instead. This fails, but should probably succeed:
In this case, it is easy to move the assumption above the expect, but that is not possible when using @test(expected = xxx.class). |
The introductory issue is a duplicate of issue #98 and is already fixed in 4.9. |
An AssumptionViolatedException thrown by the Statement is rethrown. Therefore tests are ignored if assume... fails, regardless whether an expected exception is thrown or not. Fix junit-team#121. Thanks to petur for discovering this bug.
An AssertionError thrown by the Statement is rethrown. Therefore tests fail because of the AssertionError and not because of a wrong expected exception. Fix junit-team#121. Thanks to petur for discovering this bug.
ExpectedException rule no longer handles AssertionErrors and AssumptionViolatedExceptions by default. This means that the rule doesn't intercept if your test fails because of an violated assertion or assumption. If you want to test assertions or assumptions you have to tell the rule to handle such exceptions via handleAssertionErrors() or handleAssumptionViolatedExceptions().
I fixed ExpectedException to work with assume and don't wrap AssertionErrors. AssertionErrors are still wrapped if you're using the expected=Foo.class notation. Please use ExpectedException to avoid wrapping. |
Fixes junit-team#687. junit-team#121 is still fixed. (Pull request junit-team#323 was too rigid.)
Fixes junit-team#687. junit-team#121 is still fixed. (Pull request junit-team#323 was too rigid.)
Fixes junit-team#687. junit-team#121 is still fixed. (Pull request junit-team#323 was too rigid.)
Fixes junit-team#687. junit-team#121 is still fixed. (Pull request junit-team#323 was too rigid.)
Still fixes junit-team#121, but the original fix was superfluous. Added documentation about handling assumes and asserts in conjunction with the ExpectedException rule.
Still fixes junit-team#121, but the original fix was superfluous. Added documentation about handling assumes and asserts in conjunction with the ExpectedException rule.
Still fixes junit-team#121, but the original fix was superfluous. Added documentation about handling assumes and asserts in conjunction with the ExpectedException rule.
Still fixes junit-team#121, but the original fix was superfluous. Added documentation about handling assumes and asserts in conjunction with the ExpectedException rule.
Still fixes junit-team#121, but the original fix was superfluous. Added documentation about handling assumes and asserts in conjunction with the ExpectedException rule.
Still fixes junit-team#121, but the original fix was superfluous. Added documentation about handling assumes and asserts in conjunction with the ExpectedException rule.
Still fixes junit-team#121, but the original fix was superfluous. Added documentation about handling assumes and asserts in conjunction with the ExpectedException rule.
This class's behaviour changed in JUnit 4.12 (mainly due to junit-team/junit4#121). Bring across the fix, and its tests, along with class reformatting.
This class's behaviour changed in JUnit 4.12 (mainly due to junit-team/junit4#121). Bring across the fix, and its tests, along with class reformatting.
The following test should be ignored, but fails with JUnit 4.8.2:
This test succeeds if run with @RunWith(JUnit4ClassRunner.class). The reason it works with the older runner, but fails with the new runner seems to be that org.junit.internal.runners.MethodRoadie.runTestMethod() has special handling for AssumptionViolatedException, but this handling is missing from org.junit.internal.runners.statements.ExpectException.evaluate().
The text was updated successfully, but these errors were encountered: