如何将JUnit批注组合到自定义批注中? [英] How to combine JUnit annotations into a custom annotation?
问题描述
(使用OpenJDK-13和JUnit5-Jupiter)
(Using OpenJDK-13 and JUnit5-Jupiter)
问题是我的单元测试每个都使用一个不小的JUnit批注系统,如下所示:
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!
想知道我是否可以创建自己的JUnit批注:@CcrStandardTest
,这意味着上面的所有批注?
Was wondering if I could create my own JUnit annotation: @CcrStandardTest
, which would imply all of the annotations above?
我还尝试在类定义中上移注释(希望它们随后将应用于类的所有方法),但是编译器拒绝:"@ ParameterizedTest不适用于类型"
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"