Skip to main content

Pytest plugin for sending report to testrail system.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-testrail-integrator-1.0.0.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

pytest_testrail_integrator-1.0.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file pytest-testrail-integrator-1.0.0.tar.gz.

File metadata

File hashes

Hashes for pytest-testrail-integrator-1.0.0.tar.gz
Algorithm Hash digest
SHA256 78ee0f4d26dc9e8af6605379cc87aca0a8c12aa9bc5a4569d47b6a82c249550f
MD5 34e736608f53f054bb0a155d7ea70823
BLAKE2b-256 69970bef2c1dfaefd8fae2f0eb414821ae8ce2bc56bdad66786ddeedf75dacd4

See more details on using hashes here.

File details

Details for the file pytest_testrail_integrator-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_testrail_integrator-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 946d0854ee9f13490b5af5cd30c0ce6af16a9bd543d7414083c8d9907004b91a
MD5 822e797e35d957ab81272c22e9379233
BLAKE2b-256 e636a266a18ed43efe0e4af70c2424bc3c394a8a9d88f1b1ca3453851f0e719f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page