With the TestRail integration, you can link mabl tests to TestRail cases and record plan run results in TestRail without maintaining a custom script. Your team keeps managing test cases and reviewing results in TestRail, while mabl keeps TestRail current: each completed mabl plan run becomes a TestRail run, with a report of exactly which cases were recorded and which case links were skipped.
This article explains how to set up the TestRail integration, link TestRail cases to mabl tests, and sync plan run results.
- Set up the integration
- Link TestRail cases to mabl tests
- Sync plan run results to TestRail
- When a sync is incomplete or fails
Availability
The TestRail integration a new offering and is currently enabled per account. If you're interested in using it, reach out to your customer success manager.
Set up the integration
Gather your TestRail credentials
Before you add the integration in mabl, collect the following details from TestRail:
- The URL of your TestRail Cloud or TestRail Server instance. The instance must be reachable over HTTPS.
- The email address and API key of a TestRail user. To create an API key, open My Settings > API Keys in TestRail.
- The TestRail project whose cases you want to link. If the project uses multiple test suites, you can also note the numeric ID of the suite you want to target.
Results synced by mabl are recorded in TestRail as the user whose API key you enter.
As a best practice, we recommend creating a dedicated "mabl-sync" user in TestRail and generating the API key for that user. A dedicated user keeps the audit trail in TestRail clear and keeps the integration working when people leave the team.
Add the integration in mabl
After collecting your TestRail credentials, you can configure the integration in mabl:
- In the mabl app, go to the integrations page: Settings > Integrations.
- In the Available integrations section, click on the + Setup button for TestRail.
- Give the integration a name. The default name is "TestRail integration".
- Under Setup, leave Integration enabled on. Check Automatically sync plan run results if you want mabl to record every completed plan run in TestRail on its own. You can also turn it on later. See Automatic sync for details.
- Enter the TestRail URL, the Email of the API user, and the API key. If you enter a bare host such as
your-instance.testrail.io, mabl addshttps://for you. TestRail URLs must use HTTPS. - Click Test connection. mabl checks the credentials against TestRail and, on success, loads the projects that the user can see.
- Under Configure, choose the Project. If the project is split into several test suites, a Suite ID field appears. Enter the numeric ID of one suite to search it every time, or leave the field empty if you prefer to choose the suite each time you search for a case.
- Click Save.
The integration appears in the Active integrations section with its status and host URL.
Each TestRail integration connects to one TestRail project. To link cases from another project or another TestRail instance, add a second integration and give it a unique name. When more than one integration is enabled, the case picker on a test lets you choose which instance to search, and a synced plan run gets a separate TestRail run for each integration whose cases it touched.
Required result fields
If your TestRail instance requires a custom result field that mabl doesn't populate, the setup form warns you that "Your TestRail instance requires result fields that mabl does not populate" and names the fields. Syncing results may fail until a TestRail administrator makes those fields optional under Administration > Customizations > Result Fields.
Edit, disable, or remove the integration
To edit the integration, find it in the Active integrations section and click on the pencil icon. mabl never shows the saved API key again; the field reads "API key (saved)". If you save without entering a key, mabl keeps the stored one. Test connection checks the saved key against the saved URL and email, so to test the connection after changing the URL or email, enter the API key again.
To pause the integration without removing it, turn off Integration enabled and click Save. While the integration is disabled, mabl doesn't link tests to TestRail cases or sync results.
To remove the integration, click on the trash icon in its row and confirm. Case IDs already stored on tests are kept as plain text. They stop linking to TestRail, and results stop syncing. If you add a TestRail integration again later, the stored IDs link to TestRail cases again.
Link TestRail cases to mabl tests
Link mabl tests to TestRail cases through the Test case IDs field in the test information dialog. When the workspace has a TestRail integration, this field searches TestRail, and any ID that looks like a TestRail case, such as C123, becomes a link to the case in TestRail. Plan runs record results against the linked cases.
The field still accepts IDs for other test case management integrations. mabl keeps them exactly as you typed them and doesn't send them to TestRail.
Existing test case IDs
If your team already typed TestRail case IDs into the Test case IDs field, for example for a custom integration, you don't need to enter them again. They link to TestRail as soon as you save the integration.
Add TestRail cases to a mabl test
- On the test details page, click on the pencil icon to update test information.
- In the Test case IDs field, find the case in one of two ways:
- Start typing part of the case title. mabl searches the project that the integration is configured for and groups the results by suite and section. Cases that are already linked to the test are marked Linked. Select a result.
- Type the case ID and press Enter.
C123,c123, andc0123all refer to case 123.
- Each linked case appears as a button with the case ID and title. Add as many as you need, up to 20 per test.
- Click Save.
The test header now shows the case IDs. TestRail IDs link to the case in TestRail. Other IDs appear as plain text.
Cases that mabl can't find
If you type an ID and mabl can't find the case on your instance, it says so and offers Link anyway. A case linked this way is flagged "not found in TestRail". Plan runs skip it until the case exists in TestRail, and then it syncs like any other case.
Multiple integrations and suites
Depending on how your TestRail integrations are set up, the Test case IDs field may show one or two extra selectors:
- TestRail instance: appears when more than one TestRail integration is enabled. Choose the instance you want to search.
- Suite: appears when the TestRail project is split into several test suites and the integration doesn't target one of them. Choose the suite to search. TestRail searches for cases within a suite, so a title search can't run until you pick one.
You can skip the Suite selector by typing the case ID instead of searching by title. Case IDs are unique across a TestRail instance, so mabl can find C123 without knowing which suite it belongs to.
Remove a case link
On the test details page, click on the pencil icon to edit test metadata, click on the × on the test case you want to remove, and click Save.
Create a test from a TestRail case
If a TestRail case already describes what a test should do, you can hand that case to the mabl agent when building new tests. When the workspace has an enabled TestRail integration, the + menu below the prompt on the Build tests page includes a Case option.
- Go to Build tests and, on the New test or Edit test tab, click + below the prompt and choose Case.
- Search TestRail by case title or case ID. Each picked case appears as a chip. You can add up to five cases.
- Describe anything the case doesn't cover, such as test data or the starting state, and send the prompt.
The agent reads each case's preconditions, steps, and expected results and uses them as the specification for the test outline. If it can't read a case in full, the outline says which case and doesn't claim to cover it.
The search covers the TestRail project that the integration is configured for. If that project has several test suites, the integration must target one suite. Otherwise the Case option can't search it, and the picker tells you to configure a suite on the integration.
Picking a case as a reference doesn't link it to the test. Once the test is created, add the case in the Test case IDs field as described above so plan runs record results against it.
Sync plan run results to TestRail
In TestRail, a run is a record of one pass through a set of cases. A plan run is the equivalent event in mabl, so mabl records results in TestRail at the plan run level. When a mabl plan run syncs, whether manually or automatically, it creates a corresponding run in TestRail and records a result for each case linked to a test in the plan.
A plan doesn't need to be fully linked. mabl tests without a linked TestRail case run as usual in mabl, but they aren't recorded in TestRail and aren't listed as skipped.
The TestRail button in the plan run header shows whether the run's results are in TestRail. Click on the button to check the sync status and to sync the results. If a sync doesn't record everything you expected, see When a sync is incomplete or fails.
Sync a plan run manually
- Open the plan run output page and click on the TestRail button.
- Click Sync to TestRail.
- The button reads "Syncing to TestRail" while the sync runs, then shows the result. The Results went to section of the popover links to the TestRail run that mabl created.
Automatic sync
With automatic sync on, mabl records every completed plan run in TestRail without anyone clicking Sync.
- Go to Settings > Integrations and click on the pencil icon for the TestRail integration.
- Under Setup, check Automatically sync plan run results.
- Click Save.
From the next plan run on, the TestRail button moves from "Waiting for the run to finish" to "Syncing to TestRail" to "TestRail" on its own, usually within a minute of the run completing. The popover shows the TestRail run it created, exactly as it does for a manual sync. Manual Sync to TestRail and Sync again stay available.
To turn automatic sync off, uncheck Automatically sync plan run results in the integration settings and click Save. Runs that already synced stay in TestRail. New runs show "TestRail — not synced" until someone syncs them manually.
What mabl records in TestRail
Each sync creates a TestRail run in the integration's project, named after the mabl plan and plan run. For each TestRail case linked to a test in the plan, mabl adds one result to that run:
- Passed mabl tests are recorded as Passed, and failed tests as Failed.
- TestRail has no built-in Skipped status. If you have added a custom Skipped status to your TestRail instance, mabl uses it for skipped or stopped tests. Otherwise, those tests are reported in the popover as "no result to record".
- Each result's comment starts with "Result reported by mabl" and names the mabl test behind it.
- If several mabl tests link the same case, TestRail receives one result with the worst status among them, and the comment names every test.
Sync again posts the run's results a second time, which is useful if someone edited them in TestRail. Re-syncing doesn't fix a case link that was skipped for a reason on the mabl side. A corrected case ID is picked up by the next plan run.
What isn't synced
- Ad hoc runs of a single test. Only plan runs are recorded in TestRail.
- Cancelled or stopped plan runs.
- Tests that are disabled in the plan, or that have no linked TestRail case. They produce no result in TestRail and aren't listed as skipped.
- IDs for other test case management systems. They're left for the system they belong to.
When a sync is incomplete or fails
Three statuses on the TestRail button mean that a run needs attention:
- TestRail — N links skipped: the run is synced, but some case links couldn't be recorded. Click on the button and review the Skipped section of the popover. Each skipped link is listed with a reason. See Skipped case links.
- TestRail sync failed: the sync stopped before it finished. The popover says how many cases were recorded before it stopped and what TestRail reported. Click Sync again. If it fails the same way, check the integration settings.
- TestRail sync status unavailable: mabl couldn't check whether this run was synced. Reload the page, or sync the run.
The plan's run history and the Plans page show the same state as Sync incomplete or Sync failed, so you can spot a run that needs attention without opening it.
Skipped case links
When a case link couldn't be recorded, the popover lists it with one of the following reasons:
| Reason | What to do |
|---|---|
| not a TestRail case ID | Fix the case ID on the test. The next plan run syncs it. |
| not found in TestRail | Check that the case exists in TestRail, then sync again. |
| no suite or project | The case is in a suite that the integration's project doesn't cover. Check the case's suite in TestRail, then sync again. |
| not in the TestRail run | The case wasn't part of the TestRail run that this sync created. Sync again to add it. |
| rejected by TestRail | TestRail refused the result, often because a required result field is missing. Check the case in TestRail, then sync again. |
| no result to record | The test was skipped or stopped, and this TestRail instance has no Skipped status. Add a custom Skipped status in TestRail, or accept that skipped tests stay untested there. |
Sync again only helps when the cause was on the TestRail side. A case ID that you correct on the test is picked up by the next plan run.
Limitations
- Each integration connects to one TestRail project.
- A test can link up to 20 case IDs.
- The integration reads cases from TestRail and records results. It doesn't create or edit cases in TestRail.
If any of these limitations impact your team's workflow, please share your feedback in the mabl Product Portal.