Forum Discussion

steve_rivers's avatar
steve_rivers
Occasional Contributor
4 months ago
Solved

Auto-Populate Data Generator "Value from set" values

Is there anyway to automatically populate the values list in the "Value from set" option in the Data Generator section of the Data Source step? Digging through the API definition for the DataGenerator DataSource step https://support.smartbear.com/readyapi/apidocs/3.0.0/pro/com/eviware/soapui/impl/wsdl/teststeps/datasource/DataGenerator/UI/DataGeneratorDataSource.html I could probably do this with a call to setConfig but was wondering if I was missing something easier?

We need to run some load tests on a system to do some troubleshooting. Each request needs to submit one of a selection of id's. This would be simple and not a problem except that these id's change on a daily basis. We also want these to run with minimal need for user intervention.

Regards

 

 

  • One can use own groovy data source to generate in such situation.

    For example there are many departments in an organization and want to use one of its value randomly.

    Here the script goes:

    def rand = new Random()
    def departments = ['HR', 'Fecilities', 'R&D', 'Services', 'Security', 'IT', 'Sales', 'Marketing', 'Finance']
    def getRandomDepartment = {  departments[rand.nextInt(departments.size -2) + 1]  }
    
    log.info getRandomDepartment()

    To give some more idea, generate employee data, say: 

    //Sample data source generation using department 
    log.info "Employee ID, Department"
    (1..10).each { log.info "$it, ${getRandomDepartment()}" }

     You can quickly try executing the same here

1 Reply

  • nmrao's avatar
    nmrao
    Champion Level 3

    One can use own groovy data source to generate in such situation.

    For example there are many departments in an organization and want to use one of its value randomly.

    Here the script goes:

    def rand = new Random()
    def departments = ['HR', 'Fecilities', 'R&D', 'Services', 'Security', 'IT', 'Sales', 'Marketing', 'Finance']
    def getRandomDepartment = {  departments[rand.nextInt(departments.size -2) + 1]  }
    
    log.info getRandomDepartment()

    To give some more idea, generate employee data, say: 

    //Sample data source generation using department 
    log.info "Employee ID, Department"
    (1..10).each { log.info "$it, ${getRandomDepartment()}" }

     You can quickly try executing the same here