I have the below code:
*** Settings ***
Library OperatingSystem
Library Process
Library String
*** Variables ***
@{MyList}= item items items2
${LogStr1} *HTML*
*** Test Cases ***
#Start Test#
[xxxxx] My tests
FOR ${item} IN @{MyList}
General test.out testProfile ${item}
[Template] Run Test
[Tags] TestTags
END
*** Keywords ***
Run Test
[Documentation] Run the test
[Arguments] ${type} ${profile} ${file} ${test}
When suite config is updated
And updated the config in directory ${test}
Then publish test status
suite config is updated
[Documentation] Get the variables list
Log to Console "Updating get suite config file"
updated the config in directory ${test}
[Documentation] Get the variables list
Run keyword if "${test}" == "items" Stop Test "This is stop called"
publish test status
[Documentation] Create and check if any issue found
${LogStr}= Catenate Test Passed : Log created: <a href="Hello.txt">Hello</a>
Log to Console ${LogStr}
${LogStr1}= Catenate ${LogStr1} ${LogStr}\n
Set Test Variable ${LogStr1}
Set Test Message ${LogStr1}
Stop Test
[Documentation] Stop Execution
[Arguments] ${FIALUREMSG}
Log To Console ${FIALUREMSG}
${LogStr1}= Catenate ${LogStr1} ${FIALUREMSG}
Fail ${LogStr1}
As per the code the test can be pragmatically made to fail at 1st second or third run. So when I have the code like:
Run keyword if "${test}" == "item" Stop Test "This is stop called"
in mentioned keyword, there are 2 test cases that passes for a suite but report states:
Now if I make the second test case to fail I get below test message logs:
Run keyword if "${test}" == "items" Stop Test "This is stop called"
in mentioned keyword, there are 2 test cases that passes for a suite but report states:
Similarly if
Run keyword if "${test}" == "items2" Stop Test "This is stop called"
And so on - hence it seems that "Set Test Message" log values are ignored in report message when a test case is marked as Fail. Note that below is the log.html content when I ran the code to mark the very first test case as failure:
Run keyword if "${test}" == "item" Stop Test "This is stop called"
In all my question is thus that if I want report.html file to show logs for all fail and passed test cases how can I achieve it?
If you check the documentation of the Set Test Message keyword it says that any failure will override the messages, but you have the option to override the failure message from the teardown.
So what you can do is instead of calling Set Test Message, you could just save the messages into a test variable. Then you should add a teardown in which you call the Set Test Message and concatenate your test variable with the
${TEST MESSAGE}
. For example:This example produces the following report:
With this approach you could have only the template tests in the particular robot suite as all test listed in the Test Cases table will invoke the template.
Other, completely different solution can be to get rid of the
FOR
loop as elements in@{MyList}
are static. If you move the template into the Settings table and then manually list all iterations, you could separate each one of them into an independent test case. This way failure in one iteration won't affect the test message set in an other iteration. For example:This would produce the following report: