Skip to main content

Pytest Testrail Integrator.

Pytest-testrail-integrator is a pytest extension for reporting test results to Testrail.

Pytest-testrail-integrator gives an ability to send test results to specific testrail run or can create new one during test execution. Fully compatible with xdist parallelization tool.

Installation

pip install pytest-testrail-integrator

Example

In order to link pytest test to testrail case you need to mark test with pytest.mark.case or tr_case decorator with testcase id passing as argument.

import pytest

from pytest_testrail_integrator.client import tr_case


@pytest.mark.case('98765')  # Use raw pytest marker.
def test_sum():
    assert 1 + 1 == 2


@tr_case('987654')  # Use custom decorator.
def test_divide():
    assert 2 / 1 == 2

Test case id must not start with "C" char and can be either string or integer.

Main flow overview.

At startup plugin checks if the Testrail run id is passed or not. If not passed - plugin will create new test run by itself. Then during tests execution testrail tests will be updated in real time.

Config for TestRail

  • All required configs can be loaded from virtual environment variables(higher priority) :
TR_RUN_ID
TR_API_URL
TR_USER_EMAIL
TR_USER_PASSWORD
TR_PROJECT_ID
TR_SUTE_ID

Or

  • Add options to pytest.ini file.

Launch

In order to start tests with Pytest-Message you must provide --tr-reporting flag:

pytest tests --tr-reporting

All available command line options.

option description
--tr-reporting Create and update testruns with TestRail
--tr-deselect-tests If pass testrun id only. Selects only tests which have been marked with case decorator with appropriate case id. Other tests are marked as deselected and not started in test execution.

All available pytest.ini options.

option description
tr_api_url Testrail api url.
tr_run_id Testrail test run id. If passed test reports are linked to this particular test run.
tr_user_email Testrail User email for API authentication.
tr_user_password Testrail User password for API authentication.
tr_project_id Testrail Project Id. Required for new test run creation if Test Run Id is not passed.
tr_suite_id Testrail Suite Id. Required for new test run creation if Test Run Id is not passed.
tr_tb Traceback level in testrail message reports. ['short', 'long'] options. Short is selected by default.

Hooks

pytest_tr_generate_run_name(config: pytest.Config) - > str:

Executes for generating new testrail run name right before create test run request is sent. Takes first hook result.

pytest_tr_generate_run_description(config) - > str:

Executes for generating new testrail run description right before create test run request is sent. Takes first hook result.

Release files for pytest-testrail-integrator 1.2.2

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-testrail-integrator 1.2.2
File Size Uploaded
pytest-testrail-integrator-1.2.2.tar.gz 9.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-testrail-integrator 1.2.2
File Interpreter ABI Platform
pytest_testrail_integrator-1.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 21.3 kB

Release files / pytest-testrail-integrator-1.2.2.tar.gz

Download URL pytest-testrail-integrator-1.2.2.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c61448a1659d7b44a9ea99df7d9c0de35a723807432e22bcc2475e1bc21b7b59
BLAKE2b-256 checksum
How to use checksums
aba43a46673bcabe23c5a731cfcba366c83d822f78629cb989edf370d47728f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / pytest_testrail_integrator-1.2.2-py3-none-any.whl

Download URL pytest_testrail_integrator-1.2.2-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
52c625b2ef65f3db8febf2d7b598eb9934627e504366b536cc547838cbb08a6d
BLAKE2b-256 checksum
How to use checksums
396cbc2927358de55e1adaaedfc4aa1637f29b88c5c5adf74f74eb68d77cf36d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release history Release notifications | RSS feed

This release

1.2.2 This release

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

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