Run UFT One tests in a Windows Docker container

Use a UFT One Docker image to speed up UFT One maintenance and test runs.

  • UFT One's Docker image enables you to run mobile tests in a Windows Docker environment, using UFT Mobile and UFT One automation scripts.
  • The UFT One 15.0.1 docker image also supports running API tests in a Windows Docker environment.
  • The uft-lite image provides the same functionality as the full image, but is much smaller and faster to download.

This topic assumes some knowledge in Docker management and does not describe the Docker management steps in detail.

System requirements

Running UFT One tests in a Windows Docker container requires a Windows Server 2016 operating system.

Back to top

Overview

To run UFT One tests in a docker container, you must perform the following steps, which are described in more detail below:

  1. Pull the UFT One docker image from the Docker hub
  2. Create a container based on that docker image
  3. Install a concurrent UFT One license on the container.
  4. Run your UFT One tests in the docker containers.

You must install a UFT One license on each UFT One docker container that you use. You can handle this in one of the following ways:

  • After installing the UFT One license, you can commit this container to a new image. Then, create all subsequent containers based on the new image, and avoid additional license installations.

  • After installing the UFT One license, use the same container for subsequent runs, stopping and starting the container as needed.

  • Use a docker command that creates a new container, installs the concurrent license, and then runs the tests.

Back to top

Set up the UFT One Windows Docker container

Prerequisite

Install and set up Docker on your computer so it can pull Docker images from the Docker Hub. This sets up your computer as a docker host.

Install the Docker Engine and client as described in the Microsoft documentation.

For details on setting up Docker, see the Docker documentation.

Pull the UFT Docker image

In a command window on the host computer, run the following command:

docker pull <UFT One Docker image name>[:tag]

The UFT One Docker image name can be functionaltesting/uft or functionaltesting/uft-lite

[:tag] is an optional flag to add for a specific UFT One image version. By default the tag value is latest.

Create the Docker Windows container from the UFT Docker image

In a command window on the host computer, run the following command:

docker run -it --name <container name> <UFT One Docker image name>[:tag] "cmd.exe"

This command creates the container and also opens a command window that belongs to the container. Use this window in the next step to install a UFT One license.

Note: The UFT One Docker image is based on Windows 10. If you use a docker host with a different OS, you may encounter a message about OS incompatibility. Consult the Docker documentation to mitigate this issue. For example, adding --isolation=hyperv to the command may solve the problem.

Install a UFT One concurrent license in the Docker container

UFT One's Docker image is supported for concurrent licenses only, a license being consumed from the server each time a docker container uses UFT One.

In a command window for your docker container, install a concurrent UFT One license on the container. For details, see Manage licenses with the command line.

Back to top

Run mobile tests in your docker container

After installing and configuring your docker container, set up the UFT One-UFT Mobile integration, create UFT One automation scripts, and then run the scripts in the docker container.

Configure UFT One's integration with UFT Mobile

To run tests on mobile devices, make sure that UFT Mobile and your applications are set up for the integration. For details, see Set up UFT Mobile to integrate with UFT One.

The UFT One automation scripts that you create in the next step set up the connection to UFT Mobile.

Create a UFT One automation script with UFT Mobile

Running UFT One tests on your Docker container is done via a UFT One automation script that contains the specific steps required to run your tests in UFT Mobile.

Your script should include the following parts:

  • Launch UFT One.
  • Use the MCConnection Options object to configure the UFT One's connection to UFT Mobile.
  • Use Launch methods to start your application.
  • Run your UFT One test.
  • Close the test.
  • Close UFT One.

The following is a sample script used to run a specific test in UFT Mobile.

Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Set qtApp = CreateObject("QuickTest.Application")
qtApp.Launch
qtApp.Visible = True
qtApp.Options.MCConnection.Server = "<UFT Mobile server>"
qtApp.Options.MCConnection.Port = "<UFT Mobile server port>"
qtApp.Options.MCConnection.Username = "<UFT Mobile server user name>"
qtApp.Options.MCConnection.Password = "<UFT Mobile server user password>"
qtApp.Options.MCConnection.UseSSL = false
qtApp.Options.MCConnection.SharedSpace = "<UFT Mobile server TenantID>"
qtApp.Options.MCConnection.WorkSpace = "<UFT Mobile server workspace ID>"
qtApp.Options.MCConnection.ShowRemoteWndOnRun = true
qtApp.Open "<UFT script path>", True
Set qtMobileLauncher = qtApp.Test.Settings.Launchers("Mobile")
qtMobileLauncher.Lab = "MobileCenter"
qtMobileLauncher.Device.OS = "<Device OS Type>"
qtMobileLauncher.Device.ID = "<Device UDID>"
Set launchApp = qtMobileLauncher.LaunchOnStart
launchApp.IsPackaged = True
launchApp.Counter = 1
qtMobileLauncher.InstallApps = true
qtMobileLauncher.RestartApps = true
qtMobileLauncher.UninstallApps = false
qtMobileLauncher.TrackCPUMetric = true
qtMobileLauncher.TrackMemoryMetric = true
qtMobileLauncher.TrackFreeMemoryMetric = true
qtMobileLauncher.TrackLogs = true
Set qtpResultsOpt = CreateObject("QuickTest.RunResultsOptions") 'create the run Results Options object
qtpResultsOpt.ResultsLocation = “<HTML report path>”
qtApp.Test.Run qtpResultsOpt ' Run the test
qtApp.Test.Close
qtApp.Quit

Note: If you copy this text for use in your automation script, make sure to replace the placeholders for the UFT Mobile server connection details with the values from your UFT Mobile server.

For more details, see:

Run your UFT One automation script in the Docker container

In a command window on the host computer, run the following command:

docker run -it --name <container-name> -v <host-directory>:<container-directory> <UFT One Docker image name>[:tag] cmd //Add [:tag] to specify a UFT image version. Default is 'latest'.

Install a concurrent UFT One license on the container. See Manage licenses with the command line.

cd <container-directory>

<script-name>.vbs //Run the AOM script

where:

Parameter name Description

<container-name>

The name of your Docker container. Use a unique container name to create a new container.
<host-directory>

The full path to the host directory on the machine where the automation script is stored.

This directory is mounted to the <container-directory> location on your Docker container.

<container-directory> The full path to the directory on your Docker container where the <host-directory> is mounted.
<UFT One Docker image name>

The UFT One Docker image name. Can be functionaltesting/uft or functionaltesting/uft-lite.

<script-name> The name of the UFT One automation script configured to run your UFT One tests.

Note: Include the optional [:tag] for a specific UFT One image version. By default, the tag value is latest.

Back to top

Run a UFT One API test in a Docker container

Supported on UFT One versions 15.0.1 and later

Run your API test in one of the ways described below.

Prerequisites

  • Set up a UFT One Docker container as described above.
  • On the host computer, create a local directory for your API tests and store the test folders there. Docker will mount this directory to a directory in your Docker container.

To run the tests in a new container based on an image you created with the UFT One license installed

In a command window on the host computer run the following command:

docker run -v <host-test-directory >:<container-test-directory> --name <container-name> <image-with-licensed-uft> "<UFT One installation folder>\bin\HP.ST.Fwk.InternalExecuter.exe" -test <container-test-directory> -reportPath <report-directory-path>

where:

Parameter name Description

<container-name>

The name of the Docker container to create for this run.

Use a unique container name to create a new container.

<host-test-directory>

The full path to the API test on the host computer.

This directory is mounted to the <container-test-directory> location on your Docker container.

Example: C:\DockerProject\tests\apitest, where C:\DockerProject\tests is the local directory you created for your tests and apitest is the name of the test you stored there.

Note: The test-name part of this path is case sensitive.

<image-with-licensed-uft> The image that you committed after installing the UFT One license. This image is used to generate the new container that runs your test.
<container-test-directory> The full path to the directory on your Docker container where the <host-test-directory> is mounted.
<report-directory-path>

(Optional) The path to the directory in which to store the test results. Provide a relative path, relative to the <container-test-directory>.

By default, the results are saved under the test folder, overwriting the results of any previous runs.

For example if your host test directory was C:\DockerProject\tests and the test name is apitest, the command would look like this:

docker run -v C:\DockerProject\tests\apitest:C:\tests\apitest --name apirun functionaltesting/uft:latest "C:\Program Files (x86)\Micro Focus\Unified Functional Testing\bin\HP.ST.Fwk.InternalExecuter.exe" -test C:\tests\apitest

To run test on an existing container

In a command window on the host computer run the following command:

docker exec -it <container-name> "<UFT One installation folder>\bin\HP.ST.Fwk.InternalExecuter.exe" -test <container-test-directory> -reportPath <report-directory-path>

where:

Parameter name Description

<container-name>

The name of the existing Docker container to use for this run.

Tip: Make sure the container is running before you run this command.

<container-test-directory> The full path to the directory on your Docker container where the <host-test-directory> is mounted.
<report-directory-path>

(Optional) The path to the directory in which to store the test results. Provide a relative path, relative to the <container-test-directory>.

By default, the results are saved under the test folder, overwriting the results of any previous runs.

For example if your container name is apirun, the host test directory was C:\DockerProject\tests and the test name is apitest, the command would look like this:

docker exec -it apirun "C:\Program Files (x86)\Micro Focus\Unified Functional Testing\bin\HP.ST.Fwk.InternalExecuter.exe" -test C:\tests\apitest -reportPath result1

Back to top

Use Jenkins to trigger a UFT One API test run in Docker

Supported on UFT One versions 15.0.1 and later

After setting up your Docker container, you can use Jenkins to trigger the UFT One API test run:

  1. On the host computer, create a local directory for your API test and store the test there.

  2. Add the Docker container as a slave in Jenkins.

  3. Add a build step and select “Execute Windows batch command”.

  4. In the step, insert the command to trigger the test. Do one of the following: 

    • Create a new container based on a UFT One Docker image that was committed after installing a license and then run the API tests.

      docker run -v <host-test-directory >:<container-test-directory> --name <container-name> <image-with-licensed-uft> "<UFT One installation folder>\bin\HP.ST.Fwk.InternalExecuter.exe" -test <container-test-directory> -reportPath <report-directory-path>

    • Create a new container based on the downloaded UFT One image, install a concurrent license on the container, and then run the API tests:

      docker run -dit --name <container-name> -v <host-test-directory >:<container-test-directory> <UFT One Docker image name>[:tag] cmd.exe /C " " <UFT One installation folder>/bin/HP.UFT.LicenseInstall.exe" concurrent <license ID> <license version> <primary server name/address>:<port> & "<UFT One installation folder>/bin\HP.ST.Fwk.InternalExecuter.exe" -test <container-test-directory> -reportPath <report-directory-path>

    For details on this command, see Run a UFT One API test in a Docker container

Back to top

See also: