11 Star 56 Fork 26

dongxl123 / WinTestNG

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 6.81 KB
一键复制 编辑 原始数据 按行查看 历史
dongxuanliang252 提交于 2021-01-04 10:50 . init

WinTestNG

基于TestNG开发的自动化测试框架,自动化测试平台后端接口参考项目:WinTestNG-platform-api

概述

  • 适用于HTTP接口测试
  • 测试数据维护在DB
  • 支持Redis、Mongo、Mysql等操作
  • 支持测试模板设置,可抽象通用功能、
  • 全局变量设置
  • 支持断言
  • 使用FreeMarker作为模板引擎
  • 生成测试报告数据存储在DB
  • 涉及测试概念:测试用例、数据驱动、断言、测试报告、接口测试、自动化测试、测试模板
  • 建表语句: wintestng-core/src/resources/WinTestNG.sql

使用方法

  • 执行SQL语句 wintestng-core/src/main/resources/WinTestNG.sql
  • 修改配置文件 wintestng-core/src/main/resources/application.yml
  • 执行TestNG文件 example/src/test/resources/projectname/example.xml

测试计划执行逻辑

logic

配置详细文档

资源配置

涉及

  • 表resource_config
mysql
{
    "url":"jdbc:mysql://xx.mysql.rds.aliyuncs.com:3306/baoxian",
    "userName":"userName",
    "password":"password"
}

redis

{
    "host":"12.26.1.94",
    "port":3736,
    "database":8,
    "password":"D6eAtdxxxxxxsaisf"
}

mongo

{
    "url":"mongodb://wyxx_app:xxxddd@11.40.88.39:3717,11.41.53.215:27017/wyxx_app"
}

数据准备配置

涉及

  • 表test_cases(测试计划) 字段data_preparation_config

text

{
    "showTitle":"3333-${mobile}",
    "text":"[{\"mobile\":\"15967126512\"},{\"mobile\":\"15967122137\"}]",
    "type":"text"
}

csv

{
    "fieldNameList":[
        "id",
        "name",
        "mobile"
    ],
    "fileName":"http://xx.winbaoxian.com/xx.1csv",
    "separator":",",
    "type":"csv"
}

resource

{
    "resourceId":2,
    "showTitle":"3333-${mobile}",
    "sql":"select mobile from sales_user limit 3",
    "type":"resource"
}

步骤配置

涉及

  • 表action_template(测试模板) 字段actions
  • 表test_cases(测试计划) 字段pre_action、main_actions、post_actions

示例

[
    {
        "name":"调用APP登录",
        "actionType":"TPL",
        "templateId":21,
        "mappings":{
            "a":"18757101098",
            "b":"0000"
        },
        "delayTimes":2000,
        "alias":"template"
    },
    {
        "name":"更新数据库",
        "delayTimes":2000,
        "actionType":"RESOURCE",
        "resourceId":1,
        "sql":"update big_guy_share_info set status=0 where id=8"
    },
    {
        "name":"教你赚钱-获取大咖分享分页数据-20条",
        "actionType":"HTTP",
        "requestHeader":{

        },
        "requestUrl":"http://xx.winbaoxian.cn/xx/1/getBigGuyShareInfoPageList",
        "requestParams":{
            "t":1,
            "n":1,
            "u":"10608088@winbaoxian.com",
            "di":"mockDeviceId",
            "m":1,
            "s":"${template.token}"
        },
        "requestMethod":"POST",
        "requestContentType":"e/b",
        "requestBody":"{\"pageNo\": 1}",
        "alias":"getBigGuyShareInfoPageList",
        "delayTimes":2000
    },
    {
        "actionType":"ASSERTION",
        "delayTimes":2000,
        "name":"断言",
        "verifyList":[
            {
                "type":"eq",
                "value1":"${getBigGuyShareInfoPageList.body.r.isEnd?c}",
                "value2":"true"
            }
        ]
    }
]

HTTP请求

{
    "name":"教你赚钱-获取大咖分享分页数据-20条",
    "actionType":"HTTP",
    "requestHeader":{},
    "requestUrl":"http://xx.winbaoxian.cn/xx/1/getBigGuyShareInfoPageList",
    "requestParams":{
        "t":1,
        "n":1,
        "u":"10608088@winbaoxian.com",
        "di":"mockDeviceId",
        "m":1,
        "s":"${template.token}"
    },
    "requestMethod":"POST",
    "requestContentType":"e/b",
    "requestBody":"{\"pageNo\": 1}",
    "delayTimes":2000,
    "alias":"template"
}

资源操作

{
    "name":"更新数据库",
    "actionType":"RESOURCE",
    "resourceId":1,
    "sql":"SELECT id,`name`,mobile from sales_user limit 1",
    "fetchOne":true,
    "delayTimes":2000,
    "alias":"ret"
}

常量设置

{
    "name":"常量设置",
    "actionType":"SETV",
    "params":{
        "ip":"x-api.winbaoxian.cn",
        "calculate":"/api/product/data/calculate",
        "get_captcha":"/api/policy/getCaptcha",
        "pre_order":"/api/policy/pre-order"
    },
    "delayTimes":2000,
    "alias":"ret"
}

调用模板

{
    "name":"调用APP登录",
    "actionType":"TPL",
    "templateId":21,
    "mappings":{
        "a":"18757101098",
        "b":"0000"
    },
    "delayTimes":2000,
    "alias":"template"
}

ASSERTION

{
    "name":"断言",
    "actionType":"ASSERTION",
    "templateId":21,
    "verifyList":[
        {
            "type":"condition",
            "value1":"${getExpirePolicyCollate.body.r.policyExpireRemindList?exists?c}==true"
        },
        {
            "type":"eq",
            "value1":"${getExpirePolicyCollate.body.r.policyExpireRemindList[0].policyUuid}",
            "value2":"5108"
        }
    ],
    "delayTimes":2000,
    "alias":"v"
}

GROUP分组

{
    "name":"分组",
    "actionType":"GROUP",
    "stepList":[
        {
            "name":"调用APP登录",
            "actionType":"TPL",
            "templateId":21,
            "mappings":{
                "a":"18757101098",
                "b":"0000"
            },
            "delayTimes":2000,
            "alias":"template"
        }
    ]
}

IF判断

{
    "name":"IF判断",
    "actionType":"IF",
    "condition": "${res.success?c}",
    "stepList":[
        {
            "name":"调用APP登录",
            "actionType":"TPL",
            "templateId":21,
            "mappings":{
                "a":"18757101098",
                "b":"0000"
            },
            "delayTimes":2000,
            "alias":"template"
        }
    ]
}

FOR循环

{
    "name":"IF判断",
    "actionType":"IF",
    "iterData": "${toJSONString(res.list)}",
    "iterAlias": "a",
    "stepList":[
        {
            "name":"调用APP登录",
            "actionType":"TPL",
            "templateId":21,
            "mappings":{
                "a":"${a.mobile}",
                "b":"0000"
            },
            "delayTimes":2000,
            "alias":"template"
        }
    ]
}

SCRIPT

{
    "name":"脚本",
    "actionType":"SCRIPT",
    "lang":"PYTHON",
    "content":"a=1+2",
    "extractVars": ["a"],
    "alias": "xx"
}

联系方式

Java
1
https://gitee.com/UnlimitedBladeWorks_123/WinTestNG.git
git@gitee.com:UnlimitedBladeWorks_123/WinTestNG.git
UnlimitedBladeWorks_123
WinTestNG
WinTestNG
master

搜索帮助