How to re-use properties in an other testcase
In soapUI i have a testsuite with 2 testcases: SaveThing and GetThing.
In the GetThing i use the Run TestCase testStep to run SaveThing f开发者_运维百科or getting the SaveThing properties and re-use them in the request of GetThing testcase.
Yet i did not succeed to achieve this by using the Run TestCase testStep.
Thnx.
You could also define a property at the TestSuite level, and set/get them within the test cases, by using the PropertyTransfer test step. That's a little simpler than having to write a groovy script.
A possible solution i finally found is by using this simple code in a Groovy Script:
def regnr = context.expand('${DataSource#id_regnr}')
context.getTestCase().setPropertyValue('id_regnr', regnr);
What happens is that the property is set to the Properties tab in the SaveThing testCase.
Then in GetThing testCase i run the SaveThing testCase by using the Run testCase teststep. Finally in the Test Request teststep of GetThing i can then re-use that propertie in the request message to get the thing.
You need to create a groovy script. The below script creates a global property. If you click on the project at the left menu, you will see the "custom properties" at the left below of the screen. These are the global properties and you can directly use them anywhere in the project.
testRunner.testCase.testSuite.project.setPropertyValue("globalProp","propertyValue");
So, you have 2 test cases. You want use a variable from the first one. Then go to the 1st test case and create a groovy step. You have to get data (right click within the script editoe and select get data option) then you need to create a global variable with the above script.
Hope this helps. Regards, Suha
精彩评论