UFT/QTP

UFT Parallel Test Execution

Parallel testing concurrently tests multiple applications or components of an application in order to reduce overall test execution time and to increase test coverage. Now UFT also support parallel test execution with the version 14.03 .UFT got capability to run parallel testing on mobile. Use the ParallelRunner CLI tool to run multiple UFT One tests in parallel. You can run GUI tests on mobile devices and web browsers, and you can also run API tests. The ParallelRunner also supports API tests called by GUI tests, and vice versa.

Prerequisite

1.Each web test consumes a single concurrent license and requires a concurrent license server to test in parallel.

2.Close UFT One. ParallelRunner and UFT One cannot run at the same time.

Parallel Test Execution

ParallelRunner is a Command Line Interface (CLI) tool, which enables the capability to run tests in parallel. It means that you need to use or run this tool via command prompt.

Run your tests in parallel from the command line, defining your test and environment details using the following methods:

  1. Passing test and environment details as command line parameters.
  2. Passing test and environment details within a .json file.

Passing test and environment details as command line parameters

This method is simple and easy to use when you have single test or configuration. You will need to run east test separately with individual commands

  • Launch Command Prompt
  • Change directory to UFT Installation bin folder if not already
  • Use command below to run your test

Command line options

Use the following options when running tests directly from the command line.

  • Option names are not case sensitive.
  • Use the a dash (-) followed by the option abbreviation, or a double-dash (--) followed by the option’s full name.
-t--testString. Required.Defines the path to the folder containing the UFT One test you want to run.If your path contains spaces, you must surround the path with double quotes (“”). For example: -t “.\GUITest Demo”Multiple tests are not supported in the same path.
-b
--browsers
String. Optional. Supported for web tests.Define multiple browsers using semicolons (;). ParallelRunner runs the test multiple times, to test on all specified browsers.Supported values include:ChromeChrome_HeadlessChromiumEdge (UFT One 15.0.1 or later)EdgeFirefoxFirefox64IEIE64SafariNotes:This value overrides any settings defined in the Record and Run Settings, and any browser parameterization configured in the test. The WebUtil.LaunchBrowser method is not affected.We recommend using consistent casing for the browser name, to avoid separate columns in the run result report for the same browser type. For more details, see Sample ParallelRunner response and run results.Safari is supported via testing on a remote Mac machine. For more details, see Connect to a remote Mac computer.
-d--devicesString. Optional. Supported for mobile tests.Define multiple devices using semicolons (;). ParallelRunner runs the test multiple times, to test on all specified devices.Define devices using a specific device ID, or find devices by capabilities, using the following attributes in this string:deviceID. Defines a device ID for a specific device in the UFT Mobile device lab. This attribute cannot be used with other device capability attributes.manufacturer. Defines a device manufacturer.model. Defines a device model.osType. Defines a device operating system.One of the following: AndroidiOSWindows Phone.If this value is not defined, UFT One uses the osType defined in the test’s Record and Run settings as a default.osVersion. Defines a device operating system version. One of the following:Any. Leaves the version number undefined.A specific version. For example: 10.0A boolean operator and version value. For example: >10.0<10.0>=10.0, or <=10.0Note: Do not add extra spaces around the commas, colons, or semicolons in this string. We recommend always surrounding the string in double quotes (“”) to support any special characters.For example:–d “manufacturer:apple,osType:iOS,osVersion:>=11.0”
-dt--dataTablesString. Optional. Supported for web or mobile tests.Defines the path to the data table you want to use for this test. UFT One uses the table you provide instead of the data table saved with the test.Define multiple data tables using semicolons (;). ParallelRunner runs the test multiple times, to test with all specified data tables.If your path contains spaces, you must surround the path with double quotes (“”).For example: -dt “.\Data Tables\Datatable1.xlsx;.\Data Tables\Datatable2.xlsx”.
-o--outputString. Optional.Determines the result output shown in the console during and after the test run.Supported values include:Normal. (Default) Run output is automatically updated in the console.For example, the run status changes from Pending to Running, and then to Pass or Fail, and so on.Static. The report path is displayed at the beginning of the test run, and then the run status is shown when the test is complete.Disable. No output is shown in the console at all.
-r--reportPathString. Optional.Defines the path where you want to save your test run results. By default, run results are saved at %Temp%\TempResults.If your string contains spaces, you must surround the string with double quotes (“”). For example: – r “%Temp%\Temp Results
-rl--report-auto-launchOptional.Include in your command to automatically open the run results when the test run starts. Use the -rr–report-auto-refresh option to determine how often it’s refreshed.For more details, see Sample ParallelRunner response and run results.
-rn--reportNameString. Optional.Defines the report name, which is displayed in the browser tab when you open the parallel run’s summary report. By default, the name is Parallel Report.Customize this name to help distinguish between runs when you open multiple report at once. UFT One also adds a timestamp to each report name for this purpose.If your string contains spaces, you must surround the string with double quotes (“”). For example: – rn “My Report Title
-rr--report-auto-refreshOptional.Determines how often an open run results file is automatically refreshed, in seconds.For example: -rr 5Default, if no integer is presented: 5 seconds.
-tp--testParametersString. Optional. Supported for web and mobile tests.Defines the values to use for the test parameters. Provide a comma-separated list of parameter name-value pairs.For test parameters that you do not specify, UFT One uses the default values defined in the test itself.For example: -tp “param1:value1,param2:value2”Define multiple test parameter sets using semicolons (;). ParallelRunner runs the test multiple times, to test with all specified test parameter sets.For example: -tp “param1:value1, param2:value2; param1:value3, param2:value4”If your parameter value includes commas (,), semicolons (;), or colons (:), surround the value with a backslash followed by a double quote (\”).For example, if the value of TimeParam is 10:00;00, use:-tp “TimeParam:\”10:00;00\””Note: You cannot include double quotes () inside a parameter value using the command line options. Instead, use a JSON configuration file for your ParallelRunner command.
-we--wait-for-environmentOptional. Supported for mobile tests.Include in your command to instruct each mobile test run to wait for an appropriate device to become available instead of failing immediately if no device is available

To run tests from the command line, use the syntaxes defined in the sections below. Use semicolons (;) to separate the alternatives. Parallel runner runs the test as many times as necessary, to test all combinations of the alternatives you provide.

Web test command line syntax

ParallelRunner -t <test path> -b <browser> -r<results path>

For example:

ParallelRunner -t "C:\GUIWebTest_Demo" -b "Chrome;IE;Firefox" -r "C:\parallelexecution"

If you specify multiple browsers, the test is run multiple times, one run on each browser.

Mobile test command line syntax

From the command line, run each mobile test using the following syntax:

ParallelRunner -t <test path> -d <device details> -r <results path>

For example:

ParallelRunner -t "C:\GUITest_Demo" -d "deviceID:HT69K0201987;manufacturer:samsung,osType:Android,osVersion:>6.0;manufacturer:motorola,model:Nexus 6" -r "C:\parallelexecution"

API test command line syntax

From the command line, run each API test using the following syntax:

ParallelRunner -t <test path> -r <results path>

For example:

ParallelRunner -t "C:\APITest" -r "C:\API_TestResults"

Example for different scenarios: 

Run the test three times, one for each browser:

ParallelRunner -t "C:\GUIWebTest" -b "Chrome;IE;Firefox"

Run the test four times, one for each data table on each browser:

ParallelRunner -t "C:\GUIWebTest" -b "Chrome;Firefox" -dt ".\Datatable1.xlsx;.\Datatable2.xlsx"

Run the test 8 times, testing on each browser, using each data table with each set of test parameters.

ParallelRunner -t "C:\GUIWebTest" -b "Chrome;Firefox" -dt ".\Datatable1.xlsx;.\Datatable2.xlsx" -tp "param1:value1, param2:value2; param1:value3, param2:value4"

Passing test and environment details within a .json file

Run ParallelRunner and reference a .json configuration file directly from the command line.In the .json file, you can:

  • Specify multiple tests to run in parallel.
  • Define multiple environments and parameters to use for multiple runs.

To run the ParallelRunner with a .json configuration file

  1. In a .json file, add separate lines for each test run. Use the .json options to describe the environment and parameters to use for each run.
  2. Reference the .json file in the command line using the following command line option:
-cString. Defines the path to a .json configuration file.

Use the following syntax:

ParallelRunner -c <.json file path>

For example:

ParallelRunner -c C:/UFTTests/parallelexecution.json

Sample json file for Mobile

{
   "reportPath":"C:\\parallelexecution",
   "reportName":"My Report Title",
   "waitForEnvironment":true,
   "parallelRuns":[
      {
         "test":"C:\\Users\\qtp\\Documents\\Unified Functional Testing",
         "dataTable":"C:\\Data Tables\\Datatable1.xls",
         "testParameter":{
            "para1":"val1",
            "para2":"val2"
         },
        "reportSuffix":"Samsung_OS_above_6",
         "env":{
            "mobile":{
               "device":{
                  "manufacturer":"samsung",
                  "osVersion":">6.0",
                  "osType":"Android"
               }
            }
         }
      }
   ]
}

Sample json file for Web

{
 "reportPath": "C:\\parallelexecution",
 "reportName":"My Report Title",
 "waitForEnvironment":true,
 "parallelRuns": [
  {
   "test": "C:\\Users\\qtp\\Documents\\Unified Functional Testing",
   "reportSuffix": "Web_Chrome",
   "env": {
    "web": {
     "browser": "Chrome"
    }
   }
  } 
 ]
}

Sample json file for API

{
 "reportPath": "C:\\parallelexecution",
 "reportName":"My Report Title",
 "waitForEnvironment":true,
 "parallelRuns": [
  {
   "test": "C:\\Users\\qtp\\Documents\\API Test",
   "reportSuffix": "API"
  } 
 ]
}

Stop the parallel execution

To quit the test runs from the command line, press CTRL+C on the keyboard.

  • Any test with a status of Running or Pending, indicating that it has not yet finished, will stop immediately.
  • No run results are generated for these canceled tests.

ParallelRunner response and run results

The following code shows a sample response displayed in the command line after running tests using ParallelRunner.

>ParallelRunner -t ".\GUITest_Demo" -d "manufacturer:samsung,osType:Android,osVersion:Any;deviceID:N2F4C15923006550" -r "C:\parallelexecution" -rn "My Report Name"

Report Folder: C:\parallelexecution\Res1

ProcessId, Test, Report, Status

3328, GUITest_Demo, GUITest_Demo_[1], Running -

3348, GUITest_Demo, GUITest_Demo_[2], Pass

n this example, when the run is complete, the following result files are saved in the C:\parallelexecution\Res1 directory:

  • GUITest_Demo_[1]
  • GUITest_Demo_[2]

The parallelrun_results.html file shows results for all tests run in parallel. The report name in the browser tab is My Report Name.

null

 

Limitations of ParallelRunner

  • Parallel Runner Supports running upto four tests in parallel. Which is good for the cases, where you need to run on multiple combination. It will need to wait till execution of your first four combinations are done
  • All Web 2.0 toolkits (ASP dot NET AJAX, Dojo, Ext-JS, GWT, jQueryUI, SiebelOpenUI, and YahooUI) are not supported when using ParallelRunner.
  • Below test objects and methods are not supported if used in your script
    • .Object method
    • WebFile objects
    • SystemUtil.Run method (recommended WebUtil.LaunchBrowser)
  • Run results can be viewed in IE versions 10 or higher

References

https://admhelp.microfocus.com/uft/en/15.0-15.0.2/UFT_Help/Content/User_Guide/parallel-test-runs.htm

Categories: UFT/QTP

Leave a Reply