I want to set for each test inside the test suite a simple report of the computer name,
So I've created the following simple robot __init__.robot
file:
*** Settings ***
Metadata Executed At Get Environment Variable COMPUTERNAME
Library OperatingSystem
The problem is that the Get Environment Variable
is translated as a string instead of calling the keyword Get Environment Variable
with the argument COMPUTERNAME
The log put is:
Executed At: Get Environment Variable COMPUTERNAME
Question:
How can i call some keyword from the settings Metadata
?
If you are asking about how to call a keyword in the Metadata
setting, the answer is that you can't. What you can do, however, is call a keyword that sets the metadata. Within the Metadata
setting, however, you can only define strings.
To set the metadata via a keyword is a two step process: first, call a keyword and save the return value, and then call the Set Suite Metadata keyword. You can do this in a Suite Setup by creating a custom keyword:
*** Settings ***
Suite setup Initialize Metadata
*** Keywords ***
Initialize Metadata
${data}= Get environment variable COMPUTERNAME
Set suite metadata Executed At ${data}
If your real problem is simply that you want to set metadata based on an environment variable, use the environment variable syntax:
*** Settings ***
Metadata %{COMPUTERNAME}