Xcode Flaky Tests
Xcode flaky tests {#xcode-flaky-tests}
Section titled “Xcode flaky tests {#xcode-flaky-tests}”::: warning REQUIREMENTS
Test Insights must be configured
:::
Flaky tests are tests that produce different results (pass or fail) when run multiple times with the same code. They erode trust in your test suite and waste developer time investigating false failures. Tuist automatically detects flaky tests and helps you track them over time.

How flaky detection works {#how-it-works}
Section titled “How flaky detection works {#how-it-works}”Tuist detects flaky tests in two ways:
Test retries {#test-retries}
Section titled “Test retries {#test-retries}”When you run tests with retry functionality, Tuist analyzes the results of each attempt. If a test fails on some attempts but passes on others, it’s marked as flaky.
Use -retry-tests-on-failure or -test-iterations:
tuist xcodebuild test \ -scheme MyScheme \ -retry-tests-on-failure \ -test-iterations 3
Cross-run detection {#cross-run-detection}
Section titled “Cross-run detection {#cross-run-detection}”Even without test retries, Tuist can detect flaky tests by comparing results across different CI runs on the same commit. If a test passes in one CI run but fails in another run for the same commit, both runs are marked as flaky.
This is particularly useful for catching flaky tests that don’t fail consistently enough to be caught by retries, but still cause intermittent CI failures.
Managing flaky tests {#managing-flaky-tests}
Section titled “Managing flaky tests {#managing-flaky-tests}”Automatic clearing
Section titled “Automatic clearing”Tuist automatically clears the flaky flag from tests that haven’t been flaky for 14 days. This ensures that tests that have been fixed don’t remain marked as flaky indefinitely.
Manual management
Section titled “Manual management”You can also manually mark or unmark tests as flaky from the test case detail page. This is useful when:
- You want to acknowledge a known flaky test while working on a fix
- A test was incorrectly flagged due to infrastructure issues
Quarantining flaky tests {#quarantining}
Section titled “Quarantining flaky tests {#quarantining}”Quarantining allows you to isolate flaky tests so they don’t block your CI pipeline while you work on fixing them. Quarantined tests can be skipped during test runs, preventing false failures from disrupting your team’s workflow.
[!IMPORTANT] Unless you’re using
tuist test, quarantining a test does not automatically skip it. You must explicitly pass the list of quarantined tests to xcodebuild using the-skip-testingflag.
Automatic quarantine
Section titled “Automatic quarantine”When enabled in your project’s Automations settings, tests are automatically quarantined when they’re marked as flaky. This ensures that newly detected flaky tests are immediately isolated without manual intervention.
To enable automatic quarantine:
- Go to your project settings
- Navigate to the Automations tab
- Enable Auto-quarantine flaky tests
Manual quarantine
Section titled “Manual quarantine”You can also manually quarantine or unquarantine tests from the test case detail page using the Quarantine and Unquarantine buttons. This is useful when:
- You want to quarantine a test before it’s automatically detected as flaky
- You want to unquarantine a test after fixing the underlying issue
Skipping quarantined tests {#skipping-quarantined-tests}
Section titled “Skipping quarantined tests {#skipping-quarantined-tests}”With tuist test
Section titled “With tuist test”When you run tuist test, quarantined tests are automatically skipped. Tuist fetches the list of quarantined tests from the server and passes them to xcodebuild using the -skip-testing flag.
tuist testIf you want to run all tests including quarantined ones, use the --skip-quarantine flag:
tuist test --skip-quarantineWith xcodebuild directly
Section titled “With xcodebuild directly”If you’re using xcodebuild directly instead of tuist test, use the tuist test case list command with the --skip-testing flag to get quarantined test identifiers formatted for xcodebuild:
xcodebuild test \ -scheme MyScheme \ $(tuist test case list --skip-testing)Slack notifications {#slack-notifications}
Section titled “Slack notifications {#slack-notifications}”Get notified instantly when a test becomes flaky by setting up