我的示例功能文件不是从示例中提供数据,而是希望它从csv传递,如何实现这一点,任何人都可以帮助我。
功能文件:
Feature: Rocky Search Status
Scenario Outline: Rocky Search Status with Filters
Given Open firefox and start application for Rocky Search Status
When User enters "<price_right>" and "<Carat_left>" and "<Color_right_param>" and "<Cut_right_param>" and "<Clarity_right_param>"
Then Message displayed Rocky Search Status Successful
Then Application should be closed after Rocky Search Status
Examples:
| price_right | Carat_left | Color_right_param | Cut_right_param | Clarity_right_param |
| 10000 | 1.5 | 80 | 180 | 84 |我希望数据值在项目外的CSV中定义。
发布于 2018-05-17 18:58:32
你不能和小黄瓜在一起。您可以做的是为CSV文件指定一个适当的名称,引用Gherkin步骤中的名称,然后加载和读取步骤定义中的文件。
abc.feature
Feature: A
Scenario: 1
Given data at abc.csv
...step-definitions.js
Given(/^data at (.*)$/, function (fileName) {
const data = jsonfile.readFileSync(`${__dirname}/${fileName}`);
// iterate over data
})发布于 2018-05-18 01:59:44
不是直接的。但是,您可以在示例表中有一个记录ID (或测试用例编号)。然后,您可以根据ID从步骤代码中的CSV中检索记录。
Scenario Outline: Rocky Search Status with Filters
Given Open firefox and start application for Rocky Search Status
When User enters data specified in test case <tcn>
Then Message displayed Rocky Search Status Successful
Then Application should be closed after Rocky Search Status
Examples:
|tcn|
|1 |
|2 |"When“步骤将使用tcn从CSV中检索相应的记录。
https://stackoverflow.com/questions/50388384
复制相似问题