Skip to main content

robotframework-testcontainers

Robot Framework keywords for testcontainers.

Keyword Documentation

Installation

  • using pip:
pip install robotframework-testcontainers
  • using uv:
uv add robotframework-testcontainers
  • using poetry:
poetry add robotframework-testcontainers

Usage

Starting a container can be done with a single keyword:

*** Settings ***
Library    TestcontainersLibrary

*** Test Cases ***
Basic Usage Example
    Create Docker Container    image=hello-world

TestcontainersLibrary keeps track of all started containers. It stops containers started during a test when that test ends, and containers started during suite initialization or suite setup when that suite ends.

If you require more control, you can also manually start and stop the container. Additionally, you can use different wait strategies to wait for the container to be ready:

*** Settings ***
Library    TestcontainersLibrary

*** Test Cases ***
Advanced Usage with more control
    ${container}=    Create Docker Container    image=traefik/whoami    start=False    ports=[80]
    Start Container    ${container}
    Wait For Http Endpoint    ${container}    port=80    path=/api
    Stop Container    ${container}

You can also use any of the community maintained containers. Be aware that you have to make sure to install the required dependencies yourself.
For example: starting a CockroachDB container requires installing testcontainers[cockroachdb]. Use the Create Community Container keyword and specify which class to import from which module. Any additional arguments can be passed in as keyword arguments.

*** Settings ***
Library             TestcontainersLibrary


*** Test Cases ***
Starting an CockroachDb Container
    ${password}=    Evaluate    str(uuid.uuid4())
    ${container}=    Create Community Container
    ...    module=testcontainers.cockroachdb
    ...    container_class=CockroachDBContainer
    ...    username=demoUser
    ...    password=${password}
    Log    ${container.get_connection_url()}

You can read the acceptance tests in test/acceptance/ for more concrete usage examples.

Failed-test log artifacts

Register the failed-test log collector on the Robot command line to retain stdout and stderr for every active container started through the library. The listener covers every test in the execution, including child suites that do not import TestcontainersLibrary:

robot \
  --listener TestcontainersLibrary.FailedTestLogCollector \
  tests/

By default, artifacts go to ${OUTPUT_DIR}/container-logs. Pass a different root after the listener name when needed:

robot \
  --listener TestcontainersLibrary.FailedTestLogCollector:/tmp/container-logs \
  tests/

The listener uses absolute custom paths as written. It resolves relative custom paths from the process working directory, not Robot's output directory.

The log window extends one second before and after the failed test to account for Docker log timing. Each Robot run gets one timestamped directory. Beneath it, the listener preserves the logical suite hierarchy:

<artifact-root>/<timestamp>/<suite>/<child-suite>/<test>/<container files>

Unsafe path characters and whitespace become underscores. Each container gets separate stdout and stderr files. When collection writes at least one log or error file, log.html includes one INFO message with the absolute path to that test's artifact directory. Collection errors do not change the Robot test result.

The files contain raw container logs and may include passwords, tokens, or other secrets. Choose an artifact directory with suitable access and retention controls.

License

This project is licensed under the MIT License.

Third-Party Licenses

This library depends on the testcontainers-python package, which is licensed under the Apache License 2.0.

No parts of testcontainers-python are copied or modified in this project. It is used only as a dependency.

Metadata

Release files for robotframework-testcontainers 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for robotframework-testcontainers 0.3.0
File Size Uploaded
robotframework_testcontainers-0.3.0.tar.gz 8.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for robotframework-testcontainers 0.3.0
File Interpreter ABI Platform
robotframework_testcontainers-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 18.5 kB

Release files / robotframework_testcontainers-0.3.0.tar.gz

Download URL robotframework_testcontainers-0.3.0.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6ae1448b043a2cce607b7123f5a6342c96a7b5b7bd622df4c92e60ca23ea6b77
BLAKE2b-256 checksum
How to use checksums
5c5e75042ddb4dc9001869abae8e7acd402c55c320d5102e5ab544291bf60c37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 1, 2026.

Transparency log

Release files / robotframework_testcontainers-0.3.0-py3-none-any.whl

Download URL robotframework_testcontainers-0.3.0-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
42a4bc8edd0f5af73e2ee7c3b1c2b7c4c3f4c2546d8b567fa0419721b3527b34
BLAKE2b-256 checksum
How to use checksums
64cabd76f15170a689ccabc3b4f6b8e11721f246efbaf64360a8959d418689eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 1, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page