Skip to main content

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.

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:

env:
CI_ENABLE_QUARANTINED_TEST_SKIP: "true"

Full pipeline example:

- run:
script: |-
pytest --junitxml=test-results.xml -v
hcli test-reports upload test-results.xml
env:
CI_ENABLE_QUARANTINED_TEST_SKIP: "true"

When to Quarantine

SituationQuarantine?
Flaky test blocks every deploymentYes
External service is temporarily downYes
Urgent release needed, will fix tomorrowYes
Test is slow but always passesNo, optimize it
Test fails consistently on all runsNo, fix the bug

How Quarantine Works

Original ResultWith QuarantinePipeline Impact
FAILPASS (ignored)Does not block
PASSPASSNo change
SKIPSKIPNo change

The test still executes, you'll see if it passes or fails—but failures are ignored for pipeline status.

Quarantine a Test

hcli test-management quarantine set \
--account-id="$HARNESS_ACCOUNT_ID" \
--repo="https://github.com/your-org/your-repo.git" \
--api-key="$HARNESS_API_KEY" \
--class-name="com.example.PaymentTest" \
--test-name="testRefundTimeout" \
--marking=true

View Quarantined Tests

hcli test-management quarantine get \
--account-id="$HARNESS_ACCOUNT_ID" \
--org-id="$HARNESS_ORG_ID" \
--project-id="$HARNESS_PROJECT_ID" \
--repo="https://github.com/your-org/your-repo.git" \
--api-key="$HARNESS_API_KEY" \

Example output:

Found 6 quarantined test(s):
- com.taskmanager.FlakyTest::flakyTest1
- com.taskmanager.FlakyTest::Flaky Test 2: Timing sensitive
- com.taskmanager.FlakyTest::Flaky Test 3: Random number comparison
- com.taskmanager.service.WorkItemServiceTest::Flaky test that randomly fails
Page 1 of 1 (total: 6 tests)

Remove from Quarantine

After fixing the test:

hcli test-management quarantine set \
--account-id="$HARNESS_ACCOUNT_ID" \
--repo="https://github.com/your-org/your-repo.git" \
--api-key="$HARNESS_API_KEY" \
--class-name="com.example.PaymentTest" \
--test-name="testRefundTimeout" \
--marking=false

Automate with Policies

Instead of manually quarantining tests, use policies to automate:

[
{
"when": ["test failed"],
"action": ["mark quarantine"]
}
]

This automatically quarantines any test that fails in the current pipeline execution.

Best Practices

PracticeWhy
Create a tracking issueEvery quarantined test needs an owner
Set a deadlineQuarantine should be temporary (7 days max)
Review weeklyPrevent accumulation of quarantined tests
Fix the root causeDon't just quarantine—investigate and fix

Next Steps