Connect TestRail: step-by-step guide
At the end of each run, opens one TestRail test run with the cases your tests name and posts every result at once: Passed (status 1) or Failed (status 5), with the failing browser and error line. A test with no TestRail case in its file is not reported. This guide takes you from nothing to a verified connection, and lists the errors you can meet with their cause and fix.
Last updated:
Keep your credentials private. Never paste a token, key, password or webhook URL into a chat. Type it only in Studio → Settings → Integrations, where it is saved in your workspace's .env file and shown as dots. The same goes for an AI assistant: it can walk you through this guide, but it never needs your token.
What you need
- A TestRail instance reachable over https, with the API turned on by an administrator.
- A TestRail user whose role can add test runs and results in the project, and an API key of that user.
- The project's numeric ID.
- A case ID (C123) for each test you want reported.
Get the credentials
- An administrator turns the API on once: Administration → Site Settings → API → Enable API, then Save Settings.
- Sign in as the user the Studio will act as, open My Settings → API Keys, choose Add API Key, name it and press Generate. Copy it now: TestRail shows it once.
- Open the project in TestRail: its ID is the number at the end of its address (index.php?/projects/overview/<ID>).
Connect it in the Studio
- In the Studio, open Settings → Integrations → TestRail.
- Fill
TESTRAIL_URL(like https://your-team.testrail.io),TESTRAIL_USER(the user's email),TESTRAIL_API_KEYandTESTRAIL_PROJECT_ID, turn onTESTRAIL_ENABLEDand press Save changes. - In each test file you want reported, add one comment with its case ID: // nexus:testrail C123 (Python: # nexus:testrail C123). TestRail needs no destination on the Tickets page.
Check that it works
- Run the suite. At the end, the run log shows "[TestRail] run R<number>: <n> result(s)".
- Open that run in TestRail and check that every case with a marker has a result. A case that failed on any browser is Failed.
Common errors
| What you see | Cause | Fix |
|---|---|---|
"[TestRail] needs an https TESTRAIL_URL, TESTRAIL_USER, TESTRAIL_API_KEY and TESTRAIL_PROJECT_ID: nothing reported" | A field is empty, the URL is not https, or the project ID is not a number. | Fix the field it names in Settings → Integrations → TestRail. |
| "TestRail add_run answered HTTP 401" | The email and key do not match, the key was deleted, or the API is off on the instance. | Generate a new key as that user, and ask an administrator to check Site Settings → API. |
| "TestRail add_run answered HTTP 403" | The user's role cannot add test runs in the project. | Give the user a role that can add test runs and results, or use another user. |
| "TestRail add_run answered HTTP 400" | The project ID is wrong, or a case ID in a marker is not in that project. | Check the project ID and the C numbers in your test files. |
| The run finishes and nothing is reported | No test in the run has a // nexus:testrail C<ID> marker, TESTRAIL_ENABLED is off, or it was a sandbox run. | Add the marker to the test file whose name starts with the test ID, and turn the switch on. |
Settings keys
| Key | What it does | Valid value | How to check it |
|---|---|---|---|
TESTRAIL_ENABLED | Send results to TestRail | true or false | Turn on, then run a suite with at least one marked test. |
TESTRAIL_URL | TestRail address | https://<your TestRail> with no user:password@ and no path | An http address is refused: the key is only ever sent over https. |
TESTRAIL_USER | TestRail user | The email of the TestRail user that owns the API key | HTTP 401 means this email and the key do not belong together. |
TESTRAIL_API_KEY | TestRail API key (secret, saved only on this computer) | One line, no quotes, no spaces | HTTP 401 means the key is wrong or was deleted. |
TESTRAIL_PROJECT_ID | TestRail project | A whole number, 1 or higher | HTTP 400 on add_run usually means the project or a case ID is wrong. |
More: all integrations, the Settings guide, troubleshooting. Other guides: Jira Cloud, Azure Boards, Slack, Microsoft Teams, Telegram, GitHub Issues, Linear, GitLab Issues, PagerDuty, Ticket webhook, Tickets.
Still stuck? Write to support@nexusstudioqa.com with the exact error line the Studio shows. Do not include a token.