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

Provide mechanism to order the sequence of @Before* and @After* lifecycle methods #87

Closed
yogurtearl opened this issue Jan 5, 2016 · 8 comments

Comments

@yogurtearl
Copy link

It would be great to allow explicit control of ordering things such as @BeforeEach, @AfterEach, @BeforeAll, @AfterAll, and extensions.

My use case from JUnit 4 is that I have a WireMock instance that I want to shutdown via @Rule after some other @Rule's.

@yogurtearl
Copy link
Author

Just noticed there is RuleChain. https://github.com/junit-team/junit/wiki/Rules#rulechain

@sbrannen
Copy link
Member

sbrannen commented Jan 5, 2016

This issue is closely related to #13.

@sbrannen sbrannen changed the title Ordering of @Before, @After, @Rule Provide mechanism to order the sequence of @Before*/@After* methods Jan 5, 2016
@sbrannen sbrannen added this to the M1 milestone Jan 5, 2016
@jlink
Copy link
Contributor

jlink commented Feb 4, 2016

I think it could be rather easily solved by having a position property in the @Before/AfterEach/All annotations. This would allow to use the existion Position values (e.g. OUTERMOST, INNERMOST, INSIDE, OUTSIDE). A relative position would require more work.

@bechte
Copy link
Contributor

bechte commented Feb 4, 2016 via email

@jlink
Copy link
Contributor

jlink commented Feb 4, 2016

Before/After annotations are already implemented as extension points.

2016-02-04 17:55 GMT+01:00 Stefan Bechtold [email protected]:

I believe that this is a different use-case here. We should not mix
extensions and the Before/After annotations. Also, I am still very unhappy
with these limited positions.

So for this use-case it might be better to allow explicit ordering for the
test writer. This is related to the Scenario testing we already discussed.
Thoughts?


Reply to this email directly or view it on GitHub
#87 (comment).

@bechte
Copy link
Contributor

bechte commented Feb 5, 2016

Before/After annotations are already implemented as extension points.

We used the extension point registry internally, but this is different to the test writer. Before/After are not extension points themselves. IMO providing an order (like we are discussing to provide for Scenario Testing) would be both: Easier and more consistent to the test writer.

@jlink
Copy link
Contributor

jlink commented Feb 5, 2016

I need to see a concrete use case to get a feeling for what would be a good approach. Can you think of one?

Am 05.02.2016 um 06:38 schrieb Stefan Bechtold [email protected]:

Before/After annotations are already implemented as extension points.

We used the extension point registry internally, but this is different to the test writer. Before/After are not extension points themselves. IMO providing an order (like we are discussing to provide for Scenario Testing) would be both: Easier and more consistent to the test writer.


Reply to this email directly or view it on GitHub.

@marcphilipp
Copy link
Member

If we will add a feature to ensure the order of before/after/test methods it will be in the context of scenario tests (cf. #48).

@sbrannen sbrannen closed this as not planned Won't fix, can't repro, duplicate, stale May 5, 2023
@sbrannen sbrannen removed this from the 5.0 M1 milestone May 5, 2023
@sbrannen sbrannen changed the title Provide mechanism to order the sequence of @Before*/@After* methods Provide mechanism to order the sequence of @Before* and @After* lifecycle methods May 5, 2023
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

5 participants