Robot Framework:在文档输出中显示测试用例的变量

时间:2016-06-27 14:22:22

标签: variables documentation report robotframework

是否可以将我的测试用例的变量写入我的文档?我不想打印全局变量!

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

因为以下是不可能的。

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

1 个答案:

答案 0 :(得分:2)

没有办法自动完成这项工作,但您可以在使用关键字Replace VariablesSet 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}

请注意,这仅适用于测试日志和报告中显示的文档。它不适用于testdoc工具,因为它显然要求测试已经执行。