机器人框架的[文档]中的测试用例级变量 [英] Testcase level variables in [Documentation] for robot framework

查看:90
本文介绍了机器人框架的[文档]中的测试用例级变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使测试级别变量出现在文档中.

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

请注意,套件级别变量已得到正确处理,而测试级别一则未正确处理.
如何获得所有变量的同等对待?

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}

有关更多信息,请参见 http://robotframework.googlecode.com/hg/doc/libraries/BuiltIn.html?r=2.7.7#Set%20Test%20Documentation

For more information see http://robotframework.googlecode.com/hg/doc/libraries/BuiltIn.html?r=2.7.7#Set%20Test%20Documentation

这篇关于机器人框架的[文档]中的测试用例级变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆