java - 如何使用 IAnnotationTransformer 在 testng xml 中获取测试名称或参数名称?
问题描述
我想用变压器类设置组名,但是在类中 testName 为空。我怎样才能得到你能帮助我吗?
这是我的 xml 文件
<test name="Firefox">
<parameter name="browser" value="firefox"/>
<groups>
<run>
<include name="zalenium"/>
</run>
</groups>
<classes>
<class
name="demo.RunnerTest"/>
</classes>
</test>
和我的transformerClass
public class MyTransformer implements IAnnotationTransformer {
@Override
public void transform(ITestAnnotation annotation, Class testClass,
Constructor testConstructor, Method testMethod) {
System.out.println(annotation.getTestName());
if (annotation.getTestName() == "Firefox") {
String grps[] = new String[]{"regression"};
annotation.setGroups(grps);
System.out.println("groups..." + Arrays.toString(annotation.getGroups()));
//prints groups...[regression]
}
}
}
解决方案
推荐阅读
- vue.js - 如何在 Nuxt 中对仅包含使用 jest 的布局的 Vue SFC 页面进行快照测试
- python - 关于使用多处理模块并发执行进程的问题
- sql - 我需要知道 Azure SQL DB 中是否有类似于“sys.dm_pdw_request_steps”的 DMV
- json - 在 ruby 中自动转换 JSON 编码的数据
- java - Spring Tool Suite 中的错误“生命周期配置未涵盖插件执行:org.apache.maven.plugins
- xml - xslt 在同一级别上对多个 for-each 循环进行排序
- java - Java:在绘图线上标记的某些坐标
- jquery - 如何使用 ajax 提交多个表单并等待所有结果?
- java - 代码改进:统计数组中元素出现的次数,返回重复次数最多的元素
- smalltalk - 如何更改 SpTextPresenter 中的字体?