# Rerun tests if they fail to avoid false positives

**URL:** <https://discuss.circleci.com/t/rerun-tests-if-they-fail-to-avoid-false-positives/1348>\
**Category:** Build Environment\
**Tags:** circle-yml\
**Created:** [January 4, 2016, 11:16pm UTC](https://discuss.circleci.com/t/rerun-tests-if-they-fail-to-avoid-false-positives/1348 "2016-01-04T23:16:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattrobbins](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/mattrobbins/32/919_2.png) [@mattrobbins](https://discuss.circleci.com/u/mattrobbins)\
**Post date:** [January 4, 2016, 11:16pm UTC](https://discuss.circleci.com/t/rerun-tests-if-they-fail-to-avoid-false-positives/1348/1 "2016-01-04T23:16:43Z")

</div>

I was wondering if there is a way to rerun the tests if the tests if they fail? We want to avoid any false positives. In our build environment we have a circle.yml file where we override the test run. Our acceptance tests are built in a rspec, capybara framework. We want to be able to rerun the tests x number of times before it actually reports them as being failed. Does anyone know how to do this in circleci?

---

<div class="post-metadata">

**Author:** ![patocallaghan](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/patocallaghan/32/1245_2.png) [@patocallaghan](https://discuss.circleci.com/u/patocallaghan)\
**Post date:** [November 10, 2016, 10:03am UTC](https://discuss.circleci.com/t/rerun-tests-if-they-fail-to-avoid-false-positives/1348/2 "2016-11-10T10:03:09Z")

</div>

@mattrobbins did you manage to come up with a strategy for this? This is something we are also trying to do.

---

<div class="post-metadata">

**Author:** ![mattrobbins](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/mattrobbins/32/919_2.png) [@mattrobbins](https://discuss.circleci.com/u/mattrobbins)\
**Post date:** [November 10, 2016, 3:44pm UTC](https://discuss.circleci.com/t/rerun-tests-if-they-fail-to-avoid-false-positives/1348/3 "2016-11-10T15:44:01Z")

</div>

Yes I did. We ended up using the gem rspec-retry and configured it the way we wanted it to work. [https://rubygems.org/gems/rspec-retry](https://rubygems.org/gems/rspec-retry).

Hopefully that will help you.  
-Matt

---

<div class="post-metadata">

**Author:** ![patocallaghan](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/patocallaghan/32/1245_2.png) [@patocallaghan](https://discuss.circleci.com/u/patocallaghan)\
**Post date:** [November 10, 2016, 10:07pm UTC](https://discuss.circleci.com/t/rerun-tests-if-they-fail-to-avoid-false-positives/1348/4 "2016-11-10T22:07:33Z")

</div>

Unfortunately in our case it’s a suite of JS tests but some similar functionality is definitely what we need. Thanks for letting me know!

---

<div class="post-metadata">

**Author:** ![jerefrer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/jerefrer/32/13637_2.png) [@jerefrer](https://discuss.circleci.com/u/jerefrer)\
**Post date:** [December 16, 2016, 8:58am UTC](https://discuss.circleci.com/t/rerun-tests-if-they-fail-to-avoid-false-positives/1348/5 "2016-12-16T08:58:29Z")

</div>

I tried this gem a while ago but somehow got confused about how to configure it properly and then let that slide and never looked back.

Could you please share how you are using it so that I might reconsider ?  
I’m really bored of having to look at the CircleCI failures and guess if they failed randomly or not.

Thanks !

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [June 18, 2018, 11:37am UTC](https://discuss.circleci.com/t/rerun-tests-if-they-fail-to-avoid-false-positives/1348/6 "2018-06-18T11:37:52Z")

</div>


