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

Add support for test lifecycle events in TestExecutionListener #618

Closed
ehborisov opened this issue Dec 26, 2016 · 11 comments
Closed

Add support for test lifecycle events in TestExecutionListener #618

ehborisov opened this issue Dec 26, 2016 · 11 comments

Comments

@ehborisov
Copy link

ehborisov commented Dec 26, 2016

Now there's no ability to track invocations of Before/After methods with TestExecutionListener, we need it there to be able to link test invocations with all corresponding fixtures and their timings in the reporting tool (Allure). Extensions are not entirely a solution for that, since we want to track events around fixture, one callback on the finish is not enough. And also registering such an extension via annotations everywhere would be quite clumsy.

Related Issues

@sbrannen sbrannen changed the title Modify TestExecutionListener to track events for test fixtures Add support for test lifecycle events in TestExecutionListener Dec 26, 2016
@sbrannen
Copy link
Member

Changed title to reflect terminology used in JUnit Jupiter.

@sbrannen
Copy link
Member

Is the proposal here intended to replace #542?

@baev
Copy link
Contributor

baev commented Dec 26, 2016

I think that is much better to have engine-independent listener for base test events such as TestGroupStarted/Finished TestFixtureStarted/Finished and TestCaseStarted/Finished

@sbrannen
Copy link
Member

Please keep in mind that the JUnit Platform and JUnit Jupiter do not have groups, fixtures, or cases.

Thus, we will need to use terminology in line with containers, tests, and lifecycle events.

@ehborisov
Copy link
Author

What @baev wrote about TestGroupStarted/Finished TestCaseStarted/Finished is basically a question of splitting general executionStarted/executionFinished events in TestExecutionListener into separate events for containers and for tests, at least as I got it, which is a slightly different discussion. Though it would simplify things a bit, I agree.

What is needed at the least is engine independent lifecycle events support (specifically, something to determine both start and finish of BeforeAll, BeforeEach, AfterAll, AfterEach for tests run with Jupiter engine as well as for Before, BeforeClass, After, AfterClass for tests run with Vintage engine).
This has little in common with what is proposed in #542

@ehborisov
Copy link
Author

ehborisov commented Jan 15, 2017

Any updates? @sbrannen

@marcphilipp
Copy link
Member

@ehborisov @baev Since M4 you can register extensions via ServiceLoader (see http://junit.org/junit5/docs/current/user-guide/#extensions-registration-automatic). Can you please try and check if the lifecycle callbacks (see http://junit.org/junit5/docs/current/user-guide/#extensions-lifecycle-callbacks) are sufficient for your use case?

@baev
Copy link
Contributor

baev commented Jun 17, 2017

Nope. We need to have around callbacks for all user code that executed during test execution, including configuration methods (@BeforeAll, @BeforeEach etc) and even test data generation methods for parameterized tests

@marcphilipp
Copy link
Member

marcphilipp commented Jun 17, 2017

Have you looked at http://junit.org/junit5/docs/current/user-guide/#extensions-execution-order? There's a lifecycle callback around all test class methods except test data generation methods.

In case that's really not sufficient, we could add a generic method to TestExecutionListener, e.g.

void executionEvent(Event event)

However, I'm not sure what events we need and which information needs to be contained in such events. Can you propose a list of events/event types, possible as a sequence diagram that includes the existing TestExecutionListener methods?

@stale
Copy link

stale bot commented May 13, 2021

This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. Thank you for your contribution.

@stale stale bot added the status: stale label May 13, 2021
@stale
Copy link

stale bot commented Jun 3, 2021

This issue has been automatically closed due to inactivity. If you have a good use case for this feature, please feel free to reopen the issue.

@stale stale bot closed this as completed Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants