Split properties of @MavenTest across multiple (@Repeatable) annotations (original) (raw)

Is your feature request related to a problem? Please describe.

At the moment, it is rarely possible to define JUnit 5 meta-annotations like @MavenCleanInstall meaning @MavenTest(goals = { "clean", "install"}), as doing so will also fix all the other properties of the annotation like activeProfiles, options, systemProperties and debug.

Describe the solution you'd like

I would like to see a series of @Repeatable annotations:

In particular, this would allow uses like the following:

@MavenTest @MavenGoal("clean") @MavenGoal("install") @MavenSystemProperty("skipTests")

If you want to, you can then also define a meta-annotation for, e.g., the first three of the above and use it like this:

@MavenCleanInstall @MavenSystemProperty("skipTests")

Describe alternatives you've considered

Annotations like @MavenGoal should IMHO be repeatable, as array-valued properties are often uglier when auto-formatted, in particular when the lines exceed the column limit:

@MavenGoals({ "clean", "install"})

Admitted, for @MavenGoal this is less likely, but even there only phase names are really short. For @MavenSystemProperty this is a real issue if multiple system properties are defined. (Of course, these formatting issues are even worth with the current, multi-property @MavenTest.)

@MavenTest(goals = { "clean", "install"}, systemProperties = { "skipTests" })

Additional context

@MavenSystemProperty is an interesting case. ATM, MavenTest.systemProperties includes the = in the property definitions and tries to parse the string at run-time. With a separate annotation, however, parsing can happen at compile-time:

@MavenSystemProperty(name = "skipTests", value = "true")

This is IMHO much clearer. There is one minor quirk, however, if one wants to allow the following (sensible) shorthand:

@MavenSystemProperty("skipTests")

Under the hood, the above shorthand means value = "skipTests" rather than name. Personally, I think it is acceptable to define the annotation like this, however:

@interface MavenSystemProperty {

String name() default ""; /** The system property's value or name, if "name" is not also set */ String value(); }

After all, what matters most is readability of the tests – even if the property name under the hood (value) is a bit odd.