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

[Junit5 extension] add dedicated Annotations for Number, Boolean and String flags #923

Open
aepfli opened this issue Aug 20, 2024 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@aepfli
Copy link
Member

aepfli commented Aug 20, 2024

Problem

Our annotations for testing are excellent, and they greatly ease the developer experience. Currently, all the values need to be provided as a string. This is a limitation of java annotation as java annotation members can only be (https://docs.oracle.com/javase/specs/jls/se8/html/jls-9.html#jls-9.6.1):

  • A primitive type
  • String
  • Class or an invocation of Class (§4.5)
  • An enum type
  • An annotation type
  • An array type whose component type is one of the preceding types

Furthermore, annotations can't be generic, nor do they support inheritance.

@Flag(name = "BOOLEAN_FLAG", value = "true")

Goal

Evaluate the feasibility and effort of using meta-annotations or some kind of inheritance.
We should not make the API more complex than it already is.
Maybe we only support those convenience annotations for the simple annotation approach and not in the extended configuration.

like instead of

@Flag(name = "BOOLEAN_FLAG", value = "true")
@Flag(name = "STRING_FLAG", value = "true")
@Flag(name = "Number_FLAG", value = "1")

we would love to use

@BooleanFlag(name = "BOOLEAN_FLAG", value = true)
/* optional boolean improvement
@BooleanFlagTrue(name = "BOOLEAN_FLAG")
@BooleanFlagFalse(name = "BOOLEAN_FLAG")
*/
@StringFlag(name = "STRING_FLAG", value = "true")
@NumberFlag(name = "Number_FLAG", value = 1)
@aepfli aepfli added the enhancement New feature or request label Aug 20, 2024
@toddbaert toddbaert added the help wanted Extra attention is needed label Sep 5, 2024
@aepfli
Copy link
Member Author

aepfli commented Sep 19, 2024

JUnitPioneer is actually using something like this within their cartesian test approach, which might be worth looking at https://github.com/junit-pioneer/junit-pioneer/blob/main/src/main/java/org/junitpioneer/jupiter/cartesian/CartesianTest.java#L115-L167

@toddbaert
Copy link
Member

@UtkarshSharma2612 you might like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants