Home

Awesome

pytest-testrail

PyPI version Downloads Codacy Badge

This is a pytest plugin for creating/editing testplans or testruns based on pytest markers. The results of the collected tests will be updated against the testplan/testrun in TestRail.

Installation

pip install pytest-testrail

Configuration

Config for Pytest tests

Add a marker to the tests that will be picked up to be added to the run.

    from pytest_testrail.plugin import testrail

    @testrail('C1234', 'C5678')
    def test_foo():
        # test code goes here

    # OR	

    from pytest_testrail.plugin import pytestrail

    @pytestrail.case('C1234', 'C5678')
    def test_bar():
        # test code goes here

Or if you want to add defects to testcase result:


    from pytest_testrail.plugin import pytestrail

    @pytestrail.defect('PF-524', 'BR-543')
    def test_bar():
        # test code goes here

Config for TestRail

    [API]
    url = https://yoururl.testrail.net/
    email = user@email.com
    password = <api_key>

    [TESTRUN]
    assignedto_id = 1
    project_id = 2
    suite_id = 3
    plan_id = 4
    description = 'This is an example description'

    [TESTCASE]
    custom_comment = 'This is a custom comment'

Or

Usage

Basically, the following command will create a testrun in TestRail, add all marked tests to run. Once the all tests are finished they will be updated in TestRail:

    py.test --testrail --tr-config=<settings file>.cfg

All available options

optiondescription
--testrailCreate and update testruns with TestRail
--tr-configPath to the config file containing information about the TestRail server (defaults to testrail.cfg)
--tr-urlTestRail address you use to access TestRail with your web browser (config file: url in API section)
--tr-emailEmail for the account on the TestRail server (config file: email in API section)
--tr-passwordPassword for the account on the TestRail server (config file: password in API section)
--tr-testrun-assignedto-idID of the user assigned to the test run (config file:assignedto_id in TESTRUN section)
--tr-testrun-project-idID of the project the test run is in (config file: project_id in TESTRUN section)
--tr-testrun-suite-idID of the test suite containing the test cases (config file: suite_id in TESTRUN section)
--tr-testrun-suite-include-allInclude all test cases in specified test suite when creating test run (config file: include_all in TESTRUN section)
--tr-testrun-nameName given to testrun, that appears in TestRail (config file: name in TESTRUN section)
--tr-testrun-descriptionDescription given to testrun, that appears in TestRail (config file: description in TESTRUN section)
--tr-run-idIdentifier of testrun, that appears in TestRail. If provided, option "--tr-testrun-name" will be ignored
--tr-plan-idIdentifier of testplan, that appears in TestRail (config file: plan_id in TESTRUN section) If provided, option "--tr-testrun-name" will be ignored
--tr-versionIndicate a version in Test Case result.
--tr-no-ssl-cert-checkDo not check for valid SSL certificate on TestRail host
--tr-close-on-completeClose a test plan or test run on completion.
--tr-dont-publish-blockedDo not publish results of "blocked" testcases in TestRail
--tr-skip-missingSkip test cases that are not present in testrun
--tr-milestone-idIdentifier of milestone to be assigned to run
--tc-custom-commentCustom comment, to be appended to default comment for test case (config file: custom_comment in TESTCASE section)