Run tests in Docker containers

This topic explains how to use OpenText Functional Testing for Developers Docker images to run your tests in Docker containers.

Note: This topic assumes you are familiar with Docker. If you are new to Docker and would like to learn more, see the Docker documentation.

Integrating with Docker

Docker is a software container platform. It is designed to make it easier to create, deploy, and run applications by using containers. Containers include everything required to make software run. They do not bundle a full operating system (like VMs do), only libraries and settings, which make them efficient, lightweight, self-contained systems.

OpenText Functional Testing for Developers provides Docker images enabling you to run your tests in Docker containers.

Docker is supported for all Web and mobile technologies.

Using Docker containers has major benefits for developers, DevOps, and the enterprise:

  • Zero installation. Run tests without having OpenText Functional Testing for Developers installed on your machine.
  • Background execution. Run your tests in the background and continue to work without distraction.
  • Execution box. Use a single command to run the Docker image, run the test, and close the container when the test is done.
  • CI/CD readiness. Streamline software delivery by supporting continuous integration and continuous delivery. For details, see Run tests using a CI system.

Docker images

The following docker images are available:

  • functionaltesting/uftdeveloper. The basic image, which contains the engine and the capabilities to run tests.
  • functionaltesting/uftdeveloper-chrome. The basic image with the addition of a Chrome browser.
  • functionaltesting/uftdeveloper-firefox. The basic image with the addition of a Firefox browser.
  • functionaltesting/uftdeveloper-edge. The basic image with the addition of an Edge browser.

You can use the basic functionaltesting/uftdeveloper image and create a customized image that runs a different browser version. For instructions refer to the Docker Hub documentation.

Tip: To find out which browser versions are included with the image, add the following to the end of the docker command (described in Run the Docker image):

Chrome: google-chrome --version

Firefox: firefox --version

Edge: microsoft-edge --version

The latest version of all docker images come with Java 17 and .NET 8.0 installed.

Standalone mode vs. execution box mode

You can run tests in two modes: standalone or as an execution box.

Standalone

This mode is like running tests remotely.

In this mode, you start the container, which launches the runtime engine. The engine then waits for commands. You run the test separately, on your machine. You may need to update the runtime engine address (IP or host name) in the test in order to connect to the Docker image. When you run the test, the commands are run within the Docker container. You need to stop the container when you are done.

For details on running tests remotely, see Run tests remotely.

Execution box

This mode is like running the runtime engine and the test on the same machine.

In this mode, you run the container, which launches the test within the container and closes the container when the test completes.

License usage

Docker integration is supported only for concurrent licenses. For more details on license types, see Licensing.

When you run the Docker image, you need to indicate which license server to use. You can do that in one of two ways:

  • Using --add-host=license-server:<enter your license address>
  • Using the LFT_LIC_SERVER environment variable. For more details, see License.

Download the Docker image

Before you begin you must first have Docker installed on your machine.

Download one of the following images to your machine using the pull command from a command line:

  • functionaltesting/uftdeveloper-edge

  • functionaltesting/uftdeveloper
  • functionaltesting/uftdeveloper-chrome
  • functionaltesting/uftdeveloper-firefox

For example:

docker pull functionaltesting/uftdeveloper

Run the Docker image

This sections explains how to run your Docker image:

  1. Decide in which mode you want to run the Docker image standalone mode or execution box. For details, see Standalone mode vs. execution box mode.
  2. To run the Docker image in standalone mode:

    Run the following from a command line:

    docker run -it -p 5095:5095 -p 5900:5900 --add-host=license-server:xx.xx.xx.xx <OpenText Functional Testing for Developers container>

    Explanation

    Command / Argument Description
    docker run The Docker CLI command for running the container.
    -it Instructs the Docker to run in the foreground so that you can track the output of the container. You can use Ctrl+C to stop the container.
    -p 5095:5095

    Maps the host's 5095 port (the OpenText Functional Testing for Developers default port) to the container's 5095 port, to connect to the runtime engine.

    -p 5900:5900

    Optional. Maps port 5900 to the container's 5900 port, to connect to a VNC.

    Use this option if you would like to see the Docker container. For example, for debugging purposes.

    When you connect to the VNC client, use the password: PASSWORD

    --add-host=license-server:xx.xx.xx.xx Instructs the container which IP address to use for the license server. Replace xx.xx.xx.xx with your license server IP address.
    <OpenText Functional Testing for Developers container> Instructs Docker to create a container. Possible values: functionaltesting/uftdeveloper, functionaltesting/uftdeveloper-chrome, functionaltesting/uftdeveloper-edge, functionaltesting/uftdeveloper-firefox. Optionally, append :<version number> to the container name. By default the latest version is used.

    Note:  

    • The report is generated from the location as the test is run.
    • You can also use docker's -u <name|uid>[:<group|gid>] option to specify the user to use in the container.
    • If you need to provide a self-signed certificate for the Chrome or Firefox browser to use inside the docker container, see Enable tests to access a web site using a self-signed certificate.

    Use environment variables as required. For details, see Run the docker image with environment variables.

  1. To run the Docker image as an execution box, run one of the following from a command line:

    .NET C#

    For NUnit or MSTest tests:

    To run from a compiled project: 

    docker run -it -p 5900:5900 --add-host=license-server:xx.xx.xx.xx -e RUN_MODE=custom -e RUN_CMD="dotnet test UFTdNUnitTest.dll --settings test.runsettings --filter tests.FTDTest2.TestGetSnapshot" -v <full path on the host’s machine to the project .dll>:/tests -w /tests <OpenText Functional Testing for Developers container>

    To run from the .NET project source code: 

    docker run -it -p 5900:5900 --add-host=license-server:xx.xx.xx.xx -e RUN_MODE=custom -e RUN_CMD="dotnet test --settings test.runsettings --filter tests.FTDTest2.TestGetSnapshot" -v <full path on the host’s machine to the .NET project source code>:/tests -w /tests <OpenText Functional Testing for Developers container>

    Note:

    • This command performs operations in the working folder and must have read/write/execute permissions.

      You can achieve this by prefacing the command with sudo, to run it with administrator privileges or by making sure the folder containing the tests has full permissions.

      Grant these permissions to the user you specify in the run command, or to all users, if you use the default “leanft-user” account, which is created when running the tests.

    • The --settings and --filter arguments are optional, providing an XML settings file, which contains runtime parameters for the test, and a filter option specifying which of the project's tests to run.

    Java

    For JUnit tests: 

    docker run -it -p 5900:5900 --add-host=license-server:xx.xx.xx.xx -e RUN_MODE=junit -e RUN_CMD="com.company.FTDTest" -v <full path on the host’s machine to java jars>:/tests -w /tests <OpenText Functional Testing for Developers container>

    For TestNG tests: 

    docker run -it -p 5900:5900 --add-host=license-server:xx.xx.xx.xx -e RUN_MODE=testng -e RUN_CMD="testngMyApp.xml" -v <full path on the host’s machine to java jars>:/tests -w /tests <OpenText Functional Testing for Developers container>

    JavaScript

    docker run -it -p 5900:5900 --add-host=license-server:xx.xx.xx.xx -v <full path on the host’s machine to javascript mocha project>:/tests -w /tests <OpenText Functional Testing for Developers container>

    Note: This command runs npm test, which runs the test script in the package.json file. Make sure that the test script is defined correctly in the file. For example:

    "scripts": {
    "test": "jasmine plutoE2e.js"
    }

    Command explanation

    Command / Argument Description
    docker run

    The Docker CLI command for running the container.

    -it Instructs the Docker to run in the foreground so that you can track the output of the container. You can use Ctrl+C to stop the container.
    -p 5900:5900

    Optional. Maps port 5900 to the container's 5900 port, to connect to a VNC.

    Use this option if you would like to see the Docker container. For example, for debugging purposes.

    When you connect to the VNC client, use the password: PASSWORD

    --add-host=license-server:xx.xx.xx.xx Instructs the container which IP address to use for the license server. Replace xx.xx.xx.xx with your license server IP address.

    -e RUN_MODE=junit

    or

    -e RUN_MODE=testng

    or

    -e RUN_MODE=custom

    Use for Java and .NET tests: Indicates the framework used to run the test.

    Possible values: 

    junit - indicates that this is a JUnit test.

    testng - indicates TestNG tests.

    custom - use this for .NET C# tests.

    For each type, make sure to provide the relevant value in RUN_CMD.

    -e RUN_CMD="com.company.FTDTest"

    or

    -e RUN_CMD="testngMyApp.xml"

    or

    -e RUN_CMD="testngMyApp.xml"

    Specifies the run command according to the type of test:

    • For JUnit, Specifies the class that the container should use to run the test.

    • For TestNG, specifies the TestNG configuration XML file that the container should use to run the test. Make sure the XML file is located under the host directory that is mapped to the container.

      Note: If the XML file is not located in the same folder as the test jar file, specify the file's full path, or a path relative to the test jar file.

    • For .NET, specifies the dotnet test command line.

    -v <full path on the host’s machine to the test files>:/tests

    Maps the host’s test directory to the container's /tests directory.

    After the test report is generated you can access it from your machine in the path you defined.

    -w /tests Indicates that the working directory on the container is /tests. The tests are run from this location and this is where the tests reports are generated.
    <OpenText Functional Testing for Developers container> Instructs Docker to create a container. Possible values: functionaltesting/uftdeveloper, functionaltesting/uftdeveloper-chrome, functionaltesting/uftdeveloper-edge, functionaltesting/uftdeveloper-firefox. Optionally, append :<version number> to the container name. By default the latest version is used.

    Note: If you need to provide a self-signed certificate for the Chrome or Firefox browser to use inside the docker container, see Enable tests to access a web site using a self-signed certificate.

    Use environment variables as required. For details, see Run the docker image with environment variables.

  2. After your container is up and running, run your tests from your local machine as you always do. The browser is launched inside the container and your script commands are run there.

Run the docker image in a grid configuration

You can set up an OpenText Functional Testing for Developers grid configuration using multiple docker containers. Run one container as a grid and others as grid nodes. For details on using a grid, see Use a grid configuration.

Use environment variables as required. For details, see Run the docker image with environment variables.

To run tests in a grid configuration using docker images

  1. Run an OpenText Functional Testing for Developers docker image as a grid

    docker run -it -p 5095:5095 -p 8080:8080 --add-host=license-server:xx.xx.xx.xxx -e LFT_RUN_MODE="grid" -e LFT_GRID_PASSPHRASE="<encrypted passphrase>" <OpenText Functional Testing for Developers container>

    Explanation

    Command / Argument Description
    docker run The Docker CLI command for running the container.
    -it Instructs the Docker to run in the foreground so that you can track the output of the container. You can use Ctrl+C to stop the container.
    -p 5095:5095

    Maps the host's 5095 port (the OpenText Functional Testing for Developers default engine port) to the grid container's 5095 port, to connect to the OpenText Functional Testing for Developers engine.

    -p 8080:8080

    Maps the host's 8080 port (the OpenText Functional Testing for Developers default management port) to the grid container's 8080 port, to use for the grid management user interface.

    --add-host=license-server:xx.xx.xx.xx Instructs the container which IP address to use for the OpenText Functional Testing for Developers license server. Replace xx.xx.xx.xx with your license server IP address.
    "-e LFT_RUN_MODE="grid" Instructs the container to run OpenText Functional Testing for Developers as a grid.
    -e LFT_GRID_PASSPHRASE="<encrypted passphrase>"

    Specifies the passphrase that nodes need to use to connect to the grid.

    <OpenText Functional Testing for Developers container> Instructs Docker to create a container. Possible values: functionaltesting/uftdeveloper, functionaltesting/uftdeveloper-chrome, functionaltesting/uftdeveloper-edge, functionaltesting/uftdeveloper-firefox. Optionally, append :<version number> to the container name. By default the latest version is used.
  2. Run OpenText Functional Testing for Developers docker images as grid nodes

    docker run -it -p 5900:5900 -e LFT_RUN_MODE="node" -e LFT_GRID_PASSPHRASE="<encrypted passphrase>" -e LFT_GRID_NODE_NAME="<Node Name>" -e LFT_GRID_ADDRESS="ws://<IP address>:5095" <OpenText Functional Testing for Developers container>

    Explanation

    Command / Argument Description
    docker run The Docker CLI command for running the container.
    -it Instructs the Docker to run in the foreground so that you can track the output of the container. You can use Ctrl+C to stop the container.
    -p 5900:5900

    Optional. Maps the host's port 5900 to the node container's 5900 port, to connect to a VNC.

    Use this option if you would like to see the Docker container. For example, for debugging purposes.

    When you connect to the VNC client, use the password: PASSWORD

    Note: When running additional node containers on the same host, you must map each node container's 5900 port to a different host port. For example, use -p 5900:5900 for the first node, -p 5901:5900 for the second, -p 5902:5900 for the third, and so on.

    --add-host=license-server:xx.xx.xx.xx Instructs the container which IP address to use for the OpenText Functional Testing for Developers license server. Replace xx.xx.xx.xx with your license server IP address.
    "-e LFT_RUN_MODE="node" Instructs the container to run OpenText Functional Testing for Developers as a grid node.
    -e LFT_GRID_PASSPHRASE="<encrypted passphrase>"

    Instructs the container what passphrase to use to connect to the grid.

    -e LFT_GRID_NODE_NAME="<Node Name>" Specifies the name the grid uses to identify this node.

    -e LFT_GRID_ADDRESS="ws://<IP address>:5095

    Alternatively, map the grid host address:

    --add-host=grid:<grid's IP address>

    Instructs the node container what address to use to access the grid container.

    You can do this by setting the LFT_GRID_ADDRESS environment variable or by mapping grid to the grid container's IP address.

    Note: When the environment variable is not set, a node machine looks for the grid at ws://grid:5095. If you want to use a different port number, you must set the environment variable.

    <OpenText Functional Testing for Developers container> Instructs Docker to create a container. Possible values: functionaltesting/uftdeveloper, functionaltesting/uftdeveloper-chrome, functionaltesting/uftdeveloper-edge, functionaltesting/uftdeveloper-firefox. Optionally, append :<version number> to the container name. By default the latest version is used.

    Note:  

    • If you use the uftdeveloper-<browsername> images, OpenText Functional Testing for Developers knows which browser the image contains and you do not need to define the browser capability on the node.

    • You can also use docker's -u <name|uid>[:<group|gid>] option to specify the user to use in the container.

    • If you need to provide a self-signed certificate for the Chrome or Firefox browser to use inside the docker container, see Run tests in Docker containers.

  3. After your containers are up and running, run your OpenText Functional Testing for Developers tests locally or remotely on the grid container. The grid distributes the tests to the relevant nodes, based on availability and the environment specifications you included in the tests.

See also