3
votes

Is there a way to run a keyword on Suite Teardown only if Suite Setup fails?

Using "Run Keyword If Any Tests Failed" will run the keyword if the Suite Setup fails, but it will also run if any other test fail. I did not managed to make it run only in case of a Suite Setup failure.

I also tried to read the automatic variables, but I did not succeed here too.

2

2 Answers

4
votes

The easy way to do it is with Set Global Variable. Always initialize the global variable to "fail", then as the last keyword of your Suite Setup, set it to "pass". If you want to skip something if the setup fails, skip it with Run Keyword If '${SETUP}'=='pass' right before the keyword.

3
votes

There is nothing built-in to handle this. A simple solution is to set a flag at the end of your suite setup, then check for the flag in the suite teardown. If the flag isn't set, then the suite setup failed and you can skip the rest of the teardown.