jeudi 20 février 2020

How to combine JUnit annotations into a custom annotation?

(Using OpenJDK-13 and JUnit5-Jupiter)

The problem is that my unit tests each make use of a not-small JUnit annotation system, something like this:

@ParameterizedTest
@MethodSource("myorg.ccrtest.testlogic.DataProviders#standardDataProvider")
@Tags({@Tag("ccr"), @Tag("standard")})

This makes test authoring a little tedious, test code a little long and of course, when a change is needed, it's a chore!

Was wondering if I could create my own JUnit annotation: @CcrStandardTest, which would imply all of the annotations above?

I also tried shifting the annotations up in the class definition (hoping they would then apply to all methods of the class), but the compiler says no: "@ParameterizedTest is not applicable to type"





Aucun commentaire:

Enregistrer un commentaire