Upload Test Results
Uploading test results to Harness enables flaky test detection, test history tracking, and visibility in the Tests tab. This is the foundation for all test management features.
Supported Formats
| Format | Languages |
|---|---|
| JUnit XML | Java, Python, Go, Node.js, and most languages |
Pipeline Examples
- Python
- Java/Gradle
- Go
- .NET
- run:
script: |-
# Install dependencies
pip install pytest
# Run tests with JUnit output
pytest tests/ --junitxml=test-results.xml -v
# Upload to Harness
hcli test-reports upload test-results.xml
env:
CI_ENABLE_QUARANTINED_TEST_SKIP: "true"
- step:
type: Run
name: Run Tests
spec:
shell: Sh
command: |
./gradlew clean test
hcli test-reports upload "build/test-results/test/*.xml"
envVariables:
CI_ENABLE_QUARANTINED_TEST_SKIP: "true"
- run:
script: |-
# Install JUnit reporter
go install github.com/jstemmer/go-junit-report/v2@latest
# Run tests and convert output to JUnit XML
go test -v ./... 2>&1 | go-junit-report > report.xml
# Upload to Harness
hcli test-reports upload report.xml
env:
CI_ENABLE_QUARANTINED_TEST_SKIP: "true"
- run:
script: |-
# Run tests with TRX output (converts to JUnit)
dotnet test --logger "junit;LogFilePath=test-results.xml"
# Upload to Harness
hcli test-reports upload test-results.xml
View Results
After the stage uploading tests completes:
- Open the pipeline execution
- Click the Tests tab
You'll see:
| Column | Description |
|---|---|
| Test Name | Fully qualified test name |
| Status | Pass, Fail, or Skip |
| Duration | How long the test took |
| FLAKY badge | Appears if the test has inconsistent results |
Use Filter → Flaky to show only flaky tests.
Command Reference
hcli test-reports upload <file-or-glob>
| Parameter | Example | Description |
|---|---|---|
| File path | test-results.xml | Single file |
| Glob pattern | "**/test-results/*.xml" | Multiple files (use quotes) |
Troubleshooting
| Issue | Solution |
|---|---|
| Tests not appearing | Verify the file path is correct and the XML format is valid |
| Glob not matching | Use quotes around patterns: "build/**/*.xml" |
| Upload fails silently | Add --verbose flag to see detailed output |
Next Steps
Once test results are uploading:
- View flaky tests detected automatically
- Enable quarantine to unblock deployments
- Add code coverage tracking