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

Support @EnumSource, @CsvSource, etc. as repeatable annotations #3736

Open
bjmi opened this issue Mar 18, 2024 · 10 comments · May be fixed by #3787
Open

Support @EnumSource, @CsvSource, etc. as repeatable annotations #3736

bjmi opened this issue Mar 18, 2024 · 10 comments · May be fixed by #3787

Comments

@bjmi
Copy link
Contributor

bjmi commented Mar 18, 2024

Given following example with types from the JDK,

@EnumSource(IsoEra.class)
@EnumSource(MinguoEra.class)
@EnumSource(HijrahEra.class)
@ParameterizedTest
void getDisplayName(Era era) {
    assertNotNull(era.getDisplayName(TextStyle.FULL, Locale.ROOT));
}

the compiler complains with:

java: org.junit.jupiter.params.provider.EnumSource is not a repeatable annotation type

It would be useful if multiple @EnumSource annotations were allowed for a single parameterized test.

My use case would be two enums that both implement the same interface that is used as the method parameter.

(Others JDK types are java.nio.file.LinkOption and java.nio.file.StandardOpenOption that implement the same java.nio.file.OpenOption.)

@sbrannen sbrannen changed the title EnumSource does not have a valid java.lang.annotation.Repeatable annotation Support @EnumSource as a repeatable annotation Mar 18, 2024
@marcphilipp
Copy link
Member

Team decision: Make all @..Source annotations repeatable while making sure it makes sense for all of them.

@sbrannen
Copy link
Member

The functionality required to support this feature is luckily already available.

@sbrannen sbrannen changed the title Support @EnumSource as a repeatable annotation Support @EnumSource, @CsvSource, etc. as repeatable annotations Mar 22, 2024
@madalingiurca
Copy link

@sbrannen I would like to grab this one if it's still valid

@sbrannen
Copy link
Member

Hi @madalingiurca,

This issue is labeled as up-for-grabs, and you are the first to volunteer.

So feel free to submit a PR!

@marcphilipp
Copy link
Member

@madalingiurca Have you already started on this?

@madalingiurca
Copy link

@marcphilipp nothing apart from forking the junit5 repo, unfortunately. I'll try to find some time for it by the end of this week. If anyone else is planning to submit a PR faster, feel free to do it

@marcphilipp
Copy link
Member

No worries! Please let us know when you start.

@madalingiurca
Copy link

@marcphilipp, I've drafted one approach in #3787.

So far, I've adapted @CSVSource annotation for repeatable capabilities. Let me know what you think and if we should go forward with this approach.

@marcphilipp
Copy link
Member

Thanks! I added a few comments and suggestions. 👍

@madalingiurca
Copy link

@marcphilipp, I've wrapped up the changes and updated release notes + user guide (although not sure if former is needed). Let me know if anything else should be updated.

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