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 TestInstances API from JUnit Jupiter #2719

Merged
merged 7 commits into from May 24, 2022

Conversation

tobiasstadler
Copy link
Contributor

JUnit Jupiter has an API to get the test instances per test. Let's use it.

@bsideup bsideup changed the title JUnit Jupiter already tracks the test instances Use TestInstances API from JUnit Jupiter May 13, 2020
@bsideup
Copy link
Member

bsideup commented May 13, 2020

@britter could you please verify this change? :)

@britter
Copy link
Contributor

britter commented May 14, 2020

@bsideup I'm on vacation at the moment. I will have a look next monday. 👍

Copy link
Contributor

@marcphilipp marcphilipp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that TestInstances was introduced in JUnit Jupiter 5.4.

}

current = ctx.getParent();
}
return testInstances;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming the order is important, I think this method body can be replaced with:

List<Object> allInstances = new ArrayList<>(ctx.getRequiredTestInstances().getAllInstances());
Collections.reverse(allInstances);
return new LinkedHashSet<>(allInstances);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order isn't important (sine there is no guarantee from the JVM anyways, right?), and we have dependsOn to enforce it.

Or is there some built-in way of ensuring the order that TestInstances is using?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@britter Used LinkedHashSet (which has ordering guarantees), so I guess the order is important.

I guess the intention is to start containers of parent classes before child classes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember why I used a LinkedHashSet to be honest 😇

@britter
Copy link
Contributor

britter commented May 20, 2020

LGTM

@stale
Copy link

stale bot commented Aug 22, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open. If there isn't one already, a PR to fix or at least reproduce the problem in a test case will always help us get back on track to tackle this.

@stale stale bot added the stale label Aug 22, 2020
@stale
Copy link

stale bot commented Sep 5, 2020

This issue has been automatically closed due to inactivity. We apologise if this is still an active problem for you, and would ask you to re-open the issue if this is the case.

@stale stale bot closed this Sep 5, 2020
@marcphilipp
Copy link
Contributor

@kiview @bsideup Can you please re-open this PR? I would have commented to keep it open but was on vacation.

@rnorth
Copy link
Member

rnorth commented Sep 6, 2020

Reopened - sorry, we shouldn't have let this get so stale.

@marcphilipp
Copy link
Contributor

@rnorth It still shows as "closed" to me. Wrong button?

@rnorth rnorth reopened this Sep 6, 2020
@rnorth
Copy link
Member

rnorth commented Sep 6, 2020

Huh, not sure what happened there. Thanks @marcphilipp

@tobiasstadler
Copy link
Contributor Author

This PR is laying around a bit. Are you still interested in it or should I close it?

@tobiasstadler tobiasstadler requested a review from a team as a code owner May 24, 2022 09:16
@bsideup bsideup added this to the next milestone May 24, 2022
@eddumelendez eddumelendez merged commit f60051c into testcontainers:master May 24, 2022
@eddumelendez
Copy link
Member

thanks for the contribution @tobiasstadler ! and everyone involved in the review :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants