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.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76d1d56cfb0ecf4709930c32d1e419c73d38ce370e63156042048cb5b737b670 |
|
MD5 | bca873c1592fb93c7f560009431ebd71 |
|
BLAKE2b-256 | 75a7526f37543adb7e82dabd2310a943b9ba6b88ab8dc512f55cfe2cc34d9d6f |
Hashes for pytest_robotframework-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59fc700a039ab5f0fb2d186a24a7998d3798535350ca508114f40b3cd1be98b6 |
|
MD5 | f4aac15ce624c23ad857dfe0d4aeee88 |
|
BLAKE2b-256 | 084658e1b91ea163914d09368d0be02b150cbac7b09e0464a5cf95164faadcc0 |