Test Reporting with Allure & HTML Reports
Professional test execution requires professional reporting. Stakeholders need to see test results, trends, and failure details without running tests themselves. Allure is the industry-standard reporting framework that transforms raw test results into beautiful, interactive dashboards with screenshots, logs, test history, and failure analysis.
Allure Report Setup (Playwright + Python/pytest)
# ── PYTHON + PYTEST + ALLURE ──────────────────────────────────
# pip install allure-pytest
# In conftest.py — attach screenshots to allure on failure:
import allure
import pytest
@pytest.hookimpl(tryfirst=True, hookwrapper=True)
def pytest_runtest_makereport(item, call):
outcome = yield
rep = outcome.get_result()
if rep.when == "call" and rep.failed:
try:
driver = item.funcargs.get("driver")
if driver:
# Attach screenshot to Allure report
allure.attach(
driver.get_screenshot_as_png(),
name="failure_screenshot",
attachment_type=allure.attachment_type.PNG
)
except Exception:
pass
# In your test file:
@allure.feature("Authentication")
@allure.story("Login")
@allure.severity(allure.severity_level.CRITICAL)
@allure.title("Login with valid credentials succeeds")
def test_login_valid(driver):
with allure.step("Navigate to login page"):
driver.get("https://staging.app.com/login")
with allure.step("Enter valid credentials"):
driver.find_element("id", "email").send_keys("alice@test.com")
driver.find_element("id", "password").send_keys("Test@1234")
with allure.step("Submit login form"):
driver.find_element("id", "submit").click()
with allure.step("Verify dashboard redirect"):
assert "/dashboard" in driver.current_url
allure.attach(
driver.page_source,
name="page_source",
attachment_type=allure.attachment_type.HTML
)
# Run with Allure:
# pytest tests/ --alluredir=./allure-results
# allure serve ./allure-results ← Opens live report
# allure generate ./allure-results --clean -o ./allure-report
# ── PLAYWRIGHT BUILT-IN HTML REPORTER ─────────────────────────
# playwright.config.ts:
# reporter: [
# ['html', { open: 'never', outputFolder: 'playwright-report' }],
# ['allure-playwright'], // npm install -D allure-playwright
# ]
# After running: npx playwright show-report
# Allure: npx allure serve allure-resultsQuick Quiz — Playwright & Cypress Automation
Common Mistakes
- Not generating reports in CI — Allure results must be saved as CI artifacts and the report generated post-run; configure in your CI YAML
- Missing screenshots in failure reports — attach screenshots in the test teardown fixture, not at the end of the test function (missed if assertion fails early)
- Not linking test cases to requirements — use @allure.feature and @allure.story to map tests to features; enables requirement coverage dashboards
- Ignoring test history trends — Allure's most valuable feature is the history chart showing test stability over time; configure history to be retained between CI runs
Tip
Tip
Practice Test Reporting with Allure HTML Reports in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.
Technical diagram.
Practice Task
Note
Practice Task — (1) Write a working example of Test Reporting with Allure HTML Reports from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.
Common Mistake
Warning
A common mistake with Test Reporting with Allure HTML Reports is skipping edge case testing — empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready software testing code.
Key Takeaways
- Professional test execution requires professional reporting.
- Not generating reports in CI — Allure results must be saved as CI artifacts and the report generated post-run; configure in your CI YAML
- Missing screenshots in failure reports — attach screenshots in the test teardown fixture, not at the end of the test function (missed if assertion fails early)
- Not linking test cases to requirements — use @allure.feature and @allure.story to map tests to features; enables requirement coverage dashboards