AWSleep
1、功能描述
线程等待时间。
2、字段描述
3、举例
{
"className": "AWSleep",
"seconds": "1"
}
AWHttpClient
1、功能描述
发送HTTP请求到服务端,并按照一定规则校验服务端返回的响应消息。
2、字段描述
重试策略说明:
1.若响应返回为null则直接进行重试。
2.如果未设置retryStateCodeList或retryStateCodeList为空集合,则判断reponseExpected.getStateCode()是否与实际的状态码是否一致,不一致则进行请求重试。
3.如果retryStateCodeList不为空集合,则判断retryStateCodeList集合是否包含实际状态码,若包含则进行重试。
2.1 HttpClientRequest
2.2 HttpClientResponse
3、举例
{
"remark": "调用address接口",
"className": "AWHttpClient",
"config": {
"primaryKeys": [
"orderNo"
],
"keyNameAndPrimarykeys": {
"items": [
"itemUrl"
]
}
},
"request": {
"type": 1,
"url": "${global.data.ecommerce.addr}/xxxx/api/v1/xxxx/{ecommerce_id}/xxxx/xxxx",
"path": {
"ecommerce_id": "${global.taobao.ecommerceid}"
},
"headers": {
"content-type": "application/json",
"userId": "${global.auth.userid}",
"Authorization": "${global.auth.token}"
}
},
"reponseExpected": {
"stateCode": "200",
"responseBody": [
{
"dealDate": "2017-04-17T13:16:36.000+08",
"orderNo": "3234925410420512",
"amount": 78.35,
"address": "中华人民共和国",
"consignee": "张三",
"phoneNumber": "1816",
"items": [
{
"itemUrl": "//trade.taobao.com/trade/detail/tradeSnap.htm?tradeID=3234925410430512",
"itemName": "十二生肖传说精装图画书海豚绘本花园适合3岁以上亲子阅读正版童书",
"price": 17.4,
"quantity": 1
}
]
}
]
}
AWTemplateActuator
1、AW变为模版
举例:
{
"className": "AWAppiumRecordAction",
"remark": "",
"mobile":"15210001001",
"password":"qazxsw"
}
1.1、增加下面两个参数
"awIsTemplate":true,
"templateName":"youname"
1.2、参数化
把变量参数化,比如上面的例子中,需要把mobile和password的值参数化。
上面测试步骤变成的模版如下:
{
"className": "AWAppiumRecordAction",
"remark": "",
"awIsTemplate":true,
"mobile":"${mobile}",
"password":"${password}"
"templateName":"loginTemplate"
}
原有AW只要是继承了ActionWord类都支持该功能。
2、模版引用
使用框架中的 AWTemplateActuator引用模版。该AW唯一参数citationTemplates是一个对象的list。对象属性包括:
· templateName–引用的模版名称
· templateParamValue–模版中参数值
· assertTemplateName–校验结果的模版名称
举例:
比如引用上面的模版的使用方法如下:
{
"className": "AWTemplateActuator",
"citationTemplates": [
{
"templateName": "loginTemplate",
"templateParamValue": {
"mobile": "15267",
"password": "2222"
},
"assertTemplateName": "loginSuccess"----这是把校验结果作为一个模版
}
]
}
当然如果你参数值是固定的,可以不用参数,模版引用中只需要不传递templateParamValue参数即可。
2.1、扩展
对于输入我们一般会做很多非法性校验,使用模版执行器只需要配置参数值即可,比如上面的例子:
{
"className": "AWTemplateActuator",
"citationTemplates": [
{
"templateName": "loginTemplate",
"templateParamValue": {
"mobile": "15267",--手机号位数不够"password": "2222"
},
"assertTemplateName": "loginSuccess"----这是把校验结果作为一个模版
},
{
"templateName": "loginTemplate",
"templateParamValue": {
"mobile": "152671111111111",---手机号过长"password": "x@#@"
},
"assertTemplateName": "loginSuccess"----这是把校验结果作为一个模版
}
]
}
3、模版路径
3.1、模版和非模版混合使用
一个用例文件中可以包含AW模版和非AW模版两种类型,但是对于模版记得使用AWTemplateActuator执行模版
3.2、模版路径方法
为了模版的重复使用,可以把模版放到一个文件夹里面,用例文件只负责使用AWTemplateActuator调用模版
3.2.1、新建模版文件夹
新建文件夹,把所有模版都放到该文件夹里面
3.2.2、增加配置
application.propertites中增加template.path:./xx/xx/xxx/xxx。
其它不变。
本文内容不用于商业目的,如涉及知识产权问题,请权利人联系51Testing小编(021-64471599-8017),我们将立即处理