Forum Discussion

zkerbo's avatar
zkerbo
New Contributor
8 years ago

Property Transfer Question

Hello,  I have a TestCase where I need to generate x number of unique strings. Let's say 10 email addresses. The way I am doing things now is I have 10 groovy script test steps that randomly create ...
  • groovyguy's avatar
    8 years ago

    I typically create a properties step and use a groovy script to write my properties to that with a groovy test step. If I need multiple of the same value per request, I name them differently.

     

    Example:

    CustomerEmail

    ManagerEmail

    etc.

     

    If I need multiple data-sets for multiple requests, I'd have:

    CustomerEmail1

    ManagerEmail1

    CustomerEmail2

    ManagerEmail2

     

     

    Then in my groovy script I have a for-loop that iterates through how many data-sets I need, and generates how many elements I need per dataset.

     

    Here's a very quick groovy script example. 

     

     

    def propertiesStep = testCase.testSteps["Properties"];
    
    def generateEmail()
    {
         // insert email generation script here
    } for(int i = 1; i < 100; i++) { propertiesStep.setPropertyValue("CustomerEmail" + i, generateEmail()); propertiesStep.setPropertyValue("ManagerEmail" + i, generateEmail());
    i++; }