【TestNG学习(四)忽略测试、组测试】

1、忽略测试

忽略测试就是@Test(enabled = false),false不执行,true执行
package com.lsc;

import org.testng.annotations.Test;

public class threeIgnoreTest {
    @Test
    public void ignore1(){
        System.out.println("ignore 1 执行");
    }

    @Test(enabled = false)
    public void ignore2(){
        System.out.println("ignore");
    }

    @Test(enabled = true)
    public void ignore3(){
        System.out.println("ignore 3 执行");
    }
}

执行结果(执行ignore1、ignore3):
在这里插入图片描述
执行结果(执行ignore1):
在这里插入图片描述

2、组测试

组测试:通过groups标签通过BeforeGroups和AfterGroups在用例前后添加步骤
package com.lsc;

import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test;

public class threeGroupsTest {
    @Test(groups = "server")
    public void test1(){
        System.out.println("这是server 1 测试.......");
    }

    @Test(groups = "server")
    public void test2(){
        System.out.println("这是server 2测试.............");
    }

    @Test
    public void test3(){
        System.out.println("这是客户端 1测试...........");
    }

    @BeforeGroups("server")
    public void Server1(){
        System.out.println("这是server测试之前执行的------------");
    }

    @AfterGroups("server")
    public void Server2(){
        System.out.println("这是server测试执行之后执行的***********");
    }
}

执行结果(groups=server用例前后添加执行步骤):
在这里插入图片描述

package com.lsc;

import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test;

public class threeGroupsTest {
    @Test(groups = "server")
    public void test1(){
        System.out.println("这是server 1 测试.......");
    }

    @Test(groups = "server")
    public void test2(){
        System.out.println("这是server 2测试.............");
    }

    @Test(groups="client")
    public void test3(){
        System.out.println("这是客户端 1测试...........");
    }

    @BeforeGroups("client")
    public void Server1(){
        System.out.println("这是server测试之前执行的------------");
    }

    @AfterGroups("client")
    public void Server2(){
        System.out.println("这是server测试执行之后执行的***********");
    }
}

执行结果(groups=client用例前后添加执行步骤):
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

仙女肖消乐

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值