testNG实战03_idea_java_套件测试

testNG实战03_idea_java_套件测试

创建一个suite的package用来管理下设的类,分别是logintest登录测试,paytest支付测试,suiteconfig,在resources下设一个suite.xml文件

<?xml version="1.0" encoding="UTF-8" ?>
<!--把写的类和方法都包裹起来,测试标签<test>必须要有名字-->
<suite name = "test">
    <test name="login">
        <classes>
            <class name = "com.ngtest.suite.suiteConfig"/>
            <class name = "com.ngtest.suite.loginTest"/>
        </classes>
    </test>
    <test name="pay">
        <classes>
            <class name ="com.ngtest.suite.suiteConfig"/>
            <class name ="com.ngtest.suite.payTest"/>
        </classes>
    </test>
</suite>

suiteConfig.class

package com.ngtest.suite;

import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;

public class suiteConfig {
    //suiteConfig是用来进行所有套件的配置的,在整个测试里都是生效的
    //用来写测试套件运行之前的一些共有的东西
    @BeforeSuite
    public void beforeSuite(){
        System.out.println("beforeSuite 运行成功啦");
    }
    @AfterSuite
    public void afterSuite(){
        System.out.println("afterSuite 运行成功啦");
    }

}

payTest.class

package com.ngtest.suite;

import org.testng.annotations.Test;

public class payTest {
    @Test
    public void paySuccess(){
        System.out.println("支付宝支付成功");
    }
}

loginTest.class

package com.ngtest.suite;

import org.testng.annotations.Test;

public class loginTest {
    //loginTest是最最重要的逻辑控制的类
    //在这里写测试主要的标签方法
    @Test
    public void loginTaoBao(){
        System.out.println("淘宝登陆成功");
    }
}

运行suite.xml 结果:
在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值