美文网首页
testng方法分组测试不生效

testng方法分组测试不生效

作者: 刺猬Hedgehog | 来源:发表于2021-09-06 21:08 被阅读0次

@BeforeGroups 和@AfterGroups 对应的方法没有被结果没有被执行出来
如下代码:

public class GroupsOnMethod {

    @Test(groups = "server")
    public void test1(){
        System.out.println("server组的test11111111");
    }

    @Test(groups = "server")
    public void test2(){
        System.out.println("server组的test22222222222");
    }

    @Test(groups = "client")
    public void test3(){
        System.out.println("client组的test33333333333333");
    }

    @Test(groups = "client")
    public void test4(){
        System.out.println("client组的test444444444");
    }

    @BeforeGroups("server")
    public void beforeGroupsOnServer(){
        System.out.println("这是服务端组运行之前运行的方法");
    }

    @AfterGroups("server")
    public void afterGroupsOnServer(){
        System.out.println("这是服务端组运行之后运行的方法!!!!!");
    }

    @BeforeGroups("client")
    public void beforeGroupsOnClient(){
        System.out.println("这是客户端组运行之前运行的方法");
    }

    @AfterGroups("client")
    public void afterGroupsOnClient(){
        System.out.println("这是客户端组运行之后运行的方法!!!!!");
    }
}

运行结果:

image.png
@BeforeGroups 和@AfterGroups 对应的方法没有被结果没有被执行出来;
解决办法:
在pom文件中,修改testng<=7.0.0版本都可以执行分组方法成功,大于7.0.0分组方法不生效,应该是testng的bug。
持续关注中。。。。。。

相关文章

网友评论

      本文标题:testng方法分组测试不生效

      本文链接:https://www.haomeiwen.com/subject/aryywltx.html