Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_robotframework-1.0.0.tar.gz (8.3 kB view hashes)

Uploaded Source

Built Distribution

pytest_robotframework-1.0.0-py3-none-any.whl (5.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page