Test Orchestrator
Overview
Coordinate parallel test execution across multiple test suites, frameworks, and environments. Manages test splitting, worker allocation, result aggregation, and intelligent retry strategies.
Prerequisites
- Test runner with parallel execution support (Jest, Vitest, pytest-xdist, Playwright, or JUnit 5)
- CI/CD platform configured (GitHub Actions, GitLab CI, CircleCI, or Jenkins)
- Test suite with consistent pass rates (flaky tests identified and tagged)
- Sufficient CI runner resources for parallel worker count
- Test result reporting tool (JUnit XML, Allure, or equivalent)
Instructions
- Analyze the existing test suite using Grep and Glob to catalog all test files, their framework, approximate run time, and dependency requirements.
- Classify tests into execution tiers:
- Tier 1 (Fast): Unit tests with no I/O -- target under 30 seconds total.
- Tier 2 (Medium): Integration tests requiring local services -- target under 3 minutes.
- Tier 3 (Slow): E2E and browser tests -- target under 10 minutes.
- Configure parallel execution for each tier:
- Split unit tests across N workers using
jest --shard=i/N or pytest -n auto.
- Shard E2E tests by test file using Playwright
--shard=i/N or Cypress parallelization.
- Assign heavier integration tests to dedicated workers with more resources.
- Create a CI pipeline configuration that runs tiers in parallel:
- Tier 1 and Tier 2 run concurrently on separate jobs.
- Tier 3 runs after a fast pre-check gate passes.
- Each tier reports results to a unified collection step.
- Implement intelligent retry logic for flaky tests:
- Tag known flaky tests with
@flaky or equivalent marker.
- Retry failed tests up to 2 times before marking as failed.
- Track flaky test frequency in a log file for triage.
- Aggregate results from all parallel workers into a single report:
- Merge JUnit XML files from each shard.
- Calculate total pass/fail/skip counts and execution time.
- Identify the slowest tests for optimization targets.
- Write the orchestration configuration to the project's CI config file and validate it with a dry run.
Output
- CI pipeline configuration file (
.github/workflows/test.yml, .gitlab-ci.yml, or equivalent)
- Test sharding configuration with worker count and split strategy
- Merged test result report in JUnit XML or JSON format
- Execution timeline showing parallel job durations and bottlenecks
- Flaky test inventory with retry counts and failure patterns
Error Handling
| Error |
Cause |
Solution |
| Shard produces zero tests |
Uneven test distribution or incorrect shard index |
Verify shard count matches actual test file count; use file-based splitting |
| Worker out of memory |
Too many parallel processes on one runner |
Reduce --maxWorkers or -n count; increase runner memory; use --workerIdleMemoryLimit |
| Test ordering dependency |
Tests pass in isolation but fail in specific shard order |
Add --randomize flag; fix shared state leaks; enforce test independence |
| Result aggregation mismatch |
Missing shard results due to job timeout |
Set job-level timeouts higher than test timeouts; add result upload as a separate step |
| CI cache miss slowing startup |
Dependencies not cached between parallel jobs |
Configure dependency caching per lockfile hash; use a shared setup job |
Examples
GitHub Actions matrix strategy for Jest sharding:
jobs:
test:
strategy:
matrix:
shard: [1, 2, 3, 4]
steps:
- run: npx jest --shard=${{ matrix.shard }}/4 --ci --reporters=jest-junit
- uses: actions/upload-artifact@v4
with:
name: results-${{ matrix.shard }}
path: junit.xml
merge:
needs: test
steps:
- uses: actions/download-artifact@v4
- run: npx junit-merge -d results-* -o merged-results.xml
pytest-xdist parallel execution:
pytest -n auto --dist worksteal -q --junitxml=results.xml
Playwright sharded execution:
npx playwright test --shard=1/3 --reporter=junit
Resources
1---2name: orchestrating-test-execution3description: |4 Test coordinate parallel test execution across multiple environments and frameworks.5 Use when performing specialized testing.6 Trigger with phrases like "orchestrate tests", "run parallel tests", or "coordinate test execution".78allowed-tools: Read, Write, Edit, Grep, Glob, Bash(test:orchestrate-*)9version: 1.0.010author: Jeremy Longshore <jeremy@intentsolutions.io>11license: MIT12compatible-with: claude-code, codex, openclaw13metadata:14 source: https://skillmd.com/skills/micsapp/orchestrating-test-execution15---1617# Test Orchestrator1819## Overview2021Coordinate parallel test execution across multiple test suites, frameworks, and environments. Manages test splitting, worker allocation, result aggregation, and intelligent retry strategies.2223## Prerequisites2425- Test runner with parallel execution support (Jest, Vitest, pytest-xdist, Playwright, or JUnit 5)26- CI/CD platform configured (GitHub Actions, GitLab CI, CircleCI, or Jenkins)27- Test suite with consistent pass rates (flaky tests identified and tagged)28- Sufficient CI runner resources for parallel worker count29- Test result reporting tool (JUnit XML, Allure, or equivalent)3031## Instructions32331. Analyze the existing test suite using Grep and Glob to catalog all test files, their framework, approximate run time, and dependency requirements.342. Classify tests into execution tiers:35 - **Tier 1 (Fast)**: Unit tests with no I/O -- target under 30 seconds total.36 - **Tier 2 (Medium)**: Integration tests requiring local services -- target under 3 minutes.37 - **Tier 3 (Slow)**: E2E and browser tests -- target under 10 minutes.383. Configure parallel execution for each tier:39 - Split unit tests across N workers using `jest --shard=i/N` or `pytest -n auto`.40 - Shard E2E tests by test file using Playwright `--shard=i/N` or Cypress parallelization.41 - Assign heavier integration tests to dedicated workers with more resources.424. Create a CI pipeline configuration that runs tiers in parallel:43 - Tier 1 and Tier 2 run concurrently on separate jobs.44 - Tier 3 runs after a fast pre-check gate passes.45 - Each tier reports results to a unified collection step.465. Implement intelligent retry logic for flaky tests:47 - Tag known flaky tests with `@flaky` or equivalent marker.48 - Retry failed tests up to 2 times before marking as failed.49 - Track flaky test frequency in a log file for triage.506. Aggregate results from all parallel workers into a single report:51 - Merge JUnit XML files from each shard.52 - Calculate total pass/fail/skip counts and execution time.53 - Identify the slowest tests for optimization targets.547. Write the orchestration configuration to the project's CI config file and validate it with a dry run.5556## Output5758- CI pipeline configuration file (`.github/workflows/test.yml`, `.gitlab-ci.yml`, or equivalent)59- Test sharding configuration with worker count and split strategy60- Merged test result report in JUnit XML or JSON format61- Execution timeline showing parallel job durations and bottlenecks62- Flaky test inventory with retry counts and failure patterns6364## Error Handling6566| Error | Cause | Solution |67|-------|-------|---------|68| Shard produces zero tests | Uneven test distribution or incorrect shard index | Verify shard count matches actual test file count; use file-based splitting |69| Worker out of memory | Too many parallel processes on one runner | Reduce `--maxWorkers` or `-n` count; increase runner memory; use `--workerIdleMemoryLimit` |70| Test ordering dependency | Tests pass in isolation but fail in specific shard order | Add `--randomize` flag; fix shared state leaks; enforce test independence |71| Result aggregation mismatch | Missing shard results due to job timeout | Set job-level timeouts higher than test timeouts; add result upload as a separate step |72| CI cache miss slowing startup | Dependencies not cached between parallel jobs | Configure dependency caching per lockfile hash; use a shared setup job |7374## Examples7576**GitHub Actions matrix strategy for Jest sharding:**77```yaml78jobs:79 test:80 strategy:81 matrix:82 shard: [1, 2, 3, 4]83 steps:84 - run: npx jest --shard=${{ matrix.shard }}/4 --ci --reporters=jest-junit85 - uses: actions/upload-artifact@v486 with:87 name: results-${{ matrix.shard }}88 path: junit.xml89 merge:90 needs: test91 steps:92 - uses: actions/download-artifact@v493 - run: npx junit-merge -d results-* -o merged-results.xml94```9596**pytest-xdist parallel execution:**97```bash98pytest -n auto --dist worksteal -q --junitxml=results.xml99```100101**Playwright sharded execution:**102```bash103npx playwright test --shard=1/3 --reporter=junit104```105106## Resources107108- Jest sharding: https://jestjs.io/docs/cli#--shardshardindex-shardcount109- pytest-xdist: https://pytest-xdist.readthedocs.io/110- Playwright test sharding: https://playwright.dev/docs/test-sharding111- GitHub Actions matrix strategy: https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs112- JUnit XML merge tools: https://github.com/imsky/junit-merge