Turn off "continue on failure" mode for a test teardown

450 views
Skip to first unread message

Joseph Lorenzini

unread,
Dec 27, 2015, 11:34:26 AM12/27/15
to robotframework-users

Hi all,


So here's what the user guide says about teardowns when a keyword fails.


"Execution continues on teardowns automatically

To make it sure that all the cleanup activities are taken care of, the continue on failure mode is automatically on in test and suite teardowns. In practice this means that in teardowns all the keywords in all levels are always executed."


So here's the thing, in the case of some keywords, I do NOT want the remaining teardown keywords executed. I just want the entire test case marked as failed and the teardown to stop. I know I could achieve the same result by adding  "Run Keyword If" conditions to each keyword, which checks for a condition prior to running. However, this makes for significantly more verbose code compared to something like this in the teardown:


Keyword 1
Keyword 2
Stop Teardown If Keyword Failed

This made up keyword "Stop Teardown If Keyword Failed" would look at all preceding keywords in the teardown. If any keyword has failed, then the entire test case is marked as a failure, the teardown is marked as a failure, and a failure message is generated that lists the keywords that failed and then lists all the keywords that were NOT subsequently executed. 

I get the sense that I am just asking for a feature request and I may need to submit a PR for this :). But before I do that, I'd like to see if there's anyway to do something like the above. 

Thanks,
Joe 

Pekka Klärck

unread,
Dec 30, 2015, 5:36:20 PM12/30/15
to Joseph Lorenzini, robotframework-users

Hello,

I don't think this is possible currently. It would be useful functionality, so please submit an enhancement request. Probably the best solution would be being able to turn the continue on failure mode on or off per keyword. In addition to making it posssible to turn it off on teardowns, it would allow turning it on elsewhere if needed.

Sent from my mobile.

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

Joseph Lorenzini

unread,
Jan 2, 2016, 2:02:10 PM1/2/16
to Pekka Klärck, robotframework-users
Hi Pekka,

That sounds good. Please see here for my enhancement proposal.


I am definitely interested in submitting a PR for this but please note I'll definitely need to talk one of the core developers in IRC or email with someone to get a basic idea of how and where to modify the code properly. 

Thanks,
Joe 

Pekka Klärck

unread,
Jan 3, 2016, 3:25:33 PM1/3/16
to Joseph Lorenzini, robotframework-users

I noticed the issue and already commented it. I'm afraid this might require too big changes to be doable in 3.0.x minor releases, but we'll know more if this is prototyped. Adding it in 3.1 ought to be possible anyway.

As I commented, using keyword tags like `robot-continue-on-failure` would probably be the best way to control this behavior. Internally the ExecutionContext object should probably be responsible for storing continuability state a bit like it stores timeouts.

We can continue discussion in the comments of the issue and have a chat on IRC or Slack. I won't have much time until Thursday when kindergarten opens it doors after holidays, though.

Sent from my mobile.

Reply all
Reply to author
Forward
0 new messages