Test Quarantine
Skip unstable tests to unblock deployments while you investigate
Test Quarantine
When an unstable test blocks every deployment, quarantine lets you bypass it while you investigate. Quarantined tests still run, so you see if they're fixed, but their failures don't block the pipeline.
QUARANTINE IS TEMPORARY
Create a tracking issue with a deadline for every quarantined test. Quarantined tests represent untested code paths.
Prerequisites
Before using test quarantine commands, ensure you have:
Harness account access: Account ID for your Harness account.
Personal Access Token (PAT): Required for API authentication. Go to Manage API keys to create a PAT.
hcli installed: Harness CLI tool must be available in your environment. Go to Install and configure Harness CLI to download hcli for your operating system and architecture.
Enable Quarantine in Your Pipeline
Many test steps are configured to fail the build when any test fails. When quarantine is enabled, Harness evaluates the test results and ignores failures from quarantined tests when determining the step status.
Quarantined tests still run and their results are recorded, but they won’t cause the step to fail.
To enable this behavior, add the following environment variable to your test step:
Full pipeline example:
When to Quarantine
Flaky test blocks every deployment
Yes
External service is temporarily down
Yes
Urgent release needed, will fix tomorrow
Yes
Test is slow but always passes
No, optimize it
Test fails consistently on all runs
No, fix the bug
How Quarantine Works
FAIL
PASS (ignored)
Does not block
PASS
PASS
No change
SKIP
SKIP
No change
The test still executes, you'll see if it passes or fails—but failures are ignored for pipeline status.
Quarantine a Test
Use the set command with the --quarantine=true flag to quarantine a test:
Required Parameters
--account-id: Your Harness account ID--repo: Repository URL (with or without.gitsuffix)--endpoint: TI service endpoint URL--api-key: Your Personal Access Token (PAT) starting withpat.--class-name: Test class name (must match the class name in your JUnit XML report)--test-name: Test method name (must match the test name in your JUnit XML report)--quarantine: Set totrueto quarantine,falseto remove from quarantine, orunmarkto remove the marking entirely
Optional Parameters
--suite-name: Test suite name (if the test belongs to a specific suite in your JUnit XML report)--org-id: Organization ID (if scoped to an organization)--project-id: Project ID (if scoped to a project)
View Quarantined Tests
Required Parameters
--account-id: Your Harness account ID--repo: Repository URL (with or without.gitsuffix)--endpoint: TI service endpoint URL--api-key: Your Personal Access Token (PAT) starting withpat.
Optional Parameters
--org-id: Organization ID (filters results to a specific organization)--project-id: Project ID (filters results to a specific project)
Example output:
Remove from Quarantine
After fixing the test, use the set command with --quarantine=false:
Advanced: Set Multiple Test Statuses
The set command can update both flaky and quarantine status in a single command:
Available Values
--flaky and --quarantine accept true, false, and unmark:
true: Mark the test with the status
false: Remove the status from the test
unmark: Remove any manual override and let auto-detection decide
Examples
Mark a test as flaky only:
Quarantine a test with suite name:
Remove quarantine marking entirely:
Automate with Policies
Instead of manually quarantining tests, use policies to automate:
This automatically quarantines any test that fails in the current pipeline execution.
Best Practices
Create a tracking issue
Every quarantined test needs an owner
Set a deadline
Quarantine should be temporary (7 days max)
Review weekly
Prevent accumulation of quarantined tests
Fix the root cause
Don't just quarantine—investigate and fix
Next Steps
Set up policies to automate quarantine decisions
View flaky tests to find quarantine candidates
Last updated
Was this helpful?