机器人框架的 [文档] 中的测试用例级变量 [英] Testcase level variables in [Documentation] for robot framework
问题描述
我无法让测试级变量出现在文档中.
I cannot get test level variables to appear in documentation.
假设我有这个测试套件:
Let's say I have this testsuite:
| *Variables* |
| ${SystemUnderTest} = | Staging
| *testcase* |
| Device Test |
| | Set Test Variable | ${device} | iPhone
| | [Documentation] | Device is: ${device} |
| | ... | System is: ${SystemUnderTest} |
| | No Operation
生成此日志:
TEST CASE: Device TestExpand All
Full Name: T.Device Test
Documentation:
Device is: ${device} System is: Staging
请注意,套件级别变量得到了正确处理,但测试级别 1 则没有.
如何让所有变量得到平等对待?
Notice that the Suite level variable is treated properly, but the test level one is not.
How do I get all variables to be treated equally?
推荐答案
从robotframework 2.7开始有一个内置的关键字Set test documentation
,可以用来替换或追加到现有文件.这将影响控制台中的输出,但更改将反映在日志和报告中.
Starting with robotframework 2.7 there is a built-in keyword named Set test documentation
, which can be used to replace or append to the existing documentation. This will not affect the output in the console, but the changes will be reflected in the log and report.
例如:
| *Variables* |
| ${SystemUnderTest} = | Staging
| *testcase* |
| Device Test |
| | Set Test Variable | ${device} | iPhone
| | [Documentation] | Device is: ${device} |
| | ... | System is: ${SystemUnderTest} |
| | Substitute vars in documentation
| | No Operation
| *Keywords* |
| Substitute vars in documentation
| | ${doc}= | replace variables | ${test documentation}
| | set test documentation | ${doc}
For more information see http://robotframework.googlecode.com/hg/doc/libraries/BuiltIn.html?r=2.7.7#Set%20Test%20Documentation
这篇关于机器人框架的 [文档] 中的测试用例级变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!