Run UFT One tests in a Windows Docker container

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

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

Available UFT One Docker images

Use UFT One docker images to run mobile or API tests in a Windows Docker environment. The images are available from https://hub.docker.com/r/functionaltesting/.

All images support the following functionality:

  • Run mobile tests using Digital Lab (UFT Mobile) and UFT One automation scripts.
  • Run a single API test in a Windows Docker environment.

The following images are available:

  • The uft image is a full Windows Docker image with UFT One installed.

  • The uft_lite image provides the same functionality as the full image, but is much smaller and faster to download.

  • Two UFT One Utility Docker images are available, based on the uft or uft_lite image but also include additional utility tools.

Advantages to using the UFT One Utility Docker image

This image enables the following enhancements:

Simpler test running Run your UFT One tests more smoothly and easily in a Windows Docker environment using a single command.
Run multiple API tests You can now use one Docker command to run of all the API tests stored in a specified folder.
Convert run results to a JUnit report After the tests run, use the ReportConverter utility to create a JUnit report from the run results.
Use docker images in your CI-CD pipelines Use the utility tools incorporated in the docker image to run tests on the docker image from your CI-CD pipelines.

The UFT One Utility Docker image is released more frequently than the uft and uft_lite images. We recommend that you use this image to run your API tests. For instructions on using this image, use the documentation available with the image on the Docker Hub.

Back to top

System requirements

You can run UFT One tests in a Windows Docker container on one of the following operating systems:

Using uft images Using uft_lite images
Windows Server 2016

Windows Server 2019 (10.0.17763.1637 or later)

Windows 10

Versions: 2004, 1903, 1803

Windows 10

Versions: 2004, 1909, 1903, 1809

Back to top

Overview: Use UFT One's docker images

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

This section explains how to set up the UFT One Windows Docker container:

Prerequisites

  1. 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.

  2. Enable hardware and software virtualization on your computer.

  3. Make sure your docker is configured to run Windows containers. (Right-click the Docker tray icon and see that Switch to Linux containers is displayed in the menu options.)

Pull the image and create the container

Pull the UFT Docker image and create the Docker Windows container:

  1. To pull the UFT Docker image, run the following command in a command window on the host computer:

    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.

  2. To create the Docker Windows container from the UFT Docker image, run the following command in a command window on the host computer:

    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 images are based on Windows Server 2016 (uft images) and Windows Server 2019 (uft_lite images). 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 or -–isolation=process to the command may solve the problem.

Install a UFT One 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-Digital Lab (UFT Mobile) integration, create UFT One automation scripts, and then run the scripts in the docker container.

Configure the integration

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

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

Create a UFT One mobile automation script

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 Digital Lab (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 Digital Lab (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 Digital Lab (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 = "<Digital Lab (UFT Mobile) server>"
qtApp.Options.MCConnection.Port = "<Digital Lab (UFT Mobile) server port>"
qtApp.Options.MCConnection.Username = "<Digital Lab (UFT Mobile) server user name>"
qtApp.Options.MCConnection.Password = "<Digital Lab (UFT Mobile) server user password>"
qtApp.Options.MCConnection.UseSSL = false
qtApp.Options.MCConnection.SharedSpace = "<Digital Lab (UFT Mobile) server TenantID>"
qtApp.Options.MCConnection.WorkSpace = "<Digital Lab (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 Digital Lab (UFT Mobile) server connection details with the values from your Digital Lab (UFT Mobile) server.

For more details, see:

Run the 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 an API test in a Docker container

Run your UFT One 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.

Run tests in a new container

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\UFT One\bin\HP.ST.Fwk.InternalExecuter.exe" -test C:\tests\apitest

Run the 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\UFT One\bin\HP.ST.Fwk.InternalExecuter.exe" -test C:\tests\apitest -reportPath result1

Back to top

Use Jenkins to trigger an API test run in Docker

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 an API test in a Docker container

Back to top

See also: