是的,它可以以任何方式完成,这是一个额外的步骤。
也可以在当前的测试步骤中使用Script Assertion
而没有额外的步骤。那里的回应也可以断言。
伪指令:
- 检索响应并解析它
- 断言如果所需的值是存在于所述响应
- 设定在测试情况下电平的值
- 使用使用检索到的值在测试用例的其他测试步骤中进行属性扩展。
脚本断言
/**
* This is a script assertion
* which reads the response and asserts if there is response
* reads response property and sets at test case level property SESSION_ID
*/
def jsonString = context.response
def json = new groovy.json.JsonSlurper().parseText(jsonString)
//Check if the response is not empty or null
assert json, "Response received is empty or null"
def sessionId = json.response as String
//Check if there is reponse property exists in response json
assert sessionId, "response property is empty or null"
log.info "Session id : ${sessionId}"
//To set the value at test case level
context.testCase.setPropertyValue('SESSION_ID', sessionId)
如何使用检索到的会话ID的测试用例的其他测试步骤?
注:当然,它也可以在浴室o设定值r项目级别,可以在套件或项目级别分别重用检索值
来源
2016-09-29 04:04:25
Rao