Quarantined tests are tests that are flaky or known to have issues but are not yet fixed. They are marked with the [QuarantinedTest] attribute and are excluded from regular CI runs to prevent false negatives.
The QuarantinedTestAttribute applies the xUnit trait quarantined=true to tests. This trait can then be used with test filters to include or exclude these tests.
To run tests excluding quarantined tests (this is what CI does):
dotnet test --filter-not-trait "quarantined=true"Or using the direct test runner:
dotnet exec YourTestAssembly.dll --filter-not-trait "quarantined=true"To run only quarantined tests (useful for debugging):
dotnet test --filter-trait "quarantined=true"Or using the direct test runner:
dotnet exec YourTestAssembly.dll --filter-trait "quarantined=true"- Mark as Quarantined: When a test is consistently flaky, mark it with
[QuarantinedTest("reason")] - Quarantined Execution: Quarantined tests run automatically in the quarantine CI (every 6 hours)
- Fix the Issue: Investigate and fix the underlying issue causing the flakiness
- Remove Quarantine: Once fixed and stable, remove the
[QuarantinedTest]attribute
[Fact]
[QuarantinedTest("https://github.com/dotnet/aspire/issues/7920")]
public async Task FlakyTest()
{
// Test implementation
}- Regular CI: Uses
--filter-not-trait "quarantined=true"to exclude quarantined tests - Quarantine CI on Schedule/Push: Runs all quarantined tests twice daily (02:00 and 14:00 UTC) to monitor their status
- Quarantine CI on Pull Requests: Runs only the first quarantined test project across all OSes (Windows, Linux, macOS) as a sanity check when PRs modify workflow/infrastructure files
- Results: Quarantined test failures don't block PR merges but are tracked for fixes
When running tests in automated environments like Copilot agent, always use the quarantine filter to avoid false negatives:
# Good - excludes quarantined tests
dotnet test --filter-not-trait "quarantined=true"
# Bad - runs all tests including quarantined ones
dotnet test