Skip to main content
This guide explains how to extract test cases from TestRail and convert them into TestDriver YAML test files. By automating this process, you can ensure that your TestRail test cases are directly translated into actionable tests for TestDriver.

Workflow overview

  1. Export Test Cases from TestRail: Use the TestRail API to fetch test cases.
  2. Convert Test Cases to TestDriver YAML: Transform the test cases into YAML test files.
  3. Save and Organize Test Files: Store the generated YAML files in a structured directory.
  4. Run Tests with TestDriver: Execute the tests using the TestDriver CLI.

Step 1: Export test cases from TestRail

Prerequisites

  1. TestRail API Key: Obtain your API key from TestRail.
  2. TestRail Base URL: Your TestRail instance URL (for example, https://yourcompany.testrail.io).
  3. Node.js: Ensure Node.js is installed on your system.

Script: Export test cases from TestRail

The following script fetches TestRail test cases and extracts the title and steps.

Install dependencies:

Node.js script (export-testrail-test-cases.js):


Step 2: Convert test cases to TestDriver YAML

The script above generates a YAML file for each TestRail test case. Each file contains the steps as prompt entries.

Example

testdriver/test_123.yaml

Step 3: Save and organize test files

  1. The generated YAML files will be saved in the testdriver/ directory.
  2. Ensure the directory is part of your TestDriver project structure.

Step 4: Run tests with TestDriver

Use the TestDriver CLI to execute the generated test files.

Run a Single test file:


Best practices

  1. Field Mapping: Ensure the correct TestRail field ID (for example, custom_steps) is used for test steps.
  2. Secure Credentials: Store TestRail API credentials in environment variables or secrets.
  3. Review Generated Files: Manually review the YAML files to ensure they align with your testing requirements.
  4. Organize Tests: Use a structured directory (for example, testdriver/) to manage your test files.

Summary

By following this guide, you can automate the process of importing test cases from TestRail into TestDriver test files. This ensures that your test steps are directly translated into actionable tests, streamlining your testing workflows and improving coverage.