Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 1266 by [email protected]: "Run keyword and continue on failure" changes the return value of the calling keyword to NULL
http://code.google.com/p/robotframework/issues/detail?id=1266

Example:

*** Test Cases ***
Test case 1
    ${x}=    My keyword
    Log    ${x}  <--------- This is always NULL instead of "Hello there"

*** Keywords ***
My keyword
    Run Keyword And Continue On Failure    Fail
    ${output}=    Set Variable    Hello there
    [Return]    ${output}



Let me explain how I found this problem and why I think this should not be the default behaviour.

I have a keyword which does several things. One of them is trying to stop a remote server which might fail for a number of non critical reasons. Because of this, I decided to wrap this particular action in a "Run keyword and continue on failure" keyword. This is because when this happens I want the test to appear as FAILED but continue execution nevertheless. However, due to the "problem" being reported here, when the remote server operation actually fails, the outer keyword returns NULL and the test case eventually fails when some other keyword tries to access the contents of the returned value (which is now "NULL") which should contain data objects needed for other critical operation.

One possible workaround would be to use "Run Keyword And Ignore Error" instead, keep track of the returned value from this keyword (either "PASS" or "FAIL") and later make use of it to "manually" mark the current test case as FAIL... but this solution requires keeping track of that returned value through the nested functions back to the test case entry level.

On the other hand, if "Run Keyword And Continue On Failure" would not change the return value of the calling keyword, none of this would be needed and the resulting test case structure would be much cleaner.


Reply via email to