robotframework - 如何在 Robot Framework 中创建自定义测试用例设置,如标签
问题描述
*** Test Cases ***
TestCase_ID
[Documentation] Clef test
[Tags] default_tag
[link] this is hyperlink
Log This is testing
使用上面的代码,我希望“链接:”部分显示在 log.html 中。
解决方案
在 Robot Framework Github 页面上,有一个功能请求 2080 可以满足您的要求。但是,此请求已关闭,因为所提供的用例都不能使用标签来实现。
另一种几乎相同的方法是使用测试用例消息功能和 HTML 格式来生成一个部分以添加链接。下面是显示不同选项和总结果的示例代码。
*** Settings ***
Documentation This is the Suite Level Documentation
Metadata Version 1.0.0.1 #This the first patch on the initial version.
Metadata Author Stack Overflow #The core developer
*** Test Cases ***
Test Case 1
[Documentation] This is the test case documentation
[Tags] Test Tag 1
Set Suite Documentation Test Level addition to Suite Documenation append=${true}
Set Suite Metadata Test Case 1 A Suite Level Metadata item from the Test Case append=${true}
Set Suite Metadata Link http://www.microsoft.com append=${true}
Set Test Documentation My Test Level documentation append=${true}
Set Test Message *HTML* My Test level Message<br/> append=${true}
Comment My Test Case Comment
Log My Test Case Log
Fail
[Teardown] Set Jira Link 1234
*** Keywords ***
Set Jira Link
[Arguments] ${jira_Id}
${prev_level} Set Log Level WARN
Set Test Message *HTML* <br/><b>Link:</b> <a href='http://www.jira.com/issue/${jira_Id}'>Jira Issue ${jira_Id}</a><br/> append=${true}
Set Log Level ${prev_level}
推荐阅读
- python - 使用 PyQt5 WebEngine 显示网页
- lua - 在 if 内时,随机值不是随机的
- nexus - 在 Nexus Repository Manager OSS 3 上禁用 HTTP/2
- python - 尝试绘制全角矩形,但图像边界处有空白,为什么?
- javascript - Mongoose:确保数组永远不会大于一定数量的项目
- html - Get element at point 正在获取 aria-hidden div 而不是预期的元素
- java - Android:在 Fragment 中实例化 ViewModel 时出现 NullPointerException
- macos - 无法在 Mac 上使用 Pswh 连接到 SPOService
- python - Python中的元胞自动机模拟错误
- reactjs - NextJS 和 Storybook 不渲染图像和全局样式