Stop XCUITest builds automatically with fail fast
Automatically stop an XCUITest build on App Automate after a specified number of tests fail, so you save device time and get results faster.
Continuing a test run after a known failure wastes limited device farm capacity. Fail fast aborts the build as soon as a specified failure threshold is reached, returning results faster and freeing up hardware for other queued jobs.
Enable fail fast
To enable fail fast, add testOrchestrationOptions.abortBuildOnFailure to your builds REST API request. Set enabled to true and maxFailures to the number of failed tests that stops the build.
Use the following cURL request:
Replace YOUR_USERNAME and YOUR_ACCESS_KEY with your BrowserStack credentials, and the bs:// IDs with the app and test suite IDs returned when you uploaded them.
Keep the following in mind:
-
maxFailuresaccepts an integer from1to1000. - Setting
enabledtotruewithoutmaxFailuresfails validation.
Fail fast is not supported when singleRunnerInvocation is set to true:
- All test cases run together in a single process, so there is no boundary between individual tests for BrowserStack to stop at.
- If you set both parameters together, your build request fails validation and returns an error.
- To use fail fast, keep
singleRunnerInvocationset tofalse, which is the default.
For more information, see Single runner invocation.
How failures are counted
Fail fast counts a test as failed only after all its retries are exhausted.
XCUITest resolves test retries inline during the active test execution. Fail fast evaluates failures immediately upon final invocation, eliminating any pending state or secondary retry queue.
You can combine fail fast with automatic reruns. Fail fast only counts a test as failed once its retries are exhausted.
What happens when a build stops
Reaching the fail-fast threshold triggers a coordinated shutdown across running tests and the dashboard. The following sections describe each part of that process.
Build termination behavior
Reaching a fail-fast threshold halts suite execution gracefully at the next test boundary. Active test invocations complete their execution cycle, and the system never terminates a running test mid-flight.
Queue and state handling
When a build halts, the runner cleans up active execution slots and updates pending job statuses across the pipeline:
-
Active invocations: Run to completion before the suite halts.
-
Unexecuted tests: Marked as skipped rather than failed to preserve accurate failure ratios.
Dashboard reporting
The execution dashboard flags the run as automatically terminated due to failure threshold limits. This distinguishes automated fail-fast cancellations from manual developer interventions in your build telemetry and audit logs.
Related topics
-
Use run failures only to start a new build that reruns only the tests that failed in a previous, completed build, instead of a build you stopped with fail fast.
-
See Test orchestration on XCUITest for all supported strategies.
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!