はい、いずれかの方法で実行できますが、これは追加の手順です。
現在のテストステップでScript Assertion
を使用することによって、追加の手順を実行せずに行うこともできます。そこで応答もアサートされることができます。
疑似命令:
- 応答を取得し、必要な値が
- を使用して取得した値を使用してテストケースレベルで値を設定し、応答
- で存在すること
- アサート場合パーステストケースの他のテストステップにおけるプロパティ拡張。テストケースの他のテストステップで取得したセッションIDを使用する方法
スクリプトアサーション
/**
* 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)
?
注:もちろん、スイート0に値を設定することも可能ですまた、スイートレベルまたはプロジェクトレベルで検索した値を再利用できるプロジェクトレベルもあります
出典
2016-09-29 04:04:25
Rao