黄瓜:方案大纲重用示例表 [英] Cucumber: Scenario Outline reusing examples table

查看:102
本文介绍了黄瓜:方案大纲重用示例表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些类似下面的测试:

I have a few tests 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:
    |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'}

数据文件如下所示:

  #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-黄瓜具有 BDD2 支持与Cucum 5配合使用的黄瓜。

qaf-cucumber has BDD2 support with cucumber that can be used with Cumber 5.

这篇关于黄瓜:方案大纲重用示例表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆