a pytest plugin to generate robotframework reports without having to write your tests in the robot langauge
Project description
pytest-robotframework
a pytest plugin to generate robotframework reports without having to write your tests in the robot langauge
install
poetry add pytest-robotframework --group=dev
usage
pytest should automatically find and activate the plugin once you install it, so all you should have to do is write tests with pytest like you would normally:
# you can use both robot and pytest features
from robot.api import logger
from pytest import Cache
from pytest_robotframework import keyword
@keyword # make this function show as a keyword in the robot log
def foo():
...
def test_foo(cache: Cache):
foo()
robot command line arguments
specify robot CLI arguments with the --robotargs
argument:
pytest --robotargs="-d results --listener foo.Foo"
some arguments such as --extension
obviously won't work .
setup/teardown and other hooks
to define a function that runs for each test at setup or teardown, create a conftest.py
with a pytest_runtest_setup
and/or pytest_runtest_teardown
function:
# ./tests/conftest.py
def pytest_runtest_setup():
log_in()
# ./tests/test_suite.py
def test_something():
"""i am logged in now"""
these hooks appear in the log the same way that the a .robot
file's Setup
and Teardown
options in *** Settings ***
would:
for more information, see writing hook functions. pretty much every pytest hook should work with this plugin but i haven't tested them all. please raise an issue if you find one that's broken.
tags/markers
pytest markers are converted to tags in the robot log:
from pytest import mark
@mark.slow
def test_blazingly_fast_sorting_algorithm():
[1,2,3].sort()
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 pytest_robotframework-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b6ed32011466e641d987117e866faf6e475812a09cfab9bfa70a15edf8db121 |
|
MD5 | 29b476a58d45742479e21d6b14023b3b |
|
BLAKE2b-256 | 5c7b773e1e8489f704d3f1a2deb3274c26caf06a3b8e1ba3b817cb9617eb9c7e |
Hashes for pytest_robotframework-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21c45c2174545302d1fcba7cf98d73121e1c6f34e088aab564c36be136ac6fc1 |
|
MD5 | 22c11f69aa62b1cca277c21628c8012d |
|
BLAKE2b-256 | b2d489c7944f2779d6fb403b5ee130522d30b4a9e2fad82fb02254f51ce26cd5 |