Pytest TestRail Plugin

0.10.5 · active · verified Thu Apr 16

pytest-pytestrail is a Pytest plugin designed to facilitate interaction with TestRail, a web-based test case management tool. It allows users to automatically update TestRail test results directly from their Pytest runs. The current version is 0.10.5, and it typically sees minor updates for compatibility and feature enhancements.

Common errors

Warnings

Install

Quickstart

First, create a `pytest.ini` file in your project root to configure TestRail connection details and enable the plugin. Use environment variables for sensitive data like passwords. Then, mark your Pytest tests with `@pytest.mark.testrail()` providing the corresponding TestRail case IDs. Run pytest from the command line.

# pytest.ini
[pytest]
addopts = --testrail
tr-url = https://your.testrail.net/
tr-email = your_email@example.com
tr-password = ${TR_PASSWORD}
tr-project-name = My Project
tr-testrun-name = Automated Test Run

# test_example.py
import pytest
import os

# For quickstart, ensure TR_PASSWORD is set in environment, e.g., via export TR_PASSWORD='...' 
# Or replace ${TR_PASSWORD} with actual password for local testing only (NOT recommended for production)

@pytest.mark.testrail('C1234')
def test_feature_a_works():
    assert True

@pytest.mark.testrail('C5678')
def test_feature_b_fails():
    assert False # This will be reported as failed in TestRail

view raw JSON →