Skip to content
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

Use "wrap" semantics for started/finished and opened/closed listener event pairs #3082

Closed
mnovak1 opened this issue Nov 4, 2022 · 0 comments · Fixed by #3117
Closed

Use "wrap" semantics for started/finished and opened/closed listener event pairs #3082

mnovak1 opened this issue Nov 4, 2022 · 0 comments · Fixed by #3117

Comments

@mnovak1
Copy link

mnovak1 commented Nov 4, 2022

If multiple TestExecutionListeners are registered (for example Listener1 and Listener2) then it's expected that Listener1.testPlanExecutionStarted() is started first and then Listener2.testPlanExecutionStarted() as second.

However the same order is applied to testPlanExecutionFinished(). So Listener1.testPlanExecutionFinished() is called first and Listener2.testPlanExecutionFinished() is second. This is counter intuitive for example how @BeforeAll and @AfterAll behave extensions (more info in #1620)

Current behavior is:

TestExecutionListener1.testPlanExecutionStarted 
TestExecutionListener2.testPlanExecutionStarted 
 Extension1.beforeEach()
 Extension2.beforeEach()
--> TestClass.test()
 Extension2.afterEach()
 Extension1.afterEach()
TestExecutionListener1.testPlanExecutionFinished
TestExecutionListener2.testPlanExecutionFinished

but expected is:

TestExecutionListener1.testPlanExecutionStarted 
TestExecutionListener2.testPlanExecutionStarted 
 Extension1.beforeEach()
 Extension2.beforeEach()
--> TestClass.test()
 Extension2.afterEach()
 Extension1.afterEach()
TestExecutionListener2.testPlanExecutionFinished
TestExecutionListener1.testPlanExecutionFinished

Version: JUnit 5.9.1

Steps to reproduce

Register 2 TestExecutionListeners with implemented testPlanExecutionStarted() and testPlanExecutionFinished() and check the order.

@marcphilipp marcphilipp self-assigned this Dec 16, 2022
@marcphilipp marcphilipp added this to the 5.9.2 milestone Dec 16, 2022
marcphilipp added a commit that referenced this issue Dec 30, 2022
To allow for multiple listeners that depend on each other to be called
in an order consistent with Jupiter's lifecycle callbacks.

Issue: #3082
@marcphilipp marcphilipp changed the title Execution order of registered TestExecutionListener.testPlanExecutionFinished is not reverted in comparison to TestExecutionListener.testPlanExecutionStarted Use "wrap" semantics for started/finished and opened/closed listener event pairs Dec 30, 2022
@marcphilipp marcphilipp modified the milestones: 5.9.2, 5.10.0, 5.10.0-M1 Jan 6, 2023
marcphilipp added a commit that referenced this issue Jan 10, 2023
To allow for multiple listeners that depend on each other to be called
in an order consistent with Jupiter's lifecycle callbacks.

Issue: #3082
marcphilipp added a commit that referenced this issue Jan 10, 2023
To allow for multiple listeners that depend on each other to be called
in an order consistent with Jupiter's lifecycle callbacks.

Issue: #3082
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment