Description
Filip Neven opened SPR-4365 and commented
Objective
Consider providing additional callback hooks in the TestExecutionListener
API for enabling more fine-grained integration with third-party testing frameworks (e.g., Unitils) and custom testing code.
Building Block for JUnit 5 Support
Adding these new callbacks will also enabled Spring to support the new BeforeTestExecutionCallback
and AfterTestExecutionCallback
APIs in JUnit 5's Jupiter extension model.
Deliverables
- Introduce before/after test execution callbacks in the
TestExecutionListener
API. - Introduce before/after test execution callbacks in
TestContextManager
. - Introduce before/after test execution support in the
SpringJUnit4ClassRunner
. - Introduce before/after test execution support in the
SpringExtension
for JUnit 5. - Introduce before/after test execution support in
AbstractTestNGSpringContextTests
. - Document that before/after test execution callbacks cannot be supported with JUnit 4 Rules.
- Introduce appropriate integration tests for the
SpringJUnit4ClassRunner
, theSpringExtension
, andAbstractTestNGSpringContextTests
.
Comments from Original Poster
Unitils is an open source testing project, offering features such as integration with dbunit, test database maintenance and support for mock objects.
The core of Unitils works in a similar fashion as the spring testcontext framework, with a testlistener that provides callbacks during the execution of tests. It's also been implemented for Junit 3.8, Junit 4 and TestNG.An adaptor could be written that translates spring's listener calls into unitils listener calls. Such an adaptor could be easily implemented as an org.springframework.test.context.TestExecutionListener. However, unitils' listener system currently offers more hooks than spring's. Therefore we'd like to see spring's framework extended to add callbacks directly before and directly after executing the test method (after executing the
@Before
and before executing the@After
methods).
Affects: 2.5.1
Attachments:
- springTestcontextUnitilsIntegration.txt (38.38 kB)
Issue Links:
- Introduce support for JUnit 5 in the TestContext framework [SPR-13575] #18151 Introduce support for JUnit 5 in the TestContext framework ("is depended on by")
- Introduce a TestExecutionListener for DbUnit [SPR-6593] #11259 Introduce a TestExecutionListener for DbUnit
- Please allow TestExecutionListeners to fail the test [SPR-3960] #8640 Please allow TestExecutionListeners to fail the test
Referenced from: commits 087efa6, 833dead, f7f37cd, 6efb166, 80018c6, fd00840, 3da5fbe, da89332, 5302566
3 votes, 4 watchers