Run parametrized tests in parallel
If you use Perfecto native automation scripts, you will probably face the need to parametrize and structure them in test suits. You can even execute your tests in parallel to assure properly structured regression and smoke tests and to save time running the executions. To automate this process, you can use the Scheduler.
To learn how to create parameterized tests, watch this video or review the instructions following the video.
To create parameterized tests:
- Create the test you want to parametrize, adding all steps and commands for one fully functional scenario.
-
Create a new test script with an open device, add your already created full test as many times as your parametrization needs, and then close the device.
-
For each of the added copies of your script, add the values that you want to use in your parametrization. By doing this, each of the executions of your script will use different data values.
These steps will execute your test against the same device one after another.
-
To ensure this mode of executions, confirm that your execution mode is either cleared or configured with the sync or embedded option, as shown in the following image.
-
To ensure that your execution won't stop if any of the scenarios fails, on the On Error tab, from the drop-down menu, select CATCH. This way, if any of the parametrized versions of your main script fails, the next version still starts.
You can do the same for the Open Device command. By doing this, you will ensure that if your device is busy, you can implement a device handling mechanism.
-
If you need to run your tests on several devices but one after another, create variables containing the devices you need.
-
Double-click the scripts themselves to change the way they allocate devices to use the specific variable you created.
-
From the More Menu, clear the Allocate devices automatically checkbox.
To create parallel executions:
-
In your test suit/runner (the main test that holds the parameterized options of your scripts), remove the open and close device commands. The test suite will contain only your scripts, as shown in the following image.
-
Double-click your scripts and change the script execution mode to Async.
- To automate the test executions, see Scheduler - scheduling script executions.
- (Optional) To improve your reporting further, see Add job name and job number to CI jobs, where you can follow the steps and add a dynamic job number and name.