Please follow https://github.com/allure-framework/allure-python ===================== Allure Pytest Adaptor =====================
This repository contains a plugin for py.test
which automatically prepares input data used to generate Allure Report
. Note: this plugin currently supports only Allure 1.4.x series.
This plugin gets automatically connected to py.test
via entry point
if installed.
Connecting to IDE:
To attach some content to test report:
To divide a test into steps:
Can also be used as decorators. By default step name is generated from method name:
Steps can also be used without pytest. In that case instead of pytest.allure.step
simply use allure.step
:
allure.step
decorator supports step name formatting with function parameters:
The step in the latter case will have name some operation for bar=abcdef
. Formatting is done via python's built-in string.format
and supports it's options. Arguments are passed to format
method in the same way they are passed to the decorated function.
Steps support is limited when used with fixtures.
Any test, class or module can be marked with different severity:
import pytest
@pytest.allure.severity(pytest.allure.severity_level.MINOR)
def test_minor():
assert False
@pytest.allure.severity(pytest.allure.severity_level.CRITICAL)
class TestBar:
# will have CRITICAL priority
def test_bar(self):
pass
# will have BLOCKER priority via a short-cut decorator
@pytest.allure.BLOCKER
def test_bar(self):
pass
To run tests with concrete priority:
Issues can be set for test.
import pytest
@pytest.allure.issue('http://jira.lan/browse/ISSUE-1')
def test_foo():
assert False
import allure
@allure.issue('http://jira.lan/browse/ISSUE-2')
class TestBar:
# test will have ISSUE-2, ISSUE-3 and ISSUE-4 label
@allure.issue('http://jira.lan/browse/ISSUE-3')
def test_bar1(self):
# You can use this feature like a function inside the test
allure.dynamic_issue('http://jira.lan/browse/ISSUE-4')
pass
# test will have only ISSUE-2 label
def test_bar2(self):
pass
Test cases links can be set for test also.
import pytest
@pytest.allure.testcase('http://my.tms.org/TESTCASE-1')
def test_foo():
assert False
import allure
@allure.testcase('http://my.tms.org/browse/TESTCASE-2')
class TestBar:
# test will have TESTCASE-2 and TESTCASE-3 label
@allure.testcase('TESTCASE-3')
def test_bar1(self):
pass
# test will have only TESTCASE-2 label
def test_bar2(self):
pass
Feature and Story can be set for test.
To run tests by Feature or Story:
You can provide test environment parameters such as report name, browser or test server address to allure test report.
import allure
import pytest
def pytest_configure(config):
allure.environment(report='Allure report', browser=u'Я.Браузер')
@pytest.fixture(scope="session")
def app_host_name():
host_name = "my.host.local"
allure.environment(hostname=host_name)
return host_name
@pytest.mark.parametrize('country', ('USA', 'Germany', u'Россия', u'Япония'))
def test_minor(country):
allure.environment(country=country)
assert country
More details about allure environment you can know from documentation.
Use allure.common.AllureImpl
class to bind your logic to this adapter.