# Fail whole test suite if a test case fails without affecting following test suites

**URL:** <https://forum.robotframework.org/t/fail-whole-test-suite-if-a-test-case-fails-without-affecting-following-test-suites/5363>\
**Category:** Robot Framework\
**Created:** [27 February 2023 11:42 UTC](https://forum.robotframework.org/t/fail-whole-test-suite-if-a-test-case-fails-without-affecting-following-test-suites/5363 "2023-02-27T11:42:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hyytiainen](https://avatars.discourse-cdn.com/v4/letter/h/ecd19e/32.png) [@hyytiainen](https://forum.robotframework.org/u/hyytiainen)\
**Post date:** [27 February 2023 11:42 UTC](https://forum.robotframework.org/t/fail-whole-test-suite-if-a-test-case-fails-without-affecting-following-test-suites/5363/1 "2023-02-27T11:42:10Z")

</div>

Hello,

I run tens of test suites each containing several test cases in a row. If a test case in a test suite fails I need to fail or skip all the remaining test cases in that test suite without affecting following test suites.

I am planning to use Test Setup to fail or skip the testcase if any previous test has failed by checking a suite variable which is set in Test Teardown if the testcase failed.  
I’m just wondering if there is a better way to do this?

Br,  
Sami

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [27 February 2023 14:00 UTC](https://forum.robotframework.org/t/fail-whole-test-suite-if-a-test-case-fails-without-affecting-following-test-suites/5363/2 "2023-02-27T14:00:40Z")

</div>

Hi Sami,

1. Not sure if this will help, you could try [Fatal Error](https://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Fatal%20Error)  
It says: _“The test or suite where this keyword is used fails with the provided message”_  
but it also says: _“Stops the whole test execution.”_  
It seems like you want something in between [Fail](https://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Fail) and [Fatal Error](https://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Fatal%20Error)

1. my other suggestion would be to use [Set Suite Variable](https://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Set%20Suite%20Variable).  
set a variable to false in the ` ***Variables*** ` section  
in the test that the others depend on set it to true as the last line  
in the other tests after this important one check if the variable is true before continuing  
if it’s not one specific test but they all need to pass sequentially (I don’t remember where it is in the documentation, but it’s recommended that test cases shouldn’t be dependent on each other) you could set it to false when a test starts and back to true as the last step in the test, alternatively you could use a [Test teardown](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#toc-entry-274) to set it to false

Hopefully something in that is helpful,

Dave.

---

<div class="post-metadata">

**Author:** ![hyytiainen](https://avatars.discourse-cdn.com/v4/letter/h/ecd19e/32.png) [@hyytiainen](https://forum.robotframework.org/u/hyytiainen)\
**Post date:** [28 February 2023 06:51 UTC](https://forum.robotframework.org/t/fail-whole-test-suite-if-a-test-case-fails-without-affecting-following-test-suites/5363/3 "2023-02-28T06:51:55Z")

</div>

Hi Dave,

Thank you for your response.  
You’re right. Based on my experiments Fatal Error terminates the whole test execution i.e. all the following test suites will fail also. Fail keyword causes only the current test case to fail. So something between them would be perfect in my case.

I know that tests should not be dependent on each other but in my case (embedded system testing) test cases would be very big and complicated. That’s why I prefer to use test cases which sometimes are dependent on each other in a same test suite.  
I will continue with suite variable based solution.

Br,  
Sami

---

<div class="post-metadata">

**Author:** ![mimocha](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/mimocha/32/3819_2.png) [@mimocha](https://forum.robotframework.org/u/mimocha)\
**Post date:** [3 May 2024 06:56 UTC](https://forum.robotframework.org/t/fail-whole-test-suite-if-a-test-case-fails-without-affecting-following-test-suites/5363/4 "2024-05-03T06:56:48Z")

</div>

A little bit late to the conversation, but I wanted to share my own solution.

I also have dozens of test suites to run, where I want to skip the suite if there are any failures, but continue with the remaining test suites. I also wanted the results of all suites conveniently in a single report.  
Using `robot --exitonfailure` command will skip the current test suite when a failure occurs (good), but also skip any remaining test suite after the current test (bad).

**My solution is to write a simple bash or python script executing each suite independently with the `--exitonfailure` option, then combining all results into a single report with `rebot`.**

Something like this in bash (`run.sh`):

```bash
#!/usr/bin/env bash
robot -d results/subdir_01 --exitonfailure test_suites/my_suite_01
robot -d results/subdir_02 --exitonfailure test_suites/my_suite_02
robot -d results/subdir_03 --exitonfailure test_suites/my_suite_03
robot -d results/subdir_04 --exitonfailure test_suites/my_suite_04
robot -d results/subdir_05 --exitonfailure test_suites/my_suite_05
rebot --outputdir results results/*/*.xml

```

Then in terminal,  
`> ./run.sh`

Or something like this in Python (`run.py`):

```python
import os

commands = [
   "robot -d results/subdir_01 --exitonfailure test_suites/my_suite_01"
  ,"robot -d results/subdir_02 --exitonfailure test_suites/my_suite_02"
  ,"robot -d results/subdir_03 --exitonfailure test_suites/my_suite_03"
  ,"robot -d results/subdir_04 --exitonfailure test_suites/my_suite_04"
  ,"robot -d results/subdir_05 --exitonfailure test_suites/my_suite_05"
  ,"rebot --outputdir results results/*/*.xml"
]

if __name__ == ' __main__':
  for line in commands:
    os.system(line)

```

Again, in terminal:  
`> python run.py`
