Package: pytest-testrail2
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 deprecatedpytest-testrailproject.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.Exampleimportpytest@pytest.mark.case_id('C1950')deftest_all_the_things():doit=TrueassertdoitGetting StartedInstallationVia pip:pipinstallpytest-testrail2Plugin ConfigurationThe 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 Testscase_idThecase_idmarker takes a string which must match an existing TestRail testcase.
Only tests with this marker will be added to the TestRail testrun.importpytest# This test's results will be uploaded.@pytest.mark.case_id('C1950')deftest_all_the_things():...# This test's results will not be uploaded.deftest_all_the_other_things():...defect_idsThe ‘defect_ids’ marker takes a list of strings. These will be used in thedefectfield in TestRail. This is useful for tests with known failures.Typically these are IDs for your bug tracking software.importpytest@pytest.mark.case_id('C1950')@pytest.mark.defect_ids(['JS-7001','JS-9001'])deftest_all_the_things():...Running PytestThe–testrailcommand-line flag must be present to upload results:pytest--testrailOptionsSetup--testrailActivate the TestRail plugin.--tr-urlWeb address used to access a TestRail instance.--tr-emailE-mail address for an account on the TestRail instance.--tr-passwordPassword for an account on the TestRail instance.--tr-timeoutTimeout for connecting to a TestRail server.--tr-no-ssl-cert-checkDo not check for valid SSL certificate on TestRail host.Testrun--tr-run-idID 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-namewill be ignored.--tr-testrun-nameName used for a new testrun in TestRail.--tr-testrun-descriptionDescription used for a new testrun in TestRail.--tr-testrun-assignedto-idID of the user to be assigned to the testrun.--tr-testrun-project-idID of the project the testrun will be created in.--tr-testrun-suite-idID of the suite the testrun will be created in.--tr-testrun-suite-include-allInclude all test cases in the specified testsuite for a new testrun.--tr-milestone-idID of milestone used in testrun creation.--tr-skip-missingSkip pytest test functions with marks that are not present in a specified testrun.Testplan--tr-plan-idID of an existing testplan to use. If given,--tr-testrun-namewill be ignored.Publishing--tr-versionSpecify a version in testcase results.--tr-close-on-completeOn pytest completion, close the testrun.--tr-dont-publish-blockedDo not publish results of “blocked” testcases (in TestRail).--tr-custom-commentCustom text appended to comment for all testcase results.