我现在已经搜索了一段时间,但我找不到我的问题的答案:我可以使用相同的输入运行x次特征文件吗? x应该是配置文件中的数字。
Feature: SpecFlowFeature
In order to avoid silly mistakes
As a math idiot
I want to be told the sum of two numbers on DEV environment <= Can I do this? Can DEV be a parameter?
@mytag
Scenario: Add two numbers
Given I have entered 50 into the calculator
And I have entered 70 into the calculator
When I press add
Then the result should be 120 on the screen
因此,基于上述功能,我希望能够从配置文件中读取一个数字,这将是我想要运行相同功能的次数。换句话说,我想添加50 + 70 10次。将从配置文件中读取次数。我可以使用Specflow吗?
答案 0 :(得分:1)
虽然我不知道如何使用配置文件执行此操作,但我建议您创建一个场景大纲。例如,在您的情况下:
Feature: SpecFlowFeature
In order to avoid silly mistakes
As a math idiot
I want to be told the sum of two numbers on DEV environment
@mytag
Scenario Outline: Add two numbers
Given I have entered 50 into the calculator
And I have entered 70 into the calculator
When I press add
Then the result should be 120 on the screen
And this concludes testrun number '<id>'
Examples:
|id|
|1 |
|2 |
|3 |
|...
现在最后一步可能无效,或者您可以使用报告工具来跟踪测试结果。无论哪种方式,测试将运行与示例表中的ID数量相同的次数。
你也可以这样做:
Feature: SpecFlowFeature
In order to avoid silly mistakes
As a math idiot
I want to be told the sum of two numbers on DEV environment
@mytag
Scenario Outline: Add two numbers
Given I have entered '<value1>' into the calculator
And I have entered '<value2>' into the calculator
When I press add
Then the result should be '<expected value>' on the screen
Examples:
|value1|value2|expected value|
|50 |70 |120 |
|50 |70 |120 |
|50 |70 |120 |
|50 |70 |120 |
|50 |70 |120 |
|50 |70 |120 |
|...