我需要机器人框架方面的帮助。如何创建测试场景?我所说的测试场景是指将多个测试用例组合在一起。例如,如果我有以下测试用例:
1.登录后台
2.添加内容后端
3.后台编辑内容
4.查看前端内容部分
然后我有以下测试场景: 1.登录后台->添加后台内容->检查前端内容部分是否会更新 2.登录后台->后台编辑内容->查看前端内容部分是否会更新
好吧,现在我该如何在 Robot Framework 中编写这些内容呢?目前,在***测试用例***部分,我已经写出了2个测试用例:
这两个测试用例都重复登录后端和检查前端内容部分命令。有没有办法减少代码冗余?例如,我可以将登录后端并检查前端内容部分编写为函数,然后稍后在 *** 测试用例 *** 部分中调用它们吗?
当然,您可以将任何操作包装为
keyword
(RobotFramework 函数/方法的名称),然后重用它。
在用户指南中有解释。
因此,
Login backend
、Edit content backend
和Frontend content section should be updated
可能是可以重复使用的关键字。
例如,非常高水平:
backend.robot
,例如:*** Keywords ***
Login backend
[Arguments] ...
...
Edit content backend
[Arguments] ...
...
Frontend content section should be updated
[Arguments] ...
...
sanity.robot
:*** Settings ***
Resource libs/backend.robot
*** Test Cases ***
Backend content could be added
Login backend <arguments here if any>
Add content backend <arguments here if any>
Frontend content section should be updated <arguments here if any>
Backend content could be edited
Login backend <arguments here if any>
Edit content backend <arguments here if any>
Frontend content section should be updated <arguments here if any>