如何使用iannotationtransformer在testngxml中获取testname或参数名?

zkure5ic  于 2021-07-09  发布在  Java
关注(0)|答案(0)|浏览(414)

我想用transformer类设置组名,但类内testname为null。我怎样才能得到你能帮我吗?
这是我的xml文件

<test name="Firefox">
            <parameter name="browser" value="firefox"/>
            <groups>
                <run>
                    <include name="zalenium"/>
                </run>
            </groups>
            <classes>
                <class
                        name="demo.RunnerTest"/>
            </classes>
        </test>

还有我的变形金刚班

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]

        }
    }
}

现在testname在ss中

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题