简体   繁体   English

机械手框架:在文档输出中显示测试用例的变量

[英]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.

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. 对于testdoc工具,它显然无效,因为它显然要求测试已执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM