-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Please allow TestExecutionListeners to fail the test [SPR-3960] #8640
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
Comments
Magnus Heino commented Please make SpringTestMethod and SpringMethodRoadie visible for external packages also, to make it possible to unittest custom testexecutionlisteners and annotations. |
Sam Brannen commented Hi Magnus, Thanks for the suggestion! The Spring TestContext Framework now allows 'before' and 'after' methods of
FYI: due to the "wrapped" nature of TestExecutionListener execution, you should For example, if you develop a CustomTestExecutionListener (CTEL) and configure Regards, Sam |
Sam Brannen commented Hi Magnus,
SpringTestMethod and SpringMethodRoadie constitute specific details of the Note that the TestContext Framework itself is completely agnostic of the What is keeping you from testing your code via the public APIs for TestContext, Thanks in advance for feedback. Regards, Sam |
Magnus Heino commented
Yes. I just tried my CTEL's with 2.5RC1, and I'm very happy about the current implementation. Thanks, /Magnus |
Magnus Heino opened SPR-3960 and commented
SpringMethodRoadie.runAfters() calls all
@After
methods, then calls TestContextManager.afterTestMethodTestContextManager.afterTestMethod calls all TestExecutionListeners. Any exception thrown in the TestExecutionListener is caught and logged by TestContextManager.afterTestMethod. This behaviour is good since it allows all TestExecutionListeners to execute even if one fails.
However, TestContextManager.afterTestMethod should be changed from void to boolean (or throw a custom exception). The returned value should indicate if any TestExecutionListener failed. If any TestExecutionListener failed, SpringMethodRoadie.runAfters() should then call SpringMethodRoadie.addFailure to fail the test.
I have extended TransactionalTestExecutionListener to look for
@DataSet
and@ExpectedDataSet
annotations.@DataSet
loads data using DBUnit before the test is executed, and@ExpectedDataSet
compares the data in the database after test execution with the expected result. It is not currently possible to fail the test in the TestExecutionListener, with the current behaviour described above.Please change this simple thing to make TestExecutionListeners even more powerful!
Affects: 2.1 M4
Issue Links:
The text was updated successfully, but these errors were encountered: