Declare dependencies between Robot Framework tests
Project description
Declare dependencies between tests. Make tests automatically fail based on the results of other test cases or test suites.
Although I strongly recommend that people write tests to be independent, sometimes, dependencies between tests are the simplest and easiest model to implement, and having tests fail-fast if one or more previous test cases didn’t get the expected result can be beneficial.
Versioning
This library’s version numbers follow the SemVer 2.0.0 specification.
Installation
pip install robotframework-dependencylibrary
Usage
First, include the library in your tests:
*** Settings ***
Library DependencyLibrary
Let’s say you have a passing and failing test:
*** Test cases ***
Passing Test
No operation
Failing Test
Fail This test is intentionally hardcoded to fail
A basic test that depends on the passing test looks like this:
*** Test cases ***
This Test Depends on "Passing Test" Passing
Depends on test Passing Test
Log The rest of the keywords in this test will run as normal.
Of course, you can depend on a test failure instead:
*** Test cases ***
This Test Depends on "Failing Test" Failing
Depends on test failure Failing Test
Log The rest of the keywords in this test will run as normal.
You can also depend on the status of a test suite:
*** Test cases ***
This Test Depends on an Entire Test Suite Passing
Depends on suite My Test Suite Name
Log The rest of the keywords in this test will run as normal.
Failures
Since the Depends on ... keywords fail when the dependency is not met, it supports all the usual logic you’d expect from Robot Framework:
The test case automatically aborts with a failure when the Depends on ... keyword fails as you’d expect, unless you capture the status and error message using something like Run keyword and expect error.
Error Messages
The error messages are documented (and are considered part of the interface, so you can rely on SemVer semantics: the major version number will be bumped if the logic for error messages ever changes):
If a test failed when you expected it to pass, you’ll get a helpful error:
*** Test cases ***
This Test Depends on "Failing Test" Passing
Depends on test Failing Test
Log The rest of the keywords (including this log) will NOT run!
The error message will be:
Dependency not met: test case 'Failing Test' state is 'FAIL', wanted 'PASS'
Same with expecting a passing test to fail:
*** Test cases ***
This Test Depends on "Passing Test" Failing
Depends on test failure Passing Test
Log The rest of the keywords (including this log) will NOT run!
The error message will be:
Dependency not met: test case 'Passing Test' state is 'PASS', wanted 'FAIL'
If you typo a test, or try to depend on the status of the test before it’s been run, for example:
*** Test cases ***
Depends on Non-Existant Test Case
Depends on test Misnamed Test
The error message will be:
Dependency not met: test case 'Misnamed Test' not found, wanted 'PASS'
If you accidentally make a test depend on itself, it will give a similar error message that more precisely identifies the error:
*** Test cases ***
Depends on self
Depends on test Depends on self
The error message will be:
Dependency not met: test case 'Depends on self' mid-execution, wanted 'PASS'
All test suite error messages are the same, except that they use the words “test suite” instead of “test case”.
Extras
For symmetry with Depends on test failure, the keyword Depends on test success is available as a synonym for Depends on test:
*** Test cases ***
This Test Depends on "Passing Test" Passing (using alternate keyword)
Depends on test success Passing Test
Log The rest of the keywords in this test will run as normal.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for robotframework-dependencylibrary-1.0.0.post1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2fd9a203f740a74c5427787ea19a86e4c76cebd5f9b1459f5290172cc13c8ecd |
|
MD5 | 66c889bbb794d98fd07f4f0daf57d001 |
|
BLAKE2b-256 | 567d2491fca1127f6a042a2ba8da91f349f0d42cfc911ff9aab24c6b1c73593d |
Hashes for robotframework_dependencylibrary-1.0.0.post1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c59dffaf1ed30be3ad5e8b4ad5696f276754cf476ffee4e782d7c436d02dc39 |
|
MD5 | a5f771c6209c1ab94520dc6a06f5c833 |
|
BLAKE2b-256 | 7c46c09b5ebb178a85bdeba8d0e66d4b6747657bacbc96cec01c2aedf43d0b82 |