首页 > 解决方案 > 添加多个 testng 注释

问题描述

@Test
@MyAnnotations({
@MyDefindeAnnotation(name="A"),
@MyDefindeAnnotation(name="B")
})
public void testMix(){}

我想定义一个注释“MyAnnotations”,其中包含一个名为“MyDefindeAnnotation”的注释列表。MyDefindeAnnotation 可以在运行 case 之前和之后做一些事情。我想多次运行 testMix(),每次都使用不同的 MyDefindeAnotaion。</p>

就像这样: 第一次:MyDefindeAnnotation-A 做某事 -> 运行 testMix() -> MyDefindeAnnotation-A 做某事 第二次:MyDefindeAnnotation-B 做某事 -> 运行 testMix() -> MyDefindeAnnotation-B 做某事 如果只是添加一个注解,我可以使用 IInvokedMethodListener,覆盖 onStart() 方法或 beforeInvocation() 方法。但是我想要多个Annotation,我不知道如何循环运行案例。

标签: javaannotationstestng

解决方案


推荐阅读