Allure pytest integration that generates comprehensive test reports with rich metadata and visual test execution tracking
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Add rich metadata to tests using pytest markers for enhanced categorization, organization, and reporting in the Allure interface. This enables better test organization, filtering, and comprehensive test documentation.
Add categorical labels to tests for organization, filtering, and reporting purposes.
@pytest.mark.allure_label(*labels, label_type=str)
"""
Add one or more labels of a specific type to a test.
Parameters:
- *labels: One or more label values
- label_type: Type of label (severity, feature, story, epic, etc.)
Usage:
@pytest.mark.allure_label("critical", label_type="severity")
@pytest.mark.allure_label("login", "logout", label_type="feature")
"""Associate tests with external resources like bug trackers, test management systems, or documentation.
@pytest.mark.allure_link(url, link_type=str, name=str)
"""
Add a link to an external resource.
Parameters:
- url: Full URL or short reference (if link pattern configured)
- link_type: Type of link ("issue", "tms", "test_case", etc.)
- name: Display name for the link
Usage:
@pytest.mark.allure_link("https://jira.example.com/PROJ-123",
link_type="issue", name="Bug Report")
@pytest.mark.allure_link("PROJ-123", link_type="issue", name="Bug Report") # With pattern
"""Add detailed descriptions to tests for better documentation and reporting.
@pytest.mark.allure_description(description)
"""
Add a text description to a test.
Parameters:
- description: Text description of the test
Note: Test docstrings are automatically used as descriptions if no marker is present.
Usage:
@pytest.mark.allure_description("Verify user authentication with valid credentials")
"""
@pytest.mark.allure_description_html(html_description)
"""
Add an HTML description to a test.
Parameters:
- html_description: HTML formatted description
Usage:
@pytest.mark.allure_description_html("<h3>Test Steps</h3><ol><li>Login</li><li>Navigate</li></ol>")
"""import allure
@allure.severity(allure.severity_level.BLOCKER) # Highest priority
@allure.severity(allure.severity_level.CRITICAL) # High priority
@allure.severity(allure.severity_level.NORMAL) # Standard priority (default)
@allure.severity(allure.severity_level.MINOR) # Low priority
@allure.severity(allure.severity_level.TRIVIAL) # Lowest priority
def test_example():
passimport allure
@allure.epic("E-commerce Platform") # High-level business capability
@allure.feature("User Authentication") # Product feature
@allure.story("User Login Process") # User story
def test_user_login():
passimport allure
@allure.suite("Authentication Tests") # Test suite grouping
@allure.parent_suite("User Management") # Parent suite grouping
@allure.sub_suite("Login Functionality") # Sub-suite grouping
def test_login_validation():
passimport pytest
import allure
@pytest.mark.allure_label("critical", label_type="severity")
@pytest.mark.allure_label("authentication", label_type="feature")
@pytest.mark.allure_label("TC001", label_type="testId")
@pytest.mark.allure_link("PROJ-123", link_type="issue", name="Login Bug")
@pytest.mark.allure_description("Verify user can login with valid credentials")
def test_valid_login():
"""Test successful user authentication"""
passimport pytest
import allure
@allure.severity(allure.severity_level.CRITICAL)
@allure.epic("User Management")
@allure.feature("Authentication")
@allure.story("User can login with valid credentials")
@allure.testcase("TC001", "Test Management System")
@allure.issue("PROJ-123", "Bug Tracker")
@pytest.mark.allure_description_html("""
<h3>Test Objective</h3>
<p>Verify that users can successfully authenticate with valid credentials</p>
<h3>Prerequisites</h3>
<ul>
<li>User account exists</li>
<li>Application is accessible</li>
</ul>
""")
def test_user_authentication():
passimport pytest
@pytest.mark.allure_label("backend", label_type="component")
@pytest.mark.allure_label("database", label_type="layer")
@pytest.mark.allure_label("regression", label_type="test_type")
@pytest.mark.allure_label("P1", label_type="priority")
@pytest.mark.allure_label("team_alpha", label_type="owner")
def test_database_connection():
passimport pytest
@pytest.mark.allure_link("PROJ-123", link_type="issue", name="Original Bug")
@pytest.mark.allure_link("PROJ-456", link_type="issue", name="Related Issue")
@pytest.mark.allure_link("TC001", link_type="tms", name="Test Case")
@pytest.mark.allure_link("https://wiki.company.com/auth", link_type="test_case", name="Documentation")
def test_authentication_flow():
passThe plugin defines these marker names as constants:
ALLURE_LABEL_MARK = "allure_label" # For @pytest.mark.allure_label
ALLURE_LINK_MARK = "allure_link" # For @pytest.mark.allure_link
ALLURE_DESCRIPTION_MARK = "allure_description" # For @pytest.mark.allure_description
ALLURE_DESCRIPTION_HTML_MARK = "allure_description_html" # For @pytest.mark.allure_description_htmlLabels added through markers can be used with command-line filtering options:
# Run tests with specific labels
pytest --allure-severities critical tests/
pytest --allure-features authentication tests/
pytest --allure-label component=backend tests/Install with Tessl CLI
npx tessl i tessl/pypi-allure-pytest