18 November 2008 - 2.5 user guide blog eclipse intellij netbeans maven PDF files forums bugs sourceforge eviware.com


Eviware Logo

DataGen TestStep

The "DataGen" TestStep can be used to generate data to be used as input in your TestCases, for example number or date sequences, random selections, etc. The generated data is available as properties and can thus be referred to with Property Transfers and Expansions just like any other property. Create a DataGen step as usual from the TestCase popup menu. Double-clicking the TestStep will open the following editor:

The soapUI Pro DataGen Editor Options

The table at the top contains the defined DataGen properties with their common settings (see below), selecting a property in the table shows the corresponding configuration panel at the bottom.

Add and delete properties using the toolbar buttons at the top, the Add button opens the following dialog:

The soapUI Pro DataGen Add Panel

The types of property available are currently:

  • Script : specifies a property whose value is created by a groovy script
  • Template : specified a block of content to be used when building other values
  • Number : allows for number-based sequential creation of property values (integers, dates, etc)
  • List : specifies a list of possible values to return when the property is read

Script

The configuration panel when selecting a Script property is as follows:

The soapUI Pro DataGen Script property configuration

Specify a groovy script that returns the desired value for the property. For example you could create a property that contains today date in a nice format:

def sdf = new java.text.SimpleDateFormat("yyyy-MM-dd")
return sdf.format( new Date())

Anywhere in your TestCase where PropertyExpansions are available, you could use this with ${DataGen#today}, which would be replaced with todays date when used.

Template

The Template configuration-panel is equally simple:

The soapUI Pro DataGen Template property configuration

This type is useful for building complex multiple-line properties, for example to be inserted into requests. Here one can specify any content that can also contain property-expansions, for example

<date><today>${DataGen#today}</today></date>

Which would evaluate to an XML element containing todays date when used in conjunction with the above defined script-property.

Number

The soapUI Pro DataGen Number property configuration

This property type is used for generating lists of numbers; the start/end/step values specify the range of the sequence and its increment (or decrement). The pattern specifies how to format the property value using the java DecimalFormat class (see this page for some examples). Selecting the Random check box will select a random number within the specified range instead (with specified step as modulus). The Persist options will save the last number when saving the project so the sequence can continue at its last value if required (remember though that projects are not saved after running through the command-line tools).

So for example if you want to generate random USD currencies between 100 and 1000 USD with a 50 USD increment you could specify the following:

The soapUI Pro DataGen Number example

List

Another straight-forward configuration:

The soapUI Pro DataGen List property configuration

The above screen shot configures a list of weekdays and sets the property to select a random line each time it is read, if the Randomize check box is not checked, the values are used sequentially.

Common Configuration Properties

The table listing the properties contains two more configuration possibilities; Mode and Shared.

Mode controls how the property value is evaluated and has two possible values; READ and STEP. READ will re-evaluate the property each time it is referenced. This works ok with (for example) our today property created above and any other property that can/should have its value recreated every time. This may not always be desired though; for example you might be using a Number property to generate a unique ID to use during the entire run of a TestCase. If you are referring to this ID in several requests/scripts/etc, setting it to READ would give you a new value every time, instead of one value that is always the same. In this case set the Mode to STEP and the property will be evaluated when the DataGen TestStep is executed during the execution of the containing TestCase. Please note that before this execution the property will not have any value at all so be sure to put the DataGen before any steps that might be referring to it.

Shared controls whether the property should be shared between threads in a LoadTest; maybe you are using a Number property to create unique sequential IDs and also need them to be unique across threads in which case this property is required to be shared, otherwise each thread would create the same sequence of values which would then not be unique across all runs.


Next: Load Testing Web Services with soapUI