Skip to content

Please allow TestExecutionListeners to fail the test [SPR-3960] #8640

Closed
@spring-projects-issues

Description

@spring-projects-issues

Magnus Heino opened SPR-3960 and commented

SpringMethodRoadie.runAfters() calls all @After methods, then calls TestContextManager.afterTestMethod

TestContextManager.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:

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions