# Rerun failed tests first on subsequent git commit on PR branch

**URL:** <https://discuss.circleci.com/t/rerun-failed-tests-first-on-subsequent-git-commit-on-pr-branch/40528>\
**Category:** Build Environment\
**Created:** [July 2, 2021, 8:59pm UTC](https://discuss.circleci.com/t/rerun-failed-tests-first-on-subsequent-git-commit-on-pr-branch/40528 "2021-07-02T20:59:08Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![pw60462](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/pw60462/32/27721_2.png) [@pw60462](https://discuss.circleci.com/u/pw60462)\
**Post date:** [July 2, 2021, 8:59pm UTC](https://discuss.circleci.com/t/rerun-failed-tests-first-on-subsequent-git-commit-on-pr-branch/40528/1 "2021-07-02T20:59:08Z")

</div>

Hi, we use Rails/Cucumber/RSpec, and run CircleCI on pull request branches. Our full test suite takes about 25 minutes to run on CircleCI.

If we have a few failing tests, we then do a subsequent git commit, it would be great if the first set of test that get run are the ones that failed last time. Then, if these fail, it stops, and if they pass, it then goes on to run the full suite.

That way we could avoid waiting 25 minutes only to find the same tests failed again.

Anyone know if CircleCi can do this already?

Thanks!

---

<div class="post-metadata">

**Author:** ![thekatertot](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/thekatertot/32/25169_2.png) [@thekatertot](https://discuss.circleci.com/u/thekatertot)\
**Post date:** [July 12, 2021, 11:28pm UTC](https://discuss.circleci.com/t/rerun-failed-tests-first-on-subsequent-git-commit-on-pr-branch/40528/2 "2021-07-12T23:28:14Z")

</div>

This is an interesting question - I’m going to ask around and see if anyone knows how to do this!

---

<div class="post-metadata">

**Author:** ![pw60462](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/pw60462/32/27721_2.png) [@pw60462](https://discuss.circleci.com/u/pw60462)\
**Post date:** [August 2, 2021, 11:08am UTC](https://discuss.circleci.com/t/rerun-failed-tests-first-on-subsequent-git-commit-on-pr-branch/40528/3 "2021-08-02T11:08:02Z")

</div>

Hi @thekatertot did you get any ideas on this?

---

<div class="post-metadata">

**Author:** ![thekatertot](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/thekatertot/32/25169_2.png) [@thekatertot](https://discuss.circleci.com/u/thekatertot)\
**Post date:** [August 2, 2021, 6:27pm UTC](https://discuss.circleci.com/t/rerun-failed-tests-first-on-subsequent-git-commit-on-pr-branch/40528/4 "2021-08-02T18:27:48Z")

</div>

Hi @pw60462! Thanks for your patience. I think the best solution is `rerun from failed`, which should cut down your build time by not repeated the passed tests. [Here’s a short article on where to find it in the UI](https://support.circleci.com/hc/en-us/articles/360050303671-How-to-rerun-a-workflow). If it doesn’t work for you, let me know!

---

<div class="post-metadata">

**Author:** ![dolan](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/dolan/32/32562_2.png) [@dolan](https://discuss.circleci.com/u/dolan)\
**Post date:** [March 8, 2023, 11:17pm UTC](https://discuss.circleci.com/t/rerun-failed-tests-first-on-subsequent-git-commit-on-pr-branch/40528/5 "2023-03-08T23:17:05Z")

</div>

That reruns an entire failed step. Usually all the specs are in one step, so I suppose people could split it up. I’m not familiar enough to know if that would impair it’s ability to parallelize the specs itself or not. I’m also interested in figuring out how we might be able to do this, because it would save a lot of time and CPU credits.

---

<div class="post-metadata">

**Author:** ![wyardley](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/wyardley/32/19231_2.png) [@wyardley](https://discuss.circleci.com/u/wyardley)\
**Post date:** [March 9, 2023, 11:26pm UTC](https://discuss.circleci.com/t/rerun-failed-tests-first-on-subsequent-git-commit-on-pr-branch/40528/6 "2023-03-09T23:26:24Z")

</div>

I saw a banner at the top in the web UI which I believe was saying there’s a new feature being tested that, is supposed to be able to do that. There was a Google form for signup.

---

<div class="post-metadata">

**Author:** ![mallison](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/mallison/32/36007_2.png) [@mallison](https://discuss.circleci.com/u/mallison)\
**Post date:** [January 24, 2025, 2:07pm UTC](https://discuss.circleci.com/t/rerun-failed-tests-first-on-subsequent-git-commit-on-pr-branch/40528/7 "2025-01-24T14:07:38Z")

</div>

Is what the OP asked possible yet? We have a Cypress test suite that takes ~25 to run. If some tests fail and I fix the cause of the failure and push changes, it’d be great if the tests that failed previously could be run first.

Note, this is not the same as “rerun from failed” which is for re-running the _current_ workflow for flaky tests. I’d like the _next_ run to start by running the failing tests first.

If splitting tests by time is possible then it should be possible to retain information on the failed tests so they can be run first the next time.

---

<div class="post-metadata">

**Author:** ![sebastian-lerner](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/sebastian-lerner/32/27833_2.png) [@sebastian-lerner](https://discuss.circleci.com/u/sebastian-lerner)\
**Post date:** [January 24, 2025, 7:06pm UTC](https://discuss.circleci.com/t/rerun-failed-tests-first-on-subsequent-git-commit-on-pr-branch/40528/8 "2025-01-24T19:06:53Z")

</div>

@mallison there is not a feature to run the failed tests first on the next run. There is a feature that reruns only the failed tests when you have flaky tests. But like you called out, this is on the same run, not after youve made a fix and started a new run

[https://circleci.com/docs/rerun-failed-tests-only/](https://circleci.com/docs/rerun-failed-tests-only/)
