Running in Docker

About

Docker runs applications in light-weight virtual containers. The containers provide you with a consistent environment isolated from other applications. SmartBear provides you with the soapuios-testrunner docker image you can use to run SoapUI Open Source functional tests within containers. The image is available in Docker Hub.

Docker image

To run functional tests in Docker, use the following image from Docker Hub:

https://hub.docker.com/r/smartbear/soapuios-testrunner/

Hardware requirements

This topic describes how to use Docker with SoapUI Open Source on the Hyper-V virtualization platform. To do that, use the same environment you use to run your Docker images. There are no specific requirements for this.

To learn more, see the Docker documentation:

To run SoapUI Open Source test runner in Docker containers on other virtualization platforms, additional configuration may be required. Please see the corresponding documentation.

Known issue: You cannot run the soapuios-testrunner image by using the Docker toolbox.

Pulling Functional Test Runner image from Docker Hub

To run functional tests by using a Docker image, you need to pull it from Docker Hub. To do this, use the following command:

docker pull smartbear/soapuios-testrunner

Docker command syntax

To run a functional test in a Docker container, use the following command line:

docker run -v="Project Folder":/project -v="Report Folder":/reports -v="Extensions Folder":/ext -e COMMAND_LINE="Test Runner Arguments" -it smartbear/soapuios-testrunner:latest

Arguments

  • -v=Project Folder:/project

    Required. Specifies the path to the folder that contains the SoapUI Open Source project. When a container starts, this folder will be copied to the container.
    Usage: -v="C:\Work\SoapUI Open Source Project":/project

    Note: On some systems, you may need to change the path in the following way:
    "C:\Work\SoapUI Open Source Project" -> "/host_mnt/C/Work/SoapUI Open Source Project"

  • -v=Report Folder:/reports

    Specifies the folder on a local machine to which the generated reports will be exported.
    Usage: -v="C:\Work\Reports":/reports

    Note: On some systems, you may need to change the path in the following way:
    "C:\Work\Reports" -> "/host_mnt/C/Work/Reports"

  • -v=Extensions Folder:/ext

    Specifies the folder whose content should be copied to the /bin/ext folder of the SoapUI Open Source installation in the container. Use this argument if your project requires additional libraries, such as database drivers.
    Usage: -v="C:\Work\SoapUI Open Source Extensions":/ext

    Note: On some systems, you may need to change the path in the following way:
    "C:\Work\SoapUI Open Source Extensions" -> "/host_mnt/C/Work/SoapUI Open Source Extensions"

  • -v=Plugins Folder:/root/.soapuios/plugins

    Specifies the folder with plugins that should be installed to SoapUI in the container.
    Usage: -v="C:\Users\<User>\.soapuios\plugins":/root/.soapuios/plugins

    Note: On some systems, you may need to change the path in the following way:
    "C:\Users\<User>\.soapuios\plugins" -> "/host_mnt/C/Users/<User>/.soapuios/plugins"

  • -e COMMAND_LINE="Test Runner Arguments"

    Required. Specifies arguments for the test runner. The %project% variable refers to the container folder to which the contents of the project folder were copied. To refer to the reports volume, use the %reports% variable.
    Usage:

    -e COMMAND_LINE="-f/%reports% '/%project%/Sample-soapui-project.xml'"

  • -it

    Required. This command enables the interactive command-line interface within a Docker container.

  • smartbear/soapuios-testrunner:latest

    Required. Specifies the image to create a container from.

Sample full command

docker run -v="C:\TestRunner\Project":/project -v="C:\TestRunner\Reports":/reports -v="C:\TestRunner\Extensions":/ext -e COMMAND_LINE="-f/%reports% '/%project%/Sample-soapui-project.xml'" -it smartbear/soapuios-testrunner:latest

Exit codes

After the docker stops running, you can get the exit code by using the following command:

  • PowerShell (Windows):

    $lastexitcode

  • Command Prompt (Windows):

    echo %errorlevel%

  • Terminal (macOS and Linux):

    echo $?

Besides the standard Docker exit codes (see the Docker documentation) the soapuios-testrunner Docker image uses the following codes:

102 The SoapUI Open Source project was not found.
Make sure you specify the correct folder for the project volume, and this folder contains the specified project.
103 An error occurs during the test run. See the test log for more details.

Run in Docker Compose

To add the Functional Test Runner image to your Docker Compose application:

  1. Get the Functional Test Runner image's Dockerfile from GitHub (https://github.com/SmartBear/soapui/tree/next/docker) and put it somewhere in your Docker Compose project directory.

  2. Open the docker-compose.yml file in your Docker Compose project folder and add the command to build a service from Dockerfile:

    <service-name>:
      build: <path>

    • service-name

      The name that will be assigned to the service.

    • path

      The path to the directory in the project folder where Dockerfile is stored.

    Example:

    version: '3'
      services:
        soapui-testrunner:
          build: .
        redis:
          image: redis:latest
        db:
          image: postgres:9.4
          volumes:
            - db-data:/var/lib/postgresql/data
    

    Tip: For a reference on the docker-compose.yml file, see https://docs.docker.com/compose/compose-file/.

  3. Use the docker-compose build command to build the services specified in the docker-compose.yml file.

Now, when you run your Docker Compose application, the Functional Test Runner will be run as a part of it.

To run only the Functional Test Runner service, use the following command:

docker-compose run <service-name> -v="Project Folder":/project -v="Report Folder":/reports -v="Extensions Folder":/ext -e -e COMMAND_LINE="Test Runner Arguments" -it

  • service-name

    The name of the Functional Test Runner service.

Note For a reference on the rest of the arguments, see the Docker command syntax section above.

Troubleshooting

If you cannot run Docker due to the Drive has not been shared error, perform the following steps:

  1. Right-click the Docker icon in the notification area and select Settings:

    Docker image: Docker context menu

  2. On the Shared Drives page of the Settings dialog, select all the drives you use to run the Docker container.

    Important If your drives have already been shared, but the error occurs anyway, turn off sharing. After you apply the changes, repeat these steps to share the drives again.

    To share your drivers, select them in the list and click Apply:

    Docker image: Sharing disk

    You may need to enter the credentials of your system account to apply the changes.