Skip to main content

Create and update testplans and/or testruns in TestRail based on pytest results. Test functions marked with a TestRail case ID will have their results sent to TestRail.

This project preserves the functionality of the deprecated pytest-testrail project.

PyPI PyPI - Python Version GitHub Build status

Key features:

  • Configurable: Handle results in whichever way makes sense for your project.

  • Powerful: Handle complex use cases via a simple interface to the TestRail API.

  • Flexible: Fully compatible with pytest.parametrize(), pytest-xdist, and pytest-rerunfailures.

Example

import pytest

@pytest.mark.case_id('C1950')
def test_all_the_things():
  doit = True
  assert doit

Getting Started

Installation

Via pip:

pip install pytest-testrail2

Plugin Configuration

The following values are required:

  • A valid TestRail instance URL.

  • A valid email address for a user on the instance.

  • A valid API key for the user.

They can be set on the command line via the follow flags:

--tr-url=<your_url>
--tr-email=<your_email>
--tr-password=<your_password>

Alternatively, they can be set via a pytest configuration file:

[pytest]
  tr_url=<your_url>
  tr_email=<your_email>
  tr_password=<your_password>

Marking Tests

case_id

The case_id marker takes a string which must match an existing TestRail testcase. Only tests with this marker will be added to the TestRail testrun.

import pytest

# This test's results will be uploaded.
@pytest.mark.case_id('C1950')
def test_all_the_things():
  ...


# This test's results will not be uploaded.
def test_all_the_other_things():
  ...

defect_ids

The ‘defect_ids’ marker takes a list of strings. These will be used in the defect field in TestRail. This is useful for tests with known failures.

Typically these are IDs for your bug tracking software.

import pytest

@pytest.mark.case_id('C1950')
@pytest.mark.defect_ids(['JS-7001', 'JS-9001'])
def test_all_the_things():
  ...

Running Pytest

The –testrail command-line flag must be present to upload results:

pytest --testrail

Options

Setup

  • --testrail Activate the TestRail plugin.

  • --tr-url Web address used to access a TestRail instance.

  • --tr-email E-mail address for an account on the TestRail instance.

  • --tr-password Password for an account on the TestRail instance.

  • --tr-timeout Timeout for connecting to a TestRail server.

  • --tr-no-ssl-cert-check Do not check for valid SSL certificate on TestRail host.

Testrun

  • --tr-run-id ID of an existing testrun in TestRail. If specified, the testrun matching the ID will be used instead of creating a new testrun. If given, --tr-testrun-name will be ignored.

  • --tr-testrun-name Name used for a new testrun in TestRail.

  • --tr-testrun-description Description used for a new testrun in TestRail.

  • --tr-testrun-assignedto-id ID of the user to be assigned to the testrun.

  • --tr-testrun-project-id ID of the project the testrun will be created in.

  • --tr-testrun-suite-id ID of the suite the testrun will be created in.

  • --tr-testrun-suite-include-all Include all test cases in the specified testsuite for a new testrun.

  • --tr-milestone-id ID of milestone used in testrun creation.

  • --tr-skip-missing Skip pytest test functions with marks that are not present in a specified testrun.

Testplan

  • --tr-plan-id ID of an existing testplan to use. If given, --tr-testrun-name will be ignored.

Publishing

  • --tr-version Specify a version in testcase results.

  • --tr-close-on-complete On pytest completion, close the testrun.

  • --tr-dont-publish-blocked Do not publish results of “blocked” testcases (in TestRail).

  • --tr-custom-comment Custom text appended to comment for all testcase results.

Metadata

Release files for pytest-testrail2 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-testrail2 1.1.0
File Size Uploaded
pytest-testrail2-1.1.0.tar.gz 21.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-testrail2 1.1.0
File Interpreter ABI Platform
pytest_testrail2-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 38.6 kB

Release files / pytest-testrail2-1.1.0.tar.gz

Download URL pytest-testrail2-1.1.0.tar.gz
Size 21.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a236e68d803478b38333ccf22ea829e46caaf67f581b2415391141fb99c1747f
BLAKE2b-256 checksum
How to use checksums
4bad63fc953a066a784b3fb422266416c1d0d3b6478dfbb9eee8c8262eee7ebc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / pytest_testrail2-1.1.0-py3-none-any.whl

Download URL pytest_testrail2-1.1.0-py3-none-any.whl
Size 17.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3c0eca3b654c1a093bc7bcd8e43743061b5eaddc43994d0b8429efdbcfd4a73b
BLAKE2b-256 checksum
How to use checksums
f748ad20e1abc8f7d6b9e1377a3384824acbb751f4a7067f44ae68d6d0349151
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page