我的示例功能文件,而不是从示例中提供数据我希望它从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中定义数据值。
答案 0 :(得分:1)
你不能和Gherkin在一起。您可以做的是为CSV文件指定一个合适的名称,参考Gherkin步骤中的名称,然后加载并读取步骤定义中的文件。
<强> 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
})
强>
java.util.concurrent.TimeoutException: Unable to retrieve a message from Kafka in 5000ms
答案 1 :(得分:0)
不直接。但是,您可以在Example表中拥有排序的记录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中检索相应的记录。