zoukankan      html  css  js  c++  java
  • 接口测试框架搭建

    testNG+ATS

    1.testNG插件

    1.离线安装

    TestNG Eclipse插件下载地址http://testng.org/doc/download.html 

    下载下来以后,放在eclipse的plugins文件夹下,然后启动eclipse。

    然后去Windows -> show view -> other,java文件夹下,有TestNG,双击图标,在eclipse界面下面便会出现TestNg的窗体。

    2.在线安装

    Help->Install New Software,然后在弹出的窗口中的Work with后面的输入框中输入http://beust.com/eclipse

    然后点击Add按钮,选中TestNG后一路点击Next下去安装即可,直到Finished之后,重启Eclipse完成安装。

    2.ATS插件

     ats插件是支付宝定制插件,主要实现参数化和快捷新建接口脚本等

    PS.CSV参数化

    目前我们的用例通过CSV脚本进行维护的,因此我们测试基类里编写了一个DataProvider。具体定义如下:

    //@DataProvider(name = "CsvDataProvider")
    //public Iterator<?> getDataProvider(Method method) {}

    @Override
    @DataProvider(name = "CsvDataProvider")
    public Iterator<?> getDataProvider(Method method) throws IOException {
    String file = "";

    if (null != method.getAnnotation(TestData.class)) {
    String env = StringUtil.contains(PropertyConfig.DB_MODE, "dev")?"dev":"test";
    file = method.getAnnotation(TestData.class).path()
    + method.getAnnotation(TestData.class).fileName()+ env + ".csv";
    logger.info("++++++++++++++++++++++++++++" + file);
    return getDataProvider(method.getDeclaringClass(), method, file);

    } else
    logger.info("============================" + file);

    return getDataProvider(method.getDeclaringClass(), method);
    }

    测试类继承测试基类,测试类示例如下

    @TestLab(id = "Testtest001", desc = "正常业务场景测试")
    public class Testtest extends TestBase {
    private static final Logger logger = LoggerFactory.getLogger(GetConfigNormalTest.class);

    @XAutoWire(value = XAutoWire.BY_NAME, bundle = "com.tset")
    protected Test tset;
    @TCList(caseid = { "Testtest001001" }, casedesc = { "正常业务场景测试" })
    @Test(dataProvider = "CsvDataProvider", description = "正常业务场景测试")
    public void tset(final String caseId, final String description,
    final String tset001, final String tset002, final String defValue) {

    TestVo testVo = new TestVo();
    testVo.setTset001(tset001);
    testVo.setTset002(tset002);
    TestenumEnum testenum = TestenumEnum.SUPPORTED_LINES;

    Test.tset(tset001,tset002,configKey,defValue)

  • 相关阅读:
    Zookeeper(1)---初识
    golang的一些零散笔记
    ELK使用过程中遇到的一些问题
    ECharts系列:玩转ECharts之常用图(折线、柱状、饼状、散点、关系、树)
    MySQL系列:Docker安装 MySQL提示错误:Access denied for user'root'@'localhost' (using password:yes)
    HTML+CSS系列:登录界面实现
    Apollo系列(二):ASP.NET Core 3.1使用分布式配置中心Apollo
    Apollo系列(一):分布式配置中心Apollo安装(Linux、Docker)
    为你的应用加上skywalking(链路监控)
    工作中,你是如何开始搭建一套容器云环境的呢?
  • 原文地址:https://www.cnblogs.com/blog932707727/p/5834192.html
Copyright © 2011-2022 走看看