Package: pytest-testrail-e2e
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.Installationpip install pytest-testrail-e2eConfigurationConfig for Pytest testsAdd a marker to the tests that will be picked up to be added to the run.frompytest_testrail.pluginimporttestrail@testrail('C1234','C5678')deftest_foo():# test code goes here# ORfrompytest_testrail.pluginimportpytestrail@pytestrail.case("C1234","C5678")deftest_bar():# test code goes hereOr if you want to add defects to testcase result:frompytest_testrail.pluginimportpytestrail@pytestrail.defect("PF-524","BR-543")deftest_bar():# test code goes hereSkip a testcase [You need create ‘Skipped’ status in TestRail’]:frompytest_testrail.pluginimportpytestrail@pytestrail.case("C1234")@pytest.mark.skip("Mark as skipped description")# or @pytest.mark.skip(reason="Mark as skipped description")deftest_bar():# test code goes hereBlock a testcase:importpytestfrompytest_testrail.pluginimportpytestrail@pytestrail.case("C1234")@pytestrail.block("Mark as blocked description")# @pytestrail.block(reason="Mark as blocked description")deftest_bar():# test code goes here# OR@pytestrail.case("C1234")@pytest.mark.skip(reason="Mark as blocked description",block=True)deftest_bar():# test code goes hereHow to set known defect ID for specific assertion: setpytest-defect=<defect_id>in assertion error message.frompytest_testrail.pluginimportpytestrail@pytestrail.case("C1234")@pytestrail.defectif()deftest_bar():# Assertion 1: defect NCT-836assert1==0,"pytest-defect=NCT-836"# Assertion 2: defect NCT-1024assertFalse,"Error message contains regex: pytest-defect=NCT-1024 allows to insert defect 'NCT-1024'"Config for TestRailSettings file template config:[API]url=https://yoururl.testrail.net/email=user@email.compassword=<api_key>[TESTRUN]assignedto_id=1project_id=2suite_id=3plan_id=4description='This is an example description'[TESTCASE]custom_comment='This is a custom comment'OrSet command line options (see below)UsageBasically, 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=<settingsfile>.cfgAll available optionsoptiondescription–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-as
signedto-idID of the user assigned to the test run (configfile:assignedto_idin TESTRUN section)–tr-testrun-pr
oject-idID of the project the test run is in (config file:
project_id in TESTRUN section)–tr-testrun-su
ite-idID of the test suite containing the test cases (config
file: suite_id in TESTRUN section)–tr-testrun-su
ite-include-allInclude all test cases in specified test suite when
creating test run (config file: include_all in TESTRUN
section)–tr-testrun-na
meName given to testrun, that appears in TestRail (config
file: name in TESTRUN section)–tr-testrun-de
scriptionDescription 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. If
provided, option “–tr-testrun-name” will be ignored–tr-versionIndicate a version in Test Case result.–tr-no-ssl-cer
t-checkDo not check for valid SSL certificate on TestRail host–tr-close-on-c
ompleteClose a test plan or test run on completion.–tr-dont-publi
sh-blockedDo not publish results of “blocked” testcases in
TestRail–tr-skip-missi
ngSkip test cases that are not present in testrun–tr-milestone-
idIdentifier of milestone to be assigned to run–tc-custom-com
mentCustom comment, to be appended to default comment for
test case (config file: custom_comment in TESTCASE
section)–tr-report-sin
gle-testReport result immediately for each test case when it
finishedTestRail SettingsTo increase security, the TestRail team suggests using an API key
instead of a password. You can see how to generate an API keyhere.If you maintain your own TestRail instance on your own server, it is
recommended toenable HTTPS for your TestRail
installation.For TestRail hosted accounts maintained byGurock, all accounts will automatically use
HTTPS.You can read the whole TestRail documentationhere.AuthorNGUYEN Viet -githubLicenseThis project is licensed under theMIT license.Acknowledgmentsallankp, author of thepytest-testrailrepository that was cloned.