Thursday, July 9, 2015

Parameterizing Tests

There have been a lot of questions asked of us recently about how to parameterize tests and it may be helpful to review some of the options.

Data Synthesis
The main mode of injecting test data in parametric form, one test run per line of input file, is done with eValid's Data Synthesis feature, described in this manual page: Data Synthesis Mode

In this mode eValid, reads lines from an input file that have value assignments to parameters. It matches these up with the same parameters in the script file, does the string substitution, and runs the script. eValid sets up the test execution, substitutes parameters and makes one run per line in the file.

Your script file has to contain this command at the top (before the first parameter usage):
DataSynthesis "filename"
The filename itself can be just the local filename, in your project directory. Or it can be a full Windows path name like this:
C:/TestArea/data-synthesis.txt
The actual file is a text-only file, but yes, of course you can create a text only file using a spreadsheet.

Value Extraction
Another way to feed data into your playback script that also takes advantage of the parametric macro-substitution feature is what eValid calls the "value extraction" feature, described in this manual page: Value Extraction Command Explanation

As you can see from that description , if you have a data input file that looks like this:
$VAL1=100 $VAL2=200 $VAL3=300 ...
$VAL1=101 $VAL2=201 $VAL3=301 ...
$VAL1=102 $VAL2=202 $VAL3=302 ...
$VAL1=103 $VAL2=203 $VAL3=303 ...
and at some point in your script you want to copy in the entire line from this file then you simply tell your script to do this with the command:
!file|number
where file is the name of the file and number is the line number in the file. For example, If you type in:
...!file!2...
you will get line 2, that is:
$VAL1=101 $VAL2=201 $VAL3=301 ...

LoadTest Parameter Setting 
You can also drop parametric values into each one of multiple instances of the eValid browser during a LoadTest Run using the $NAME=value format available in the LoadTest file, as described in this manual page: Script String/Parameter Substitution

As you can see, it is entirely possible to have 100's of different browsers running 100's of different data values, all in parallel. It takes some planning and some construction time, but the effort is well worth the payoff.


No comments: