2017-08-11 3 views
0
私は、以下のシナリオのプロパティの転送を使用して、同じプロパティに2つの値を格納したい

ソープUI適切trasfer

応答:

{ 
    "token_type": "Bearer", 
    "expires_in": "3600", 
    "ext_expires_in": "0", 
    "expires_on": "1502435816", 
    "not_before": "1502431916", 
    "resource": "https://CY17API.toyota.com", "access_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IlZXVkljMVdEMVRrc2JiMzAxc2FzTTVrT 
} 

私は、トークン型の値を格納し、トークン値にアクセスしたいですプロジェクトレベルの1つのプロパティでテストし、そのプロパティをすべてのテストケースにさらに渡します。

私は$.token_type$.access_tokenを使用していますが、私は両方を保存する方法はありません。

答えて

0

テストステップをとすると、テストステップを追加することなく達成できます。

ここには考えがあります:

必要な値を抽出します。
プロジェクトレベルのカスタムプロパティでそれらを保存します。
さらなるテストケースでこれらの値が必要な場合はいつでもproperty expansionを使用してください。

スクリプトアサーション:今

assert context.response, 'Response is null or empty' 

def json = new groovy.json.JsonSlurper().parseText(context.resposne) 
log.info "Token type: ${json.token_type}" 
log.info "Access token : ${json.access_token}" 

//Check those are not empty in the received response before storing the values 
assert json.token_type, 'Token type is empty or null' 
assert json.access_token, 'Access token is empty or null' 

//Store them at project level 
context.testCase.testSuite.project.setPropertyValue('TOKEN_TYPE', json.token_type) 
context.testCase.testSuite.project.setPropertyValue('ACCESS_TOKEN', json.access_token) 

、あなたはすなわち、さらにテストケースでそれらを必要な場所にそれぞれtoken_typeaccess_tokenの動的な値を取得するには${#Project#TOKEN_TYPE}${#Project#ACCESS_TOKEN}を使用しています。