Cucumber: Scenario Outline reusing examples table

后端 未结 3 733
予麋鹿
予麋鹿 2020-12-11 23:22

I have a few tests like below:

Scenario Outline: Add two numebrs
  Given two numbers  and 
  When I add them
  Then Result is         


        
3条回答
  •  半阙折子戏
    2020-12-11 23:54

    The easiest solution that comes to my mind is combining both scenarios, extracting details to the examples table. So it would look like:

    | number_1 | number_2 | operation | result |
    

    You have another possibility.

    Scenario: Add two numebrs
    Given I have the matrix of numbers
    When I add them
    Then I would have the resulting vector.
    
    Scenario: Update two numebrs
    Given I have the matrix of numbers
    When I update them
    Then I would have the resulting vector.
    

    Where "the matrix of numbers" and "the resulting vector" go to step defs file.

提交回复
热议问题