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
Typical usage:
*** Test cases ***
Passing Test
No operation
A Test that Depends on "Passing Test"
Depends on test Passing Test
Log The rest of the keywords in this test will run as normal.
When you need to declare multiple dependencies, just repeat the keyword:
*** Test cases ***
Another Passing Test
No operation
A Test that Depends on Both "Passing Test" and "Another Passing Test"
Depends on test Passing Test
Depends on test Another Passing Test
Log The rest of the keywords in this test will run as normal.
You can also depend on the statuses of entire test suites:
*** Test cases ***
A Test that Depends on an Entire Test Suite Passing
Depends on suite Some Test Suite Name
Log The rest of the keywords in this test will run as normal.
Failures
The Depends on ... keywords fail if the dependency is not met, so the test case automatically aborts with a failure unless you use something like Run keyword and expect error.
Error Messages
The error messages are considered part of the interface, so per SemVer the major version number will be bumped if the error message format ever changes).
If a test failed when you expected it to pass,
*** Test cases ***
A Test that Depends on "Some Test" Passing
Depends on test Some Test
Log The rest of the keywords (including this log) will NOT run!
the error message will be:
Dependency not met: test case 'Some Test' state is 'FAIL', wanted 'PASS'
If Some Test was skipped, the error message would be be:
Dependency not met: test case 'Some Test' state is 'SKIP', wanted 'PASS'
If you typo a test, or try to depend on the status of a test before it has been run, there won’t be any status yet,
*** Test cases ***
A Test that Depends on Missing Test Case
Depends on test Another Test
so the error message will be:
Dependency not met: test case 'Another Test' not found, wanted 'PASS'
If you accidentally make a test depend on itself,
*** 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'
When depending on test suites, the error messages are the same, but they use the words “test suite” instead of “test case”.
Extras
You’ll probably never need to, but you can depend on a failure or skip of a test or suite instead of success:
*** Test cases ***
Failing Test
Fail This test always fails
A Test that Depends on "Failing Test" Failing
Depends on test failure Failing Test
Log The rest of the keywords in this test will run as normal.
Skipped Test
Skip This test always skips
A Test that Depends on "Skipped Test" Getting Skipped
Depends on test skipped Skipped Test
Log The rest of the keywords in this test will run as normal.
A Test that Depends on an Entire Test Suite Failing
Depends on suite falure Another Test Suite Name
Log The rest of the keywords in this test will run as normal.
A Test that Depends on an Entire Test Suite Getting Skipped
Depends on suite skipped Some Test Suite Name
Log The rest of the keywords in this test will run as normal.
For symmetry with the above, the keywords Depends on test success and Depends on suite success are available as synonyms for Depends on test and Depends on suite.
*** 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.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e4972f1550f9140833636f23ce31a068424750b41d02c84162c560a2bddc6a1 |
|
MD5 | 32b9252b922655e69eefe95f7cfe9b65 |
|
BLAKE2b-256 | 3f7a87eb37fa505b76c6dd14197bd15ca0dbf7720964ce3cf255282eec3e8cda |
Hashes for robotframework_dependencylibrary-1.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 783fbe59ef7dc68c28edf974f3d63ef85c6b43f18870c2e36e7448e8c1cb3cc6 |
|
MD5 | f22ab1bc83fe07d1c1c5f1168e1d708f |
|
BLAKE2b-256 | ad4a9f3492eea80833d341705ae21aae8fe5b632732ac3f4383aed8ded4ae33d |