Skip to main content
🚀 See how 20+ AI Agents can make your QA faster and smarter. Join 10k+ QAs at global leadership summit! Register Now
No Result Found
Connect & Get help from fellow developers on our Discord community. Ask the CommunityAsk the Community

Automatically rerun failed Espresso tests on App Automate

Flaky tests slowing you down? Automatically retry failed Espresso suites on BrowserStack App Automate to get more reliable build results and save time.

Flaky tests cause intermittent failures and pipeline delays by forcing manual retries.

BrowserStack’s App Automate solves this by automatically rerunning failed Espresso tests, which distinguishes real bugs from transient issues to improve build reliability, reduce manual effort, and accelerate CI/CD pipelines.

Benefits of rerunning failed tests

Enabling automatic reruns for your Espresso test suites on App Automate provides the following key advantages:

  • Identify flaky tests and improve feedback reliability: Automatically rerunning a failed test helps confirm if a failure is persistent (a real bug) or intermittent (a flaky test). This reduces the noise from transient failures, allowing your team to act on real issues faster.

  • Improve build stability: By successfully rerunning tests that failed due to temporary issues (like network glitches), you can prevent your entire CI/CD pipeline from being marked as “failed” unnecessarily.

  • Reduce manual effort and save time: Eliminates the need for developers and QA engineers to manually investigate and re-trigger builds, allowing them to focus on writing code and finding critical bugs.

Enable reruns using REST API

You can enable the automatic rerun capability by passing the following parameters in your test execution API call:

Parameter Type Required/Optional Description Default
retryTestsOnFailure Boolean Required Set to true to enable the automatic rerun feature for failed test cases. N/A
testIterations Integer Optional The maximum number of retry attempts for a single failed test. The reruns will stop as soon as the test passes. 5
runWholeSession Boolean Optional Set to true to rerun the entire test session if any test case fails. This is useful for test suites where tests are dependent on each other. false

Rerun only the failed test cases

This is the most common scenario, where you want to retry only the specific tests that fail to overcome flakiness. The build will continue to execute other tests, and only the ones that fail will be added to the rerun queue.

To configure this, set retryTestsOnFailure to true. You can optionally specify testIterations to control the number of retries.

Use the following cURL request:

Terminal
Copy icon Copy

Rerun the entire session on any failure

This capability is designed for tightly coupled test suites where the success of one test depends on the state set by a previous one. If any test fails, the entire session is aborted and re-executed from the beginning. This ensures that test dependencies are respected in every retry attempt.

To configure this, set both retryTestsOnFailure and runWholeSession to true.

Use the following cURL request:

Terminal
Copy icon Copy

View rerun results

After your build completes, go to the App Automate dashboard to view all test executions, including any retries.

Tests that were retried are marked with a label indicating the number of attempts (e.g., “3 attempts”).

You can expand the test result to view the logs and metadata for each individual attempt, making it easy to debug why a test failed initially before passing.

The final status of the test (and the build) reflects the outcome of the last attempt.

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

Is this page helping you?

Yes
No

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!

Talk to an Expert
Download Copy Check Circle