简体   繁体   中英

SOAP UI - Set custom property to a test case after the REST request test step

I need to set a custom property from a test case lets say TestCase #1 ,

This TestCase#1 has a Rest request test step

These are the 2 different steps, 1.Rest Request Test Step 2.Set Custom property

After this step executes, in the next step via Groovy script I would like to access the previous step's response, parse and set custom property to the test case or test suite.

I am setting a value to test suite via this code,

testRunner.testCase.setPropertyValue("someName", someValue)

This is the code that I will be using in the step #2 to set up a custom property.

import groovy.json.JsonSlurper

def jsonSlurper = new JsonSlurper()

def config = jsonSlurper.parse('JSON response from previous step object here'))
def someValue=config.apiVals.someJSONProperty[0].id as String

The above can be achieved using script assertions in the same step #1 but I don't want to do over there.

I want to parse the response in the next step with some additional processing.

how can I achieve this?

Within REST Request, we get a response which is a JSON Object:

在此处输入图像描述

and when we want to transfer this response with Property Tranfer: we can leave Source text field empty and we will tranfer the whole JSON object, if we want to tranfer a data of this object which is in this case name we set the source text field $.name and we are now able to retrieve a specific data of the JSON object.

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM