Skip to content

Introduce before/after test execution callbacks in the TestContext framework [SPR-4365] #9043

Closed
@spring-projects-issues

Description

@spring-projects-issues

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

  1. Introduce before/after test execution callbacks in the TestExecutionListener API.
  2. Introduce before/after test execution callbacks in TestContextManager.
  3. Introduce before/after test execution support in the SpringJUnit4ClassRunner.
  4. Introduce before/after test execution support in the SpringExtension for JUnit 5.
  5. Introduce before/after test execution support in AbstractTestNGSpringContextTests.
  6. Document that before/after test execution callbacks cannot be supported with JUnit 4 Rules.
  7. Introduce appropriate integration tests for the SpringJUnit4ClassRunner, the SpringExtension, and AbstractTestNGSpringContextTests.

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:

Issue Links:

Referenced from: commits 087efa6, 833dead, f7f37cd, 6efb166, 80018c6, fd00840, 3da5fbe, da89332, 5302566

3 votes, 4 watchers

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions