在运行时使用testngListners为@test方法设置java注释
我正在使用testng编写诱惑报告,有一个非常基本的方法,如下所示
@Test
@DisplayName("Hello this is a description for allure report")
public void method1(){
System.out.println("Hi i am from method1");
}
在上面的代码中,@DisplayName来自诱惑报告。现在我试图实现的是在运行时使用TestngListners设置DisplayName
我查看了ITextResult和ITestContext,但据我所知,它不支持这一点
有没有其他方法可以做到这一点
# 1 楼答案
如果您使用的是Junit launcher,只需在测试计划上迭代即可获得显示名称
显示名称的代码如下所示: