How to transfer a value from one test case to another using groovy
Hi,
In my first test case, I have a soap request from which I get an account id in the response. Below is the response that I get.
<CreatAccountResponse> <Account> <AccountId>ACCT11011294</AccountId> </Account> </CreatAccountResponse>
In my second test case, I have a request where I have to use the account id created in the first test case.
<UpdateAccountRequest> <Account> <AccountId>"need to use account id from the first test case</AccountId> <AccountStatus>ACTIVE</AccountStatus> </Account> </UpdateAccountRequest>
so my question is how can I transfer the account id from my first test case soap response to my second test case via Groovy script.
Regards,
Umair
First of all, thumb rule is that, each test case should be independent. Design your tests so that there is not dependency between the two test cases.
The above is not my statement, which I learned and follow.
Having said that, of course, it does not mean it is not possible to do so in SoapUI, it is possible.
Use below Script Assertion for the first request:
def accountId = new XmlSlurper().parseText(context.response).'**'.find{it.name() == 'AccountId'}.text() context.testCase.testSuite.setPropertyValue('ACCOUNT_ID, accountId)
In your next test step use
<AccountId>${#TestSuite#ACCOUNT_ID}</AccountId>