Re: How to use Run Keyword if Test Failed/Passed in a TestCase TearDown?

12,068 views
Skip to first unread message

Mika Hänninen

unread,
Apr 23, 2013, 10:24:13 AM4/23/13
to els...@gmail.com, robotframework-users
This should work...

*** Settings ***
Test TearDown   Custom Teardown

*** Test Cases ***
Test case 1
    Log   Hola

*** Keywords ***
Custom Teardown
    Log   First
    Log   Second


Best Regards,
Mika


On Tue, Apr 23, 2013 at 12:13 PM, Elsvent Hong <els...@gmail.com> wrote:
Hi 

I would like to use Run Keyword if Test Failed and Passed in test case tear down. I set Test TearDown in Settings, but looks like Test TearDown does not allow multiple lines. Does anyone know if there is a workaround for this?

*** Settings ***

Test TearDown   Run Keyword If Test Failed   Open Issue
Test TearDown   Run Keyword If Test Passed   Close Issue

Elsvent

--
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 http://groups.google.com/group/robotframework-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Elsvent Hong

unread,
Apr 24, 2013, 8:21:58 AM4/24/13
to robotframe...@googlegroups.com, els...@gmail.com
Hi Mika,

Firstly, Thanks for your reply. 

I am sorry about my question not clarity. 

I need to use "Run Keyword If Test Failed" function(while I found test failed I can trigger something to action) and "Run Keyword If Test Passed"(While Test Pass, I can document the result to another place)

However if I just run a keyword to trigger other function there is no if else condition check for test pass/fail. That why I want to use Run Keyword If Test Failed/Passed in same test teardown.

or

Is there any variable that can indicate test failed or pass that I can use in teardown keyword?

Thanks,
Elsvent

On Tuesday, April 23, 2013 6:24:13 PM UTC+8, Mika Hänninen wrote:
This should work...

*** Settings ***
Test TearDown   Custom Teardown

*** Test Cases ***
Test case 1
    Log   Hola

*** Keywords ***
Custom Teardown
    Log   First
    Log   Second


Best Regards,
Mika
On Tue, Apr 23, 2013 at 12:13 PM, Elsvent Hong <els...@gmail.com> wrote:
Hi 

I would like to use Run Keyword if Test Failed and Passed in test case tear down. I set Test TearDown in Settings, but looks like Test TearDown does not allow multiple lines. Does anyone know if there is a workaround for this?

*** Settings ***

Test TearDown   Run Keyword If Test Failed   Open Issue
Test TearDown   Run Keyword If Test Passed   Close Issue

Elsvent

--
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-users+unsub...@googlegroups.com.

Mika Hänninen

unread,
Apr 24, 2013, 8:46:16 AM4/24/13
to Hung Yi-Che, robotframework-users
Hi,

I left my example too generic. If you try the example below, it Logs 'Test failed" in the test teardown and then comment out/remove "Fail  failing" row from the "Test case 1" then it will Log "Test passed" in the test teardown.

*** Settings ***
Test TearDown   Custom Teardown


*** Test Cases ***
Test case 1
    Log   Hola
    Fail  failing

*** Keywords ***
Custom Teardown
    Run Keyword If Test Failed   Log   Test failed
    Run Keyword If Test Passed   Log   Test passed

BR,
Mika


To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.

Elsvent Hong

unread,
Apr 24, 2013, 9:25:00 AM4/24/13
to robotframe...@googlegroups.com, Hung Yi-Che
It's work. Thanks a lot Mika
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsubscrib...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.

Ganesh Kumbhar

unread,
Nov 11, 2014, 5:44:28 AM11/11/14
to robotframe...@googlegroups.com, els...@gmail.com
HI

How can we call Run Keyword If Test Failed/passed for different test cases 

i.e. suppose test_case 1 &2 get failed and i want different fail message for 1 and 2 

so How can we achieve that  .. 

Tatu Aalto

unread,
Nov 11, 2014, 6:32:09 AM11/11/14
to Ganesh Kumbhar, els...@gmail.com, robotframework-users

Ugh

Just like in Mika's example but provide the desired message as an argument [1] to the Custom Keyword.

-Tatu
Send from my mobile
[1] http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#user-keyword-arguments

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.

aditi...@gmail.com

unread,
Aug 25, 2015, 5:34:04 AM8/25/15
to robotframework-users, els...@gmail.com
hi, I am new to RIDE, I want to log test fail and pass after every case to an excel.Can anyone please explain the complete flow of how to achieve it.How can I use Test Case Teardown
How can I use Run Keyword if all Test Fail and Run Keyword if any Test Fail 
Reply all
Reply to author
Forward
Message has been deleted
0 new messages