声明robot框架测试之间的依赖关系

robotframework-dependencylibrar的Python项目详细描述


声明测试之间的依赖关系。使测试自动基于失败 其他测试用例或测试套件的结果。

尽管我强烈建议人们编写测试时要独立, 有时,测试之间的依赖关系是最简单和最容易的模型 实现,如果一个或多个以前的测试失败 没有得到预期效果的病例是有益的。

版本控制

这个库的版本号跟在SemVer 2.0.0 specification后面。

安装

pip install robotframework-dependencylibrary

用法

首先,在测试中包含库:

*** Settings ***LibraryDependencyLibrary

假设您有一个通过和不通过的测试:

*** Test cases ***Passing TestNo operationFailing TestFailThis test is intentionally hardcoded to fail

取决于通过测试的基本测试如下:

*** Test cases ***This Test Depends on "Passing Test" PassingDepends on testPassing TestLogThe rest of the keywords in this test will run as normal.

当然,您可以依靠测试失败来代替:

*** Test cases ***This Test Depends on "Failing Test" FailingDepends on test failureFailing TestLogThe rest of the keywords in this test will run as normal.

您还可以取决于测试套件的状态:

*** Test cases ***This Test Depends on an Entire Test Suite PassingDepends on suiteMy Test Suite NameLogThe rest of the keywords in this test will run as normal.

故障

因为Depends on ...关键字在依赖项不存在时失败 met,它支持您期望从robot框架获得的所有常规逻辑:

Depends on ...关键字按预期失败时,测试用例会自动中止并失败,除非您捕获状态和 使用Run keyword and expect error之类的错误消息。

错误消息

错误信息被记录在案(并被视为 接口,因此您可以依赖semver语义:主要版本 如果错误消息的逻辑发生更改,则编号将被取消:

如果测试未通过,则会出现一个有用的错误:

*** Test cases ***This Test Depends on "Failing Test" PassingDepends on testFailing TestLogThe rest of the keywords (including this log) will NOT run!

错误信息为:

Dependency not met: test case 'Failing Test' state is 'FAIL', wanted 'PASS'

与期望通过测试失败相同:

*** Test cases ***This Test Depends on "Passing Test" FailingDepends on test failurePassing TestLogThe rest of the keywords (including this log) will NOT run!

错误信息为:

Dependency not met: test case 'Passing Test' state is 'PASS', wanted 'FAIL'

如果你输入了一个测试,或者试着依赖于之前测试的状态 它已运行,例如:

*** Test cases ***Depends on Non-Existant Test CaseDepends on testMisnamed Test

错误信息为:

Dependency not met: test case 'Misnamed Test' not found, wanted 'PASS'

如果你不小心让一个测试依赖于它自己,它会给出一个类似的 更准确地标识错误的错误消息:

*** Test cases ***Depends on selfDepends on testDepends on self

错误信息为:

Dependency not met: test case 'Depends on self' mid-execution, wanted 'PASS'

所有测试套件错误消息都是相同的,除了它们使用 用“测试套件”代替“测试用例”。

注意

如果需要以编程方式分析错误消息,请保留 请注意,测试用例和套件的名称和状态是用 相当于python内置函数repr的逻辑。

额外费用

对于与Depends on test failure对称,关键字Depends on test success可用作Depends on test

*** Test cases ***This Test Depends on "Passing Test" Passing (using alternate keyword)Depends on test successPassing TestLogThe rest of the keywords in this test will run as normal.

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java文件分块,获取长度字节   java嵌入式Tomcat不执行jsf页面   java我的数据库中有2个实体,但hibernate返回其中6个。   java如何基于逗号拆分字符串   java取消已经运行的CompletableFutures的预期模式是什么   java如何在informix中从另一个数据库复制表ddl和数据   为什么图片是黑色的?   java根据字符串数组中的单词筛选列表   Java8的集合。平行流有效吗?   Kotlin中的java静态内部类   java如何在GUI中生成一列字符串   javafx如何正确使用高对比度主题?   带空格的javascript Httpurlconnection参数   java如何设置GridBagLayout的约束   java如何在一个线程可能尚未初始化时关闭另一个线程   java将简单时间格式转换为特殊时间格式(hhmmt)   安卓/java阵列重复过滤器的问题   java在队列的链接实现下,入队和出队是如何工作的   java更新sql外键约束