Parallel testing allows you to run multiple tests simultaneously, significantly reducing the time required to execute your test suite. By leveraging GitHub Actions’ matrix strategy, you can dynamically distribute your tests across multiple jobs, ensuring efficient and scalable test execution.Documentation Index
Fetch the complete documentation index at: https://docs.testdriver.ai/llms.txt
Use this file to discover all available pages before exploring further.
Why use parallel testing?
- Faster Execution: Run multiple tests at the same time to reduce overall test duration.
- Scalability: Easily scale your testing efforts as your test suite grows.
- Dynamic Distribution: Automatically distribute tests across jobs using GitHub’s matrix strategy.
- Cost Efficiency: Optimize resource usage by running tests in parallel.
- Reliability: Avoid failures from going beyond your plan’s max instances.
Setting Up parallel testing with a matrix strategy
Ensure your test files are stored in a directory (for example,
testdriver/acceptance/) and follow a consistent naming convention (for example, login.yaml, signup.yaml, etc.).Explanation of the workflow
-
gather-test-filesJob:- Collects all test files in the
testdriver/acceptance/directory. - Uses
basenameto get just the filenames without the full path. - Outputs the list of test files as a JSON array for the matrix strategy.
- Collects all test files in the
-
run-testsJob:- Uses the matrix strategy to dynamically create a job for each test file.
- Runs each test file in parallel using
npx testdriverai@latestwith the--headlessflag. - The
max-parallelsetting limits the number of tests that can run in parallel to8(the max instances for the Medium Team Plan).
-
Matrix Strategy:
- The
matrix.testvariable represents each test filename. - Each job runs a single test file from the
testdriver/acceptance/directory.
- The
-
Environment Variables:
TD_API_KEY: Your TestDriver API key for authentication.TD_WEBSITE: The target website URL for testing if its a web application.TD_THIS_FILE: The current test file being executed, this will also be the title of the test recording.
-
Fail-Fast:
- Set to
falseto ensure all tests run even if one fails.
- Set to
Benefits of using the matrix strategy
- Dynamic Test Distribution: Automatically adapts to the number of test files.
- Scalable: Easily handles large test suites by distributing tests across multiple jobs.
- Efficient Resource Usage: Runs tests in parallel, reducing idle time.
Example output
When this workflow runs:- Each test file in
testdriver/acceptance/(for example,login.yaml,signup.yaml) is executed in its own job. - The results of all tests are displayed in the GitHub Actions dashboard with clear matrix job names.
- Failed tests can be easily identified and debugged individually.
Best practices
- Organize Test Files: Use a consistent naming convention for test files to simplify management.
- Monitor Test Results: Review the GitHub Actions dashboard to identify and debug failing tests.
- Optimize Test Files: Ensure each test file is self-contained and doesn’t depend on the execution of other tests.
- Use Fail-Fast Judiciously: Enable
fail-fast: trueonly if you want to stop all tests when one fails.

