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

Introduce @DependsOn annotation to prioritize test method execution order #1767

Open
duckladydinh opened this issue Feb 9, 2019 · 14 comments

Comments

@duckladydinh
Copy link

duckladydinh commented Feb 9, 2019

@Update: Now it works exactly like TestNG, which means if A depends on B, and B is disabled, then A is disabled as well.

Hi everyone,

I am creating a pull request for this feature. It should work similar to TestNG (@Test(dependsOn = ...)) but it will not disable the test if some test fails. It just gives methods a priority like @Order.

It would be great if someone can give me some advice how to improve it.

Thank you :)

@sbrannen
Copy link
Member

sbrannen commented Feb 9, 2019

Tentatively slated for 5.5 M1 for the purpose of team discussion.

@sbrannen sbrannen changed the title Feature Request: Add @Depend(String[] methods) annotation to give 'methods' higher priority than the annotated method Introduce @DependsOn annotation prioritize method execution order Feb 9, 2019
@sbrannen sbrannen changed the title Introduce @DependsOn annotation prioritize method execution order Introduce @DependsOn annotation to prioritize method execution order Feb 9, 2019
@sbrannen sbrannen changed the title Introduce @DependsOn annotation to prioritize method execution order Introduce @DependsOn annotation to prioritize test method execution order Feb 9, 2019
@sbrannen
Copy link
Member

sbrannen commented Feb 9, 2019

Hi @duckladydinh,

Thanks for opening the issue and submitting the PR!

I am creating a pull request for this feature. It should work similar to TestNG (@Test(dependsOn = ...)) but it will not disable the test if some test fails. It just gives methods a priority like @Order.

Although I think there is merit in mere "dependent ordering" as in the PR, I think it would be worth investigating the possibility for "not executing" methods if a method that they depend on fails.

For example, if C depends on A and A fails, then C should be aborted. That's basically what TestNG does, and I think it might be possible to implement this elegantly in JUnit Jupiter by implementing the TestWatcher API introduced in JUnit Jupiter 5.4. Of course, I have not tried to implement it myself, so I'm just thinking out loud here.

@duckladydinh
Copy link
Author

duckladydinh commented Feb 11, 2019

Hi @sbrannen , thank you for the suggestion. I think I have something done already based on your suggestion. My design is to keep the DependsOnAnnotation as it is, and add a separate TestWatcher :).

@thespags
Copy link

Hi is there any update on when this PR might be merged in. There hasn't been any follow up since end of last year. Thank you.

@stale
Copy link

stale bot commented Jun 19, 2022

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 Jun 19, 2022
@spags-twilio
Copy link

Hi. I wanted to check in if there is any update or concerns? This is one of the features available in TestNG that I miss when working in JUnit5. It helps isolate problems in tests when you have good dependency management.

@stale stale bot removed the status: stale label Jun 19, 2022
@fogrid
Copy link

fogrid commented Jul 12, 2022

Also checking about this, this feature would be very usable, is it going to be merged?

@ahoehma
Copy link

ahoehma commented Jun 9, 2023

Any news here?

@sbrannen
Copy link
Member

sbrannen commented Jun 9, 2023

@ahoehma, this issue still has the waiting-for-interest label.

@jzhang-SD
Copy link

This feature would be very useful

@thespags
Copy link

I am still interested.

@ericparton
Copy link

I'm not sure what happened here, but this would be a useful feature to have. It's something that TestNG can do, and the lack of support makes migrating from TestNG to JUnit difficult.

@armlesshobo
Copy link

armlesshobo commented May 15, 2024

I'm also interested in this.

@Mercuron
Copy link

I'm also interesting in this. I have a lot of tests that I want to run in the order in which they are written (yes this is the case). When there are few of them, there is no problem.

@Test
@Order(10)...

@Test
@Order(11)...

But when the dough gets too much (100-200 consecutive tests) and I need to change/insert something in the middle, it's a big pain.

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