Cucumber: Scenario Outline reusing examples table(Cucumber:场景大纲重用示例表)
问题描述
我有一些测试如下:
Scenario Outline: Add two numebrs
Given two numbers <number_1> and <number_2>
When I add them
Then Result is <number_3>
Examples:
|number_1|number_2|number_3|
|2 |3 |5 |
|1 |2 |3 |
Scenario Outline: Update two numebrs
Given two numbers <number_1> and <number_2>
When I update them
Then Result is <number_3>
Examples:
|number_1|number_2|number_3|
|2 |3 |5 |
|1 |2 |3 |
对于每个测试,我应该添加相同的表格示例.
For each test I should add the same table Examples.
有什么方法可以提取此表以对所有测试使用同一个表?
Is any way to extract this table to use the same one for all tests?
推荐答案
你可以使用 qaf-gherkin 您可以在其中移动外部文件中的示例并将其用于一个或多个场景.使用 qaf,您的功能文件可能如下所示:
You can use qaf-gherkin where you can move examples in external file and use it with one or more scenario. With qaf your feature file may look like below:
Scenario Outline: Add two numebrs
Given two numbers <number_1> and <number_2>
When I add them
Then Result is <number_3>
Examples::{'datafile':'resources/testdata.txt'}
Scenario Outline: Update two numebrs
Given two numbers <number_1> and <number_2>
When I update them
Then Result is <number_3>
Examples:{'datafile':'resources/testdata.txt'}
您的数据文件将如下所示:
And your datafile will look like:
#col.separator=|
number_1|number_2|number_3
2|3|5
1|2|3
以上是带有 | 的 csv(宪章分隔值)数据提供者的示例作为分隔符.您还可以使用不同的数据提供者来提供来自任何 excel/xml/json/database 的数据.
Above is example of csv (charter separated values) data provider with | as seperator. You also can use different data providers to provide data from any of excel/xml/json/database.
qaf-cucumber 有 BDD2 支持可与 Cumber 5 一起使用的黄瓜.
qaf-cucumber has BDD2 support with cucumber that can be used with Cumber 5.
这篇关于Cucumber:场景大纲重用示例表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Cucumber:场景大纲重用示例表


- 转换 ldap 日期 2022-01-01
- 在 Java 中,如何将 String 转换为 char 或将 char 转换 2022-01-01
- java.lang.IllegalStateException:Bean 名称“类别"的 BindingResult 和普通目标对象都不能用作请求属性 2022-01-01
- GC_FOR_ALLOC 是否更“严重"?在调查内存使用情况时? 2022-01-01
- Eclipse 的最佳 XML 编辑器 2022-01-01
- 将 Java Swing 桌面应用程序国际化的最佳实践是什么? 2022-01-01
- 如何使 JFrame 背景和 JPanel 透明且仅显示图像 2022-01-01
- 未找到/usr/local/lib 中的库 2022-01-01
- 如何指定 CORS 的响应标头? 2022-01-01
- 获取数字的最后一位 2022-01-01