Getting Pass/Fail result after RF execution

Hi. I have a need to post the RF script run result (Pass/Fail) on the SUT on an issue tracking forum. Obviously once the RF script has finished running its got no way of posting the result (and I can’t post the result until its finished!). So I have written a pretty shameful script that looks at the RF report generated then logs into the forum and posts the result, but how to get around the problem of triggering this “post to forum” script when the RF execution has finished. (the holy grail would be to post the test report at the same time but one thing at a time!)

Just wondered if I’m missing anything obvious.
(the system runs on an intranet there is no access to the web).

Many thanks

you can access ${TEST STATUS} in Teardown
http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#automatic-variables

Variable Explanation Available
${TEST STATUS} The status of the current test case, either PASS or FAIL. Test teardown
${TEST MESSAGE} The message of the current test case. Test teardown
${SUITE STATUS} The status of the current test suite, either PASS or FAIL. Suite teardown
${SUITE MESSAGE} The full message of the current test suite, including statistics. Suite teardown
1 Like

Hi Brendan,

As always is the case in IT, there are many options and no right or wrong way, it’s really a matter of what works best for you.

Options you have (in order mentioned):

  1. parse the robot results files (like you are doing) this is actually how I started with RFSwarm too. are you parsing the log.html or the output.xml file, the xml file is easier as you can use xml libraries to convert the xml to a dictionary that is easy to iterate.
    [Pro: can use any programming language you like / Con: need to wait till after execution then run a seperate process]

  2. As @ericbjones mentioned you can create a keyword and call it as a teardown
    [Pro: same robot keywords as your test case so no need to learn anything new]

  3. Use robot framework’s listener api to report results as they happen (this is what RFSwarm uses now)
    [Pro: transparent to your test cases, so can be controlled at runtime if enabled or not, also can post passes to your issue tracker while next test continues to run / Con: need to write listeners in python or java]

There may also be other options but those are the ones I know.

Don’t be ashamed, any script that works for you is better than repetitively doing manual steps and everyone needs to start somewhere and practical exercises like this are a great way to learn programming.

Dave.

1 Like

Thank you, but I’m still confused about how I pass the ${TEST STATUS} variable to another test case like in the example below

*** Test Cases ***

TC1-STARTUP
[Documentation] Open Browser
[Tags] TESTRESULT
Go to MyApp

[Teardown]    ${TEST STATUS}

TC2-TESTRESULT
[Documentation] Post Test Result
[Tags] TESTRESULT
Post Test Result ${TEST STATUS}

[Teardown]    Close All Browsers

Hi Brendan,

try it like this then it might make more sense

*** Test Cases ***
TC1-STARTUP
    [Documentation] Open Browser
    [Tags] open app
    Go to MyApp
    [Teardown]    My Teardown

TC2-TESTRESULT
    [Documentation] clicks a link
    [Tags] hyperlinks
    Click Element    my link
    [Teardown]    My Teardown

TC3-TESTRESULT
    [Documentation] clicks another link
    [Tags] hyperlinks
    Click Element    my other link
    [Teardown]    My Teardown

*** Keywords ***
My Teardown
    Log    ${TEST STATUS}
    Run Keyword if    '${TEST STATUS}' == 'FAIL'    Close All Browsers

Hope that helps,

Dave.

1 Like

Thanks for your help everyone, it was taking me ages to work this out I really appreciate your help.