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

Apply suite configuration to tests selected by unique ID #3694

Conversation

mpkorstanje
Copy link
Contributor

@mpkorstanje mpkorstanje commented Feb 16, 2024

Overview

Applies suite configuration to tests selected by unique ID.

Tests in a suite selected by id did not receive their configuration because this was only applied to the discovery request builder when a suite class was selected. By splitting the processing of configuration annotations and select and filter annotations, the configuration can now always be applied prior to discovery.

Fixes: #3693


I hereby agree to the terms of the JUnit Contributor License Agreement.


Definition of Done

@sbrannen sbrannen changed the title Use suite configuration when selecting tests by id Use suite configuration when selecting tests by unique ID Feb 17, 2024
Copy link
Member

@sbrannen sbrannen left a comment

Choose a reason for hiding this comment

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

Thanks for the super fast PR! 👍

I think it looks pretty solid, but I've requested a few minor enhancements.

@@ -198,6 +196,16 @@ public SuiteLauncherDiscoveryRequestBuilder suite(Class<?> suiteClass) {
return this;
}

public SuiteLauncherDiscoveryRequestBuilder suiteConfigurationParameters(Class<?> suiteClass) {
Copy link
Member

@sbrannen sbrannen Feb 17, 2024

Choose a reason for hiding this comment

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

I just realized we don't have any Javadoc for SuiteLauncherDiscoveryRequestBuilder. 😱

So we should definitely address that, but rather in a different issue.

In any case, I'd like to see some Javadoc on this new method.

In addition, let's come up with a more descriptive name, perhaps something like one of the following.

  • configurationParametersForSuite(Class<?>)
  • configurationParametersForSuiteClass(Class<?>)
  • configurationParametersFromSuite(Class<?>)
  • applyConfigurationParametersFromSuite(Class<?>)

I know the last one is a bit long and doesn't start with configurationParameter like the existing methods; however, I do think it aptly describes what it does (which is a bit special compared to the existing configurationParameter() and configurationParameters() methods).

Thoughts?

Copy link
Contributor Author

@mpkorstanje mpkorstanje Feb 18, 2024

Choose a reason for hiding this comment

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

I skipped the Javadoc because most classes marked as internal were lacking it. I'll add some for new methods.

Namingwise, I am considering deprecating the existing suite(Class<?>) method and replacing it with two methods:

  • applyConfigurationParametersFromSuite(Class<?>)
  • applySelectorsAndFiltersFromSuite(Class<?>)

And then also look at a way to avoid invoking applyConfigurationParametersFromSuite() over and over again for every unique ID.

In hindsight these are two rather distinct operations. It just didn't occur to me when I wrote the suite engine.

Copy link
Member

Choose a reason for hiding this comment

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

I skipped the Javadoc because most classes marked as internal were lacking it. I'll add some for new methods.

Indeed, it is marked as internal even though it's public. I had overlooked that.

In any case, I think it's still worth documenting (even if it's "just for us").

I raised #3695 to address that.

Speaking of which, would you like to address #3695?

I'm asking because someone else has already volunteered to do that, and I want to avoid duplicate work.

Copy link
Member

@sbrannen sbrannen Feb 18, 2024

Choose a reason for hiding this comment

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

Namingwise, I am considering deprecating the existing suite(Class<?>) method and replacing it with two methods:

* `applyConfigurationParametersFromSuite(Class<?>)`

* `applySelectorsAndFiltersFromSuite(Class<?>)`

I like that. 👍

I'm also wondering if we should add a precondition check which requires that the supplied Class is annotated with @Suite.

Or... perhaps that's over-engineering. 🤷

And then also look at a way to avoid invoking applyConfigurationParametersFromSuite() over and over again for every unique ID.

Yes, please do that.

In hindsight these are two rather distinct operations. It just didn't occur to me when I wrote the suite engine.

No worries. It's a learning process, and APIs are meant to evolve (in a non-breaking manner). 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm asking because someone else has already volunteered to do that, and I want to avoid duplicate work.

That's quick! This looks like a good issue for a first time contributor, so I'm happy to see someone else try.

Copy link
Contributor Author

@mpkorstanje mpkorstanje Feb 20, 2024

Choose a reason for hiding this comment

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

I'm also wondering if we should add a precondition check which requires that the supplied Class is annotated with @suite.

Or... perhaps that's over-engineering. 🤷

That would be a breaking change. The @Suite annotation is optional for the JUnitPlatform runner.

@mpkorstanje mpkorstanje changed the title Use suite configuration when selecting tests by unique ID Apply suite configuration to tests selected by unique ID Feb 20, 2024
@mpkorstanje mpkorstanje marked this pull request as ready for review February 20, 2024 17:41
@mpkorstanje mpkorstanje requested a review from sbrannen February 21, 2024 08:44
@marcphilipp marcphilipp self-requested a review March 18, 2024 15:28
Copy link
Member

@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.

Looks great! 👍

@marcphilipp marcphilipp self-assigned this Mar 18, 2024
@marcphilipp marcphilipp merged commit 74bd85c into junit-team:main Mar 19, 2024
12 checks passed
@mpkorstanje mpkorstanje deleted the use-suite-configuration-when-selecting-by-id branch March 19, 2024 09:05
@sbrannen
Copy link
Member

Looks great! 👍

I second that.

Thanks again for raising the issue and for the well-executed PR. 👍

p.s. I polished a bit in 2a5c6b2.

@mpkorstanje
Copy link
Contributor Author

Cheers! You're welcome. I think I've said before, it's nice to work on a codebase where everything is clear and well organized.

marcphilipp pushed a commit that referenced this pull request Jun 17, 2024
Tests in a suite selected by unique id did not receive their
configuration because this was only applied to the discovery request
builder when a suite class was selected. By splitting the processing of
configuration annotations and select and filter annotations, the
configuration can now always be applied prior to discovery.

Fixes #3693.

(cherry picked from commit 74bd85c)
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.

Suite configuration is not applied to tests selected by unique ID
3 participants