Updating the name of SpecFlow scenario outline variations

做~自己de王妃 提交于 2019-12-10 12:46:47

问题


I have this feature file:

Scenario Outline: Example
    Given I am a user
    When I enter <x> as an amount
    Then the result should be <result>
    Examples:
        | x | result |
        | 3 | 3      |
        | 1 | 1      |

My issue is that after it's run, each example is labeled as variant #

Is there a way to name what each example line is actually testing, so that in the report, we know better what is tested, not just:

Scenario: Example, Variant 0
Scenario: Example, Variant 1
Scenario: Example, Variant 2

I'm trying to help our testers get more meaningful reports; there is typically a reason they write multiple examples, and they want that reason for that example shown somehow.


回答1:


As the SpecFlow Scenario Outlines documentation says:

the Gherkin syntax does not enforce that all example columns have the matching placeholder in the scenario outline, you can even introduce an arbitrary column in the example sets for better test method name readability

So you could introduce an arbitrary column into your "Examples" table to succinctly describe the intention of the test e.g.

Scenario Outline: Example
    Given I am a user
    When I enter <x> as an amount
    Then the result should be <result>
    Examples:
        | example description   | x | result |
        | Example Description 1 | 3 | 3      |
        | Example Description 2 | 1 | 1      |

This would result in the following test names:

Example_ExampleDescription1
Example_ExampleDescription2


来源:https://stackoverflow.com/questions/21946550/updating-the-name-of-specflow-scenario-outline-variations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!