I want to access the ${TEST STATUS}
outside of the Test Teardown
, i.e. I'd like to record the status to a variable and capture the result in a csv.
*** Test Cases ***
Sample Test
[Teardown] ${status}= Set Variable ${TEST_STATUS}
I get the following error when I do this
Teardown failed:
Variable '${status}' not found. Did you mean:
${TEST_STATUS}
Is it not possible to grab the PASS
or FAIL
status outside of Test Teardown
?
The [Teardown]
setting requires a keyword as its first argument. You can't provide a statement that assigns the result of a keyword to a variable. When it sees ${status}=
, it thinks that ${status}=
is a keyword.
If you want to save the variable, you'll have to create a keyword that saves it, and then call that keyword from the teardown. Something like this perhaps:
*** Keywords ***
Save Status
set suite variable ${status} ${TEST_STATUS}
*** Test Cases ***
Sample Test
[Teardown] Save status
Is it not possible to grab the PASS or FAIL status outside of Test Teardown?
No, it is not. The documentation says that ${TEST STATUS}
is only available in a test teardown. This makes logical sense, because before the teardown there is no status, and after the teardown you're in another test or in the suite teardown so robot wouldn't know which test you were wanting the status from.