Forum Discussion

Flora's avatar
Flora
New Contributor
5 years ago
Solved

How could be a good way to create a member which would be used in many test cases of a test suite?

I am just starting to use SoapUI recently. Can someone nicely help me figure out this problem? I have a method to create a member which would be used in many test cases of a test suite only. So won't be a good way to put the method in the global function I guess. 

  • Lucian's avatar
    Lucian
    5 years ago

    Something like jkrolczy should do the trick. However, I would advise using a Test Suite Setup script for this. So the scenario would look like this:

     

    1. Before a certain test suite is started, ReadyApi executes the Setup script (which generates the memberId and password and saves them at Test Suite level)

    2. Every Test Case references that memberId and password.

8 Replies

  • Lucian's avatar
    Lucian
    Community Hero

    Hi Flora,

     

    What do you mean by member? Can you tell a little bit more about what you're trying to do?

    • Flora's avatar
      Flora
      New Contributor

      Hi Lucian ,

       

      Thank you for your reply!

       

      Sure! For example, I have a method to generate a memberID and password so that I can login using them to check some functionalities. 

       

      I have a test suite which includes a few test cases and all of those cases have the same step: generate a new memebrID, pwd and login.

       

      My question is that is there a better way to generate the memberID in the test suite level so that all the cases under that test suite can use the memberID? 

      • jkrolczy's avatar
        jkrolczy
        Regular Contributor

        You could create a test case in your TestSuitte that would generate a memberID and password.

        This would be the first testcase to run in your suite.

        Not sure how you are creating these new memberID and Pwd ??

         

        TestSuite level : Custom Properties: create variables   i.e.  memberID and Pwd

         

        Using Groovy script in this test cases you can extract these from a Response

        or however you know these values

        Then store them into a TestSuite: Custom Properties variables   i.e.  memberID and Pwd

         

        testRunner.testCase.testSuite.project.setPropertyValue( "memberID ", <your value>);
        testRunner.testCase.testSuite.project.setPropertyValue( "Pwd", <your value>);

         

        Then in the following test cases where you need these values, refernce your TestSuite level

        using this in the appropiate spot for your memberID  or Pwd

         

        ${#TestSuite#memberID}

        ${#TestSuite#Pwd}

         

         

    • Lucian's avatar
      Lucian
      Community Hero

      Something like jkrolczy should do the trick. However, I would advise using a Test Suite Setup script for this. So the scenario would look like this:

       

      1. Before a certain test suite is started, ReadyApi executes the Setup script (which generates the memberId and password and saves them at Test Suite level)

      2. Every Test Case references that memberId and password.

      • Flora's avatar
        Flora
        New Contributor

        Hi Lucian 

         

        Thanks again. I think using the test suite setup script would be the best way for this. The problem is I don't know how to do it? It'd be nice you can send me some materials/ documentation related to this to learn?

         

        Thanks, heaps!