kame
kame

Reputation: 21990

Robot Framework: Show a variable of a test case in the documentation output

Is it possible to write the variable of my test case into my documentation? I don't want to print a global variable!

*** Test Case ***
My Test Case
    [Documentation]    I want to print ${variable1} here.
    ${variable1}=    set variable    "hello, world"

Because the following is not possible.

*** Test Case ***
My Test Case
    ${variable1}=    set variable    "hello, world"
    [Documentation]    I want to print ${variable1} here.

Upvotes: 0

Views: 1304

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 386285

There's no way to make this work automatically, but you can set the documentation dynamically within your test at some point after you've defined the variables using the keywords Replace Variables and Set Test Documentation:

*** Test Case ***
Example
    [Documentation]    I want to print ${variable} here

    ${variable}=    set variable    "hello, world"

    ${doc}=    Replace variables    ${TEST DOCUMENTATION}
    set test documentation    ${doc}

Note that this only works for the documentation as it appears in the test logs and reports. It won't work for the testdoc tool since it obviously requires that the the test has been executed.

Upvotes: 2

Related Questions