In my current project, as part of compliance requirement, we are required to update the results back for each test step in our test management system. We are implementing a listener for this and using keyword tags to map them to specific test steps. While everything works perfectly, we are left with a situation, where we do not have any meaningful message to update the test step in case of passing keyword. In case of Failed keyword, the ${KEYWORD MESSAGE} has the information that we update in test results. Also, since the variable is only available in Suite Teardown, we created a standard keyword that we send the custom message. This keyword is called as part of Keyword Teardown and gets specific message if Keyword Fails, and retains failure value in case of failure.
But, while trying to use the variable in end_user_keyword method - the value is unavailable - maybe because of timing/sequence of update.
Is there a better reliable way to achieve this workflow? Would be great to be able to set Keyword Message value at Keyword Setup stage, which gets overridden in case of failure .
Let me repeat what I have understood: when a keyword fails, you use ${KEYWORD MESSAGE} to report the status of the test step to a test management system. When the keyword passes there is no error message, thus you cannot report the KEYWORD MESSAGE to the test management system.
Do you have to set the keyword message argument in robot? Maybe you can send a default (pseudo code):
if keyword_status == 'PASS'
self.report_test_step_status(keyword_status) # send PASS as default keyword message
else:
self.report_test_step_status(keyword_message)
Yes, the problem statement is accurate! What we implemented is quite close to what you suggested, except that we are using another global variable and not ${KEYWORD MESSAGE}. Ideally, it would have been useful to have facility to set the ${KEYWORD MESSAGE} variable in Keyword Setup method, and gets overriden with the actual failure message in case of Failed Keyword. We wanted to avoid adding additional lines to code to each keyword to make this work - but looks like thats the only way right now.
If i understood what @ckarve is asking - the information in ${keyword message}contains the “step” that you need to update against in your test management ? If thats the case, add the step information in the docs with something that you can easily capture with regex and then in your listener, you should be able to access the keyword documentation. At least the documentation states that docattribute should be available.