Skip to content

Groovy script to generate "random" names, last names and emails for using in SoapUI

Notifications You must be signed in to change notification settings

abstracta/groovyDataGenerator4SoapUI

Repository files navigation

groovyScripts4SoapUI

Groovy scripts to manage test data in SoapUI projects.

  • takeDataFromFile.groovy get the data from the line lineNo in id.txt file and set the property ID in SoapUi with that value
  • personsData.groovy generates "random" names, last names and emails in SoapUI
  • id.groovy could generate random 8 digit valid id's or validate an existing one analyzing the validation digit
  • mongoDBExamples has examples for connecting to a Mongo database and performing actions over collections.

takeDataFromFile

In order to have this script working, you should replace route-to-file in line 4 with the directory where id.txt file it's located, and declare ID and lineNo properties in SoapUI.

If you want to start getting data from the first line you should set lineNo to 0 in SoapUI.

personsData

It get the names from a list of 3096 elements and the last names from a list of 624 elements, that gives a chance of 1 in 1931904 of getting the same combination of name + last name. Both lists were taken from the Faker Library.

To increase the randomness, both name and last name are concatenated with a random integer from 0 to 999. That increase the chance of getting the same combination of strings for name and last name to 1 in 1921904000000.

Then, the email is generated as [email protected].

An example of the result could be:

Finally, each value is saved in a SoapUI property (Name1, Lastname1 and Email1).

id

It's the Groovy version of this JavaScript code.

It has 4 functions:

  • validation_digit(id) - Generates the validation digit from the other remaining 7 digits of the id
  • validate_id(id) - Validates if the id has a correct format, analyzing the validation digit
  • random_id() - Returns a random valid id between 0 and 9.999.999 with the validation digit
  • clean_id(id) - It basically removes any character that it's not a number from the id (for example "." or "-")

Finally, the script creates a random id and set a SoapUi property named "ID1" with its value.

mongoDBExamples

In order to use this script you will need the mongo-java-driver jar on the lib folder where you have SoapUI installed.

This script defines a class that has methods for connecting to a client and getting collections from a database, the methods are the following:

  • client() - Creates and returns a new Mongo Client.
  • collection(databaseName, collectionName) - Gets a Mongo database and returns a collection.

In addition to that, there are some examples that show how to perform some actions over collections, such as iteration over elements, finding documents and making updates.

About

Groovy script to generate "random" names, last names and emails for using in SoapUI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages