我可以在 SpecFlow 中多次 运行 一个特征吗?

Can i run a feature multiple times in SpecFlow?

我已经搜索了一段时间,但我还没有找到我的问题的答案:我可以 运行 使用相同输入的功能文件 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 做到这一点吗?

虽然我不知道您将如何使用配置文件执行此操作,但我建议您创建一个场景大纲。例如,在您的情况下:

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 数量 table.

一样多

你也可以这样做:

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           |
|...