Forum Discussion

steve_rivers's avatar
Occasional Contributor
5 months ago

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 DataGenerato...
  • nmrao's avatar
    5 months ago

    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]  } getRandomDepartment()

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

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

     You can quickly try executing the same here