是否可以多个场景使用同一个Examples表?
所以不要像下面这样:
Scenario Outline: First Scenario
Given I am viewing "<url>"
Then I assert that the current URL "<url>"
Examples:
| url |
| https://google.com |
| https://twitter.com|
Scenario Outline: Second Scenario
Given I am viewing "<url>" with route "</contactus>"
Then I assert that "<url>" contains "contactus"
Examples:
| url |
| https://google.com |
| https://twitter.com|
我可以做类似的事情
Scenario Outline: Reusable Example
Examples:
| url |
| https://google.com |
| https://twitter.com|
Scenario: First Scenario
Given I am viewing "<url>"
Then I assert that the current URL "<url>"
Scenario: Second Scenario
Given I am viewing "<url>" with route "</contactus>"
Then I assert that "<url>" contains "contactus"
我找到了一个 similar question on StackOverflow ,但将我的所有场景合并到一个场景中对我来说不是一个选择。由于这个问题是在 2014 年发布的,也许框架有一些我不知道的进步 :D
提前致谢。
最佳答案
您可以使用 qaf-gherkin您可以在其中移动外部文件中的示例并将其用于一个或多个场景。使用 qaf,您的功能文件可能如下所示:
Scenario Outline: First Scenario
Given I am viewing "<url>"
Then I assert that the current URL "<url>"
Examples:{'datafile':'resources/testdata.txt'}
Scenario Outline: Second Scenario
Given I am viewing "<url>" with route "</contactus>"
Then I assert that "<url>" contains "contactus"
Examples:{'datafile':'resources/testdata.txt'}
您的数据文件将如下所示:
url
https://google.com
https://twitter.com
这是 reference .
关于cucumber - Cucumber 中的可重用/通用示例表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52168605/