我想使用KW“设置测试文档”与RobotFW的多行,返回到行(\n)不适用于此KW
有人有解决方案吗?
发布于 2017-12-23 00:09:51
设置多行文档很棘手,因为robot对其文档有一些奇怪的规则。从标题为Documentation Formatting的用户指南部分
从Robot Framework2.7.2开始,格式化的
文档中的所有常规文本都表示为段落。实际上,由单个换行符分隔的行将被合并到一个段落中,而不管换行符是手动还是自动添加的。多个段落可以用空行(即两个换行符)分隔,也可以用后续章节中讨论的表格、列表和其他特殊格式的块来结束段落。
简而言之,这意味着每行都需要以两个换行符结束。
示例:
*** Variables ***
${var1} this is var1
${var2} this is var2
*** Test Cases ***
Example of setting multiline test documentation
set test documentation
... var1: ${var1}\n\nvar2: ${var2}在log.html中,上面的内容将如下所示:

如果您的目标是记录变量的值,robot还支持用于创建表的简单标记。以下示例展示了如何创建表。在本例中,我使用了附加到文档而不是替换文档的功能:
*** Variables ***
${var1} this is var1
${var2} this is var2
*** Test Cases ***
Example 2: documentation with embedded table
set test documentation
... | var1 | ${var1} | \n
set test documentation
... | var2 | ${var2} | \n append=True在log.html中,上面的内容将如下所示:

发布于 2017-12-22 20:16:35
我不确定我们是否可以直接这样做,在参考了Bryan在这个帖子上的回复后,我找到了一个解决办法。
Testcase level variables in [Documentation] for robot framework
在这里,首先在文档部分提到多行,然后这一部分可以被设置测试文档kw使用。
*** Variables***
${SystemUnderTest} Staging
*** Test cases***
Device Test
Set Test Variable ${device} iPhone
[Documentation] Device is:
... System is: ${SystemUnderTest}
Substitute vars in documentation
*** Keywords ***
Substitute vars in documentation
${doc}= replace variables ${test documentation} # This will substitute the variables in documentation with their values , ${test documentation} is an inbuilt keyword which actually parse the content of [Documentation]
set test documentation ${doc} append=True #now the set test docuemntation will take the multi line input from documentation section有关http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Set%20Test%20Documentation的更多详细信息,请参阅以下链接
https://stackoverflow.com/questions/47940278
复制相似问题