# Hi Guys, does anyone know how to run the test again just once if it fails?

**URL:** <https://forum.robotframework.org/t/hi-guys-does-anyone-know-how-to-run-the-test-again-just-once-if-it-fails/4912>\
**Category:** Robot Framework\
**Created:** [7 November 2022 12:38 UTC](https://forum.robotframework.org/t/hi-guys-does-anyone-know-how-to-run-the-test-again-just-once-if-it-fails/4912 "2022-11-07T12:38:56Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Wolfe1](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/wolfe1/32/3386_2.png) [@Wolfe1](https://forum.robotframework.org/u/Wolfe1)\
**Post date:** [7 November 2022 20:14 UTC](https://forum.robotframework.org/t/hi-guys-does-anyone-know-how-to-run-the-test-again-just-once-if-it-fails/4912/2 "2022-11-07T20:14:50Z")

</div>

**Edit: See @René 's [answer below](https://forum.robotframework.org/t/hi-guys-does-anyone-know-how-to-run-the-test-again-just-once-if-it-fails/4912/4) for a newer/better way to do this.**

We do this internally with a bat or sh file:

bat:

```
//Run your robot command:
robot file.robot

//Check if any tests failed, if so we rerun the failures and combine the reports:
IF NOT %ERRORLEVEL%==0 (robot --rerunfailed output.xml --output rerun.xml file.robot & rebot --ProcessEmptySuite --output output.xml --merge output.xml rerun.xml)

```

sh:

```
//Run your robot command:
robot file.robot
//Check if any tests failed, if so we rerun the failures and combine the reports:
if [$? -gt 0]
    then
       robot --rerunfailed output.xml --output rerun.xml file.robot
       rebot --ProcessEmptySuite --output output.xml --merge output.xml rerun.xml
fi

```

---

_[View the full topic](https://forum.robotframework.org/t/hi-guys-does-anyone-know-how-to-run-the-test-again-just-once-if-it-fails/4912)._
