• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

WinTestNG: 基于testNG开发的自动化测试基础框架

原作者: [db:作者] 来自: 网络 收藏 邀请

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:[email protected]: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":"[email protected]",            "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":"[email protected]",        "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"}

联系方式


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
jacoco: jacoco二开,支持增量代码覆盖率发布时间:2022-02-13
下一篇:
ngtesting-web: ngtesting软件测试平台发布时间:2022-02-13
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap