Skip to main content

Python unittest test suite for Robot Framework

This is an experimental package for wrapping Robot Framework test suites into Python unittest suites to make it possible to run Robot Framework tests as plone.testing’s layered test suites:

import unittest

from plone.testing import layered
from robotsuite import RobotTestSuite

from my_package.testing import ACCEPTANCE_TESTING


def test_suite():
    suite = unittest.TestSuite()
    suite.addTests([
        layered(RobotTestSuite('mysuite.txt'),
                layer=ACCEPTANCE_TESTING),
    ])
    return suite

RobotTestSuite splits Robot Framework test suites into separate unittest test cases so that Robot will be run once for every test case in every test suite parsed from the given Robot Framework test suite. Because of that, each Robot will generate a separate test report for each test. Each report will have it’s own folder, which are created recursively reflecting the structure of the given test suite.

RobotTestSuite’s way of wrapping tests into unittest’s test suite is similar to how doctest-module’s DocTestSuite does its wrappings. See the documentation of DocTestSuite for possible common parameters (e.g. for how to pass a test suite from a different package).

The main motivation behind this package is to make Robot Framework support existing test fixtures and test isolation when testing Plone. Yet, this should help anyone wanting to use Robot Framework with zope.testrunner or other Python unittest compatible test runner.

If this works for you, please contribute at: http://github.com/collective/robotsuite/

https://github.com/collective/robotsuite/actions/workflows/build.yml/badge.svg?branch=master

Setting robot variables from environment variables

Robot Framework supports overriding test variables from command-line, which is not-available when running tests as robotsuite-wrapped with other test runners. That’s why robotsuite supports settings variables as environment variables so that every ROBOT_-prefixed environment variable will be mapped into corresponding test variable without the ROBOT_-prefix.

Declaring tests non-critical by given set of tags

Robot Framework supports declaring tests with given tags as non-critical to prevent their failing to fail the complete build on CI. This is supported as keyword argument for RobotTestSuite as follows:

def test_suite():
    suite = unittest.TestSuite()
    suite.addTests([
        layered(RobotTestSuite('mysuite.txt',
                               noncritical=['non-critical-tag']),
                layer=ACCEPTANCE_TESTING),
    ])
    return suite

Setting zope.testrunner-level

zope.testrunner supports annotating test suites with levels to avoid slow test being run unless wanted:

def test_suite():
    suite = unittest.TestSuite()
    suite.addTests([
        layered(RobotTestSuite('mysuite.txt'),
                layer=ACCEPTANCE_TESTING),
    ])
    suite.level = 10
    return suite

Retry failing tests

You can retry a failed test. This can be useful for flaky robot browser tests. Warning: this may not be good for all types of test. For example any changes that were done in the test until the first failure, may persist.

You can enable retries in two ways:

  • Set an environment variable ROBOTSUITE_RETRY_COUNT=X.

  • Override this by passing retry_count=X to a RobotTestSuite call.

The default is zero: no retries. The retry count excludes the original try.

def test_suite():
    suite = unittest.TestSuite()
    suite.addTests([
        robotsuite.RobotTestSuite('test_example.robot', retry_count=3),
        robotsuite.RobotTestSuite('test_variables.robot'),
        robotsuite.RobotTestSuite('test_setups', retry_count=2)
    ])
    return suite

Appending test results to existing test report

When running Robot Framework through robotsuite, its test reports are created into the current working directory with filenames robot_output.xml, robot_log.html and robot_report.html. The default behavior is to override the existing robot_output.xml (and also the other report files generated from that).

To merge test results from separate test runs into the same test report, set environment variable ROBOTSUITE_APPEND_OUTPUT_XML=1 to prevent robotsuite from overriding the existing test results, but to always append to the existing robot_output.xml.

Filtering test execution errors

Set environment variable ROBOTSUITE_LOGLEVEL=ERROR to filter all top level Test Execution Errors below the given log level (e.g. ERROR) from the merged test report. This is useful when unnecessary warnings are leaking from the tested code into Robot Framework logs.

Including or skipping all RobotTestSuite-wrapped tests

Robot Framework is often used with Selenium2Library to write acceptance test using the Selenium-framework. Yet, because those test may be slow to run, one might want sometimes (e.g. on CI) to run everything except the robotsuite wrapped tests, and later only the robotsuite wrapped tests.

This can be achieved for sure, with injecting a custom string into the names of robotsuite-wrapped tests with ROBOTSUITE_PREFIX-environment variable and then filter the test with that string.

E.g. run everything except the robotsuite wrapped tests with:

$ ROBOTSUITE_PREFIX=ROBOTSUITE bin/test --all -t \!ROBOTSUITE

and the other way around with:

$ ROBOTSUITE_PREFIX=ROBOTSUITE bin/test --all -t ROBOTSUITE

Re-using test suites from other packages

Sometime it could be useful to re-use acceptance test from some upstream package to test your slightly tailored package (e.g. with a custom theme). This can be done with by defining the test lookup location with package-keyword argment for RobotTestSuite:

def test_suite():
    suite = unittest.TestSuite()
    suite.addTests([
        layered(leveled(
            robotsuite.RobotTestSuite('robot',
                                      package='Products.CMFPlone.tests'),
        ), layer=PLONE_APP_MOSAIC_NO_PAC_ROBOT),
    ])
    return suite

Metadata

Release files for robotsuite 3.0.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 robotsuite 3.0.0
File Size Uploaded Provenance Actions
robotsuite-3.0.0.tar.gz 77.0 kB Without provenance Details for robotsuite-3.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for robotsuite 3.0.0
File Interpreter ABI Platform Actions
robotsuite-3.0.0-py3-none-any.whl Python 3 none any Details for robotsuite-3.0.0-py3-none-any.whl

Total release size: 93.3 kB

Release files / robotsuite-3.0.0.tar.gz

Download URL robotsuite-3.0.0.tar.gz
Size 77.0 kB
Tags Source
SHA-256 checksum
How to use checksums
832d74ff244ab9820f9de2d312b9a3668059004a7ab40ccd46aae7f0db9876fa
BLAKE2b-256 checksum
How to use checksums
b195425a3f3c7b94cc650c490597e7409b78ba3d633122c85ef4c15d9ddba676
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / robotsuite-3.0.0-py3-none-any.whl

Download URL robotsuite-3.0.0-py3-none-any.whl
Size 16.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e9c3b2edbed4dcd8e64f402ee9fc8fd539d1a08f51a1e5dd94bc6197a506ea3e
BLAKE2b-256 checksum
How to use checksums
d977b560aec71ed5411aa89f22727152db2404d06e5ffe7b0d84c59fac3456e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Security for robotsuite 3.0.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

3.0.0 This release

2 release files No provenance

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