Forum Discussion

mkhan031486's avatar
mkhan031486
Contributor
7 years ago
Solved

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</A...
  • nmrao's avatar
    7 years ago

    mkhan031486,

     

    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>