Running tests in a containerized workbench

You can run tests in a containerized workbench after you deploy your Docker images. You need not install the workbench on your computer to run your tests.

Before you begin

  • You must have configured a Docker container.
  • You must have exported test assets to a location from where Docker can import them.
Notes:
  • You must use a Bash shell to run the commands for executing tests. In Windows operating system, you can use Git Bash.
  • The version number of the container images and the desktop products must match. If you have a previous version of the container image, you must uninstall it and then install the current version. To uninstall the image, you must use the following commands:

    To stop the container:

    docker stop "CONTAINER ID"

    To uninstall the image:

    docker rmi -f "image ID"
  • When you want to run Web UI tests on Chrome or Edge browser that is installed with HCL OneTest UI in a Docker container, you must accept the license agreement and terms of use of these third-party browsers by using the -acceptLicense parameter. For example, to run a test on the Chrome browser, you must use the following values:
    -acceptLicense "name=google-chrome"
    You can also specify multiple browser names such as Chrome and Edge to run the test by using the following value:
    -acceptLicense "name=google-chrome,ms-edge"
Restriction: If you run the test script for an HTML application as part of a compound test and in the headless mode in Docker, the inputKeys action for some special keys might not work. For example, in Firefox, the inputKeys action does not work for arrow keys.

Procedure

  1. Run the following command to load the workbench image into the Docker repository:
    docker load -i <workbenchImageName>

    For example, workbenchImageName can be hcl-onetest-studio-<versionNumber>.tar.gz.

    When the workbench image is loaded into the Docker repository, the following message is displayed:
    -Loaded image: imageFileName:versionNumber
  2. To run tests on the Docker environment without using any agents, complete the following steps:
    1. Select the required test from the workbench and export it by using the Test Assets with Dependencies option. You can use this exported test asset to run on Docker environment.
    2. To run a Web UI test or compound test, start the container by running the following command:
      $docker run --rm -e  HCL_ONETEST_LICENSING_URL=<URL> HCL_ONETEST_LICENSING_ID=<server_ID> -v hostTestAssets:/containerTestAssets -v hostImportedData:/containerImportedData -e TEST_IMPORT_PATH=/containerTestAssets/testasset.zip  imageName:imageVersion cmdline -workspace /containerImportedData/workspace -project projectName -suite TestSuiteName -results autoResults -stdout -exportlog /containerImportedData/testlog.txt -exportReport "type=unified;format=<html, xml, or pdf>;folder=runData;filename=report"
      For example, on Windows host:
      $docker run --rm -e HCL_ONETEST_LICENSING_URL= https://hclsoftware.compliance.flexnetoperations.com -e HCL_ONETEST_LICENSING_ID=MYDEMOLICENSEID -v C:\TestAssets:/test -v C:\TestExecutions:/runData -e TEST_IMPORT_PATH=/test/Project.zip hcl-onetest-studio:10.0.2 cmdline -workspace /runData/workspace -project MyHCLOneTestUIProject -suite Tests/WebUITest.testsuite -results autoResults -stdout -exportlog /runData/logs/WebUItestlog.txt -exportReport "type=unified;format=html;folder=runData;filename=WebUIreport"

      For example, on Linux host:

      $docker run --rm -e HCL_ONETEST_LICENSING_URL=https://hclsoftware.compliance.flexnetoperations.com -e HCL_ONETEST_LICENSING_ID=MYDEMOLICENSEID -v /home/user/TestAssets:/test -v /home/user/TestExecutions:/runData -e TEST_IMPORT_PATH=/test/Project.zip hcl-onetest-studio:10.0.2 cmdline -workspace /runData/workspace -project MyHCLOneTestUIProject -suite "Compound Tests/CompoundTest.testsuite" -results autoResults -stdout -exportlog /runData/logs/CompoundTesttestlog.txt -exportReport "type=unified;format=html;folder=runData;filename=CompoundTestreport"
    3. To run an Accelerated Functional Test suite, start the container by running the following command:
      $docker run --rm -e HCL_ONETEST_LICENSING_URL=<URL> -e HCL_ONETEST_LICENSING_ID=<server_ID> -v hostTestAssets:/containerTestAssets -v hostImportedData:/containerImportedData -e TEST_IMPORT_PATH=/containerTestAssets/testasset.zip  imageName:imageVersion cmdline -workspace /containerImportedData/workspace -project projectName -aftsuite AFTTestSuiteName -results autoResults -stdout -exportlog /containerImportedData/testlog.txt -exportReport "type=unified;format=<html, xml, or pdf>;folder=runData;filename=report"
      For example:
      $docker run --rm -e HCL_ONETEST_LICENSING_URL=https://hclsoftware.compliance.flexnetoperations.com -e HCL_ONETEST_LICENSING_ID=MYDEMOLICENSEID -v C:\TestAssets:/test -v C:\TestExecutions:/runData -e TEST_IMPORT_PATH=/test/hcl-onetest-studio MyHCLOneTestUIProject:10.0.2 cmdline -workspace /runData/workspace -project MyRFTProject -aftsuite MyAFTSuite.XML -results autoResults -stdout -exportlog /runData/logs/AFTSuiteTestlog.txt -exportReport "type=unified;format=html;folder=runData;filename=AFTreport"
      On Linux host, if you want to run an AFT suite on multiple browsers, then you must use a varinit file to specify the browser parameters as follows:
      <?xml version="1.1" encoding="UTF-8"?>
      <inits xmlns="http://www.ibm.com/rational/test/lt/varinit">
      <variable_init name="browser.parameters" value="--disable-dev-shm-usage;--no-sandbox"/>
      <variable_init name="webui.browserparam.selected" value="true"/>
      </inits>
      Sample command with the varinit file:
      $docker run --rm -e HCL_ONETEST_LICENSING_URL=<URL> -e HCL_ONETEST_LICENSING_ID=<server_ID> -v hostTestAssets:/containerTestAssets -v hostImportedData:/containerImportedData -e TEST_IMPORT_PATH=/containerTestAssets/testasset.zip  imageName:imageVersion cmdline -workspace /containerImportedData/workspace -project projectName -aftsuite AFTTestSuiteName -acceptLicense "name=google-chrome,ms-edge" -results autoResults -stdout -exportlog /containerImportedData/testlog.txt -exportReport "type=unified;format=<html, xml, or pdf>;folder=runData;filename=report" -varfile <varinitFileName>
      For example:
      $docker run --rm -e HCL_ONETEST_LICENSING_URL=https://hclsoftware.compliance.flexnetoperations.com -e HCL_ONETEST_LICENSING_ID=MYDEMOLICENSEID -v C:\TestAssets:/test -v C:\TestExecutions:/runData -e TEST_IMPORT_PATH=/test/hcl-onetest-studio MyHCLOneTestUIProject:10.0.2 cmdline -workspace /runData/workspace -project MyRFTProject -aftsuite MyAFTSuite.XML -acceptLicense "name=google-chrome,ms-edge" -results autoResults -stdout -exportlog /runData/logs/AFTSuiteTestlog.txt -exportReport "type=unified;format=html;folder=runData;filename=AFTreport" -varfile /test/browserVar4.init -stdout
      
    The following table lists the command options with description:
    Command Description
    --rm Removes the container after the run is completed.
    -e Sets the environment variables.
    HCL_ONETEST_LICENSING_URL=<URL> Specifies the URL of the license server. For example, https://hclsoftware.compliance.flexnetoperations.com.
    HCL_ONETEST_LICENSING_ID=<ID> Specifies the cloud license server ID. If you are using a local license server, you must not use this variable. The floating license for the product and VT-packs must be on the license server.
    hostTestAssets:/containerTestAssets Specifies the folder location on the host computer and the container that contains the compressed test assets (.zip format). You must use both the locations to map one or more shared volumes to transfer data such as test assets, logs, and execution results between the host and the container.
    hostImportedData:/containerImportedData Specifies the workspace location on the host computer and the container that contains the test assets that are not compressed. The results of the test execution are saved to the directory you specify on the host computer.
    TEST_IMPORT_PATH=<PATH> Specifies the location of the compressed test assets to be imported into the container. The location path is on the container side and not the host. For example, /containerTestAssets/archiveName.zip. The volume and path names are user-defined and must be consistent.
    imageName:imageVersion Specifies the name of the image and its version to run.
    cmdline
    Specifies the existing command-line arguments to define the following details:
    • Location of the workspace
    • Project name
    • Test name
    • Results file name
    • Location of the exported logs
    • Unified report format
    • Location of the unified report
    • Unified report file name
  3. Run the following command to play back a Web UI test on the browsers such as Chrome or Edge:
    docker run -e HCL_ONETEST_LICENSING_URL=<URL> -e  HCL_ONETEST_LICENSING_ID=<server_ID> -v hostTestAssets:/containerTestAssets -v hostImportedData:/containerImportedData -p <host_port>:<container_port> -e TEST_IMPORT_PATH=/containerTestAssets/testasset.zip imageName:imageVersion cmdline -workspace/containerImportedData/workspace -project projectName -suite TestSuiteName -acceptLicense "name=<browser_name>" -results autoResults -stdout -exportlog /containerImportedData/testlog.txt -exportReport "type=unified;format=<html, xml, or pdf>;folder=runData;filename=report"
    For example,
    docker run -e HCL_ONETEST_LICENSING_URL=https://hclsoftware.compliance.flexnetoperations.com -e HCL_ONETEST_LICENSING_ID=MYDEMOLICENSEID -v C:\dockertests\Test:/test -v C:\dockertests\Test:/runData -p 7878:7080 -e TEST_IMPORT_PATH=/test/Google1.zip hcl-onetest-studio:10.5.4 cmdline -workspace /runData/sandbox1 -project sf -suite test.testsuite -acceptLicense "name=google-chrome" -results autoResults -stdout -exportlog /runData/logs/WebUItestlog.txt -exportReport "type=unified;format=pdf;folder=/runData/logs/Exportedreport1051;filename=testreport"
    Where, 7878 is the recommended host port and 7080 is the recommended container port.
  4. Run the following command to view the unified report:
    docker run -e HCL_ONETEST_LICENSING_URL=<URL> -e  HCL_ONETEST_LICENSING_ID=<server_ID> -v hostTestAssets:/containerTestAssets -v hostImportedData:/containerImportedData -p <host_port>:<container_port> -e TEST_IMPORT_PATH=/containerTestAssets/testasset.zip imageName:imageVersion cmdline -workspace/containerImportedData/workspace -project projectName -suite TestSuiteName -results autoResults -stdout -exportlog /containerImportedData/testlog.txt -exportReport "type=unified;format=<html, xml, or pdf>;folder=runData;filename=report"
    For example,
    docker run -e HCL_ONETEST_LICENSING_URL=https://hclsoftware.compliance.flexnetoperations.com -e HCL_ONETEST_LICENSING_ID=MYDEMOLICENSEID -v C:\dockertests\Test:/test -v C:\dockertests\Test:/runData -p 7878:7080 -e TEST_IMPORT_PATH=/test/Google1.zip hcl-onetest-studio:10.5.1 cmdline -workspace /runData/sandbox1 -project sf -suite test.testsuite -results autoResults -stdout -exportlog /runData/logs/WebUItestlog.txt -exportReport "type=unified;format=pdf;folder=/runData/logs/Exportedreport1051;filename=testreport"
    Where, 7878 is the recommended host port and 7080 is the recommended container port.
    Sample command output on console:
    INFO: License status: OK
    Info : WebdriverUtils - findDownloadDirPath - downloadDrivePath set to /etc/opt/HCL/FunctionalTester/configuration
    getValue:autoResults_1676021430617.stats Persistance File : autoResults_1676021430617.stats
    To view the report for the duration of the execution, please open http://127.0.0.1:7878/results/ftwebreport/index.html?path=/ftreport/L3J1bkRhdGEvc2FuZGJveDEvc2YvYXV0b1Jlc3VsdHNfMTY3NjAyMTQzMDYxNy54bW9lYnJlcG9ydA== in a browser. 
    Please open a desktop client to view the report after playback is completed.

    You can view the live report by using the URL displayed in the command output on console. For example, http://127.0.0.1:7878/results/ftwebreport/index.html?path=/ftreport/L3J1bkRhdGEvc2FuZGJveDEvc2YvYXV0b1Jlc3VsdHNfMTY3NjAyMTQzMDYxNy54bW9lYnJlcG9ydA==.

What to do next

When the test run is completed, you can check hostImportedData in the host computer to view the exported log.