Forum Discussion

SoapRookie's avatar
SoapRookie
Occasional Contributor
12 years ago

Using one test case to run from several other test cases

I am using soapUI Pro for REST apis.
Currently, each of my test cases contain a login test step in order to obtain the session id. So I have decided to create just one test case with login test step and use the obtained session id in other test cases. So this is what I did:

1. I created a new test case for Login and got the session id
2. I created a new Property and transferred the Session id there (Do I need to create this?)
3. In the other test case where I need to use this session id, I created a "Run Test Case".
When I view the Options for Run Test Case, I don't see any Return Properties.

How can I make this work? Can some one please help?


SoapRookie

3 Replies

  • Hello,
    There is no need to create property transfer and Run Test Case step,
    rather you can store session id at testSuite level and directly use in your other test cases.
    You can use following groovy to store the session id at test suite level and use wherever required.

    def sessionid = context.expand( '${Login#Response#declare namespace ns=\'used in\'; //ns:Response[1]/ns1:sessionid[1]}' )
    testRunner.testCase.testSuite.setPropertyValue("SessionId ",sessionid );
    Hope it helps.
  • SoapRookie's avatar
    SoapRookie
    Occasional Contributor
    Hi Reshma,

    These are the steps that I followed:
    1. I have created a test case with the login test step to obtain the sessionId.
    2. I added the Groovy script suggested by you as a test step withing the same test case.
    3. In the other test case, where I need that sessionId, I did a point and click step by doing a GetData > Test Suite > CreateNew > Property[SessionId]
    But this is not working when I ran the test suite.
    I am getting an error that the Session Id is invalid. I am wondering if step3 is wrong. Could you please suggest?

    Thanks
  • SoapRookie's avatar
    SoapRookie
    Occasional Contributor
    Hi Reshma,

    I was able to do it by creating a Property Transfer of SessionId from the Login test case to the Test Suite. Then I created a Run TestCase test step in the test case where I needed to access this SessionId. I was able to get the SessionId to all the test steps in this test case.
    Thank you for your time.

    SoapRookie