TestRail-CrossBrowserTesting integration is created to help our users easily upload their test results to their test runs using TestRail's provided API. This example is written in python but you can read about how to use this API in their documentation here: TestRail API Docs
TestRail account with API enabled (you can do this by going to Administration > Site Settings > API > Enable API).
Requests (HTTP request library for python).
Json (JSON library for python).
Both of these are native to python and should already be included in your python environment. If though you do not have these preinstalled you can install them with the package manager Pip. Using pip to install, go to your terminal and type:
pip install requests or
pip install json
Quick start guide
Clone this repository and add TestRails.py to your working directory.
For authentication you will need to provide your email and password as well as your TestRail UR:. Here is a quick example of how a QA at CrossBrowserTesting would authenticate their requests.
testrail_auth = TestRail('cbtQA@crossbrowsertesting.com', 'password_here', 'testcbt.testrail.io')
To add a result to a test you will call
add_result() and provide the two required arguments:
status_id. All other fields are optional and are set by keywords. Put this snippet of code at the end of your test cycle to mark whether your CrossBrowserTesting test has passed or failed.
testrail_auth.add_result(test_id, status_id, comment = "Your comment here", version = "1.0.0")
An example of all the fields you can set are listed here:
||int||The ID of the test status.|
||string||The comment / description for the test result.|
||string||The version or build you tested against.|
||timespan||The time it took to execute the test, e.g. "30s" or "1m 45s".|
||string||A comma-separated list of defects to link to the test result.|
||int||The ID of a user the test should be assigned to.|
Status ids can be passed as integer or string: ex: 1, 2, 4, 5 or Passed, Blocked, Retest, Failed.
Get needed information from Users, Projects, Runs, or Tests
If you need gather any IDs for users, tests, runs, or projects we have also included easy ways to obtain these.
Find user by email account:
"name": "Alexis Gonzalez"
Find all projects:
"name": "New CrossBrowserTesting project",
Find all test runs in project:
"name": "Test Run 5/29/2019",
Find all tests in test run:
"name": "Go to crossbrowsertesting.com",