Add TestRail to capabilities

Learn how to add TestRail to your capabilities so you can automatically update TestRail projects and link the results in your session overview.

Before you start

You’ll need to complete the following:

Create constant variables

First, download your auto-generated Appium script and open the config file in the test directory. The exact location and name of the config file will depend on your testing framework.

Example
root
└── src
    └── test
        └── Config # Java TestNG
        └── Config.java # Java JUnit
        └── config.js # NodeJS Mocha

In the config file, assign your Kobiton username and API key to constant variables.

public class Config {

    // Kobiton credentials
    public static final String KOBITON_USERNAME = "<username>"; // Add your Kobiton username.
    public static final String KOBITON_API_KEY = "<api-key>"; // Add your Kobiton API key.
}

Below your Kobiton credentials, assign your TestRail server address, username, and API key to constant variables.

public class Config {

    // Kobiton credentials

    // TestRail credentials
    public static final String TCM_SERVER_ADDRESS = "<testrail-server-address>"; // Add your TestRail server address.
    public static final String TCM_USERNAME = "<testrail-username>";  // Add your TestRail username.
    public static final String TCM_API_KEY = "<testrail-api-key>"; // Add your TestRail API key.
}

Add desired capabilities

Next, in the same config file, locate DesiredCapabilities and add the following capabilities:

"kobiton:tcmServerAddress"

Assign to the TestRail server address variable.

"kobiton:tcmUsername"

Assign to the TestRail username variable.

"kobiton:tcmpApiKey"

Assign to the TestRail API key variable.

"kobiton:externalRunId"

Assign to your TestRail project’s run ID.

"kobiton:externalCaseId"

Assign to your TestRail project’s case ID.

Example
public static DesiredCapabilities getIPhone11ProIOS146DesiredCapabilities() {
    DesiredCapabilities capabilities = new DesiredCapabilities();

    // Add these desired capabilities:
    capabilities.setCapability("kobiton:tcmServerAddress", TCM_SERVER_ADDRESS); // Assigned to your TestRail server address variable.
    capabilities.setCapability("kobiton:tcmUsername", TCM_USERNAME); // Assigned to your TestRail username variable.
    capabilities.setCapability("kobiton:tcmpApiKey", TCM_API_KEY); // Assigned to your TestRail API key variable.
    capabilities.setCapability("kobiton:externalRunId", "<run-id>"); // Assigned to your TestRail project's run ID.
    capabilities.setCapability("kobiton:externalCaseId", "<case-id>"); // Assigned to your TestRail project's run ID.

    return capabilities;
}

When you’re finished, save your changes. Now future automation sessions using this config will automatically update this TestRail project and display the project IDs in the session overview.