Skip to content

Document order of callback methods and extensions that run after test/container execution #1620

@apodkutin

Description

@apodkutin

Based on JUnit5 user-guide extensions execution order should correlate with extensions declaration order:

Extensions registered declaratively via @ExtendWith will be executed in the order in which they are declared in the source code. For example, the execution of tests in both MyFirstTests and MySecondTests will be extended by the FooExtension and BarExtension, in exactly that order.

But it does not.

Example: https://github.com/apodkutin/junit5-extensions-order-test/blob/master/src/test/java/junit5/extensions/order/JUnit5ExtensionsOrderTest.java

@ExtendWith({FirstExtension.class, SecondExtension.class})

Expected output

FirstExtension afterEach method call
SecondExtension afterEach method call

Actual output

SecondExtension afterEach method call
FirstExtension afterEach method call

Jupiter-api version is 5.3.1

<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.3.1</version>

Deliverables

  • Document the lack of explicit ordering for all user-supplied callback methods (i.e., @BeforeEach, @AfterEach, @BeforeAll, @AfterAll) declared within a single test class/interface.

    • in Javadoc
    • in User Guide
  • Document the lack of wrapping behavior for all user-supplied callback methods (e.g., @AfterAll, @AfterEach) declared within a single test class/interface.

    • in Javadoc
    • in User Guide
  • Document wrapping behavior for all user-supplied callback methods (i.e., @BeforeEach, @AfterEach, @BeforeAll, @AfterAll) within test class/interface hierarchies.

    • in Javadoc
    • in User Guide
  • Document wrapping behavior for all applicable extension APIs (e.g., TestExecutionExceptionHandler, AfterTestExecutionCallback, AfterEachCallback, AfterAllCallback, etc.).

    • in Javadoc
    • in User Guide

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions