Search code examples
c#cucumberspecflowgherkin

Receiving value from another column in SpecFlow Feature file with Examples


I'm writing BDD Tests with SpecFlow in c#. I'm trying to, in a beautiful way, take the value of one of the columns and use it as input to another column. Code:

Examples:
| volume    | error |
|  0        | Volume must be greater than 0 but is <volume> | 

I'd like <volume> to take the value 0 in this case. Is this possible? This is obviously not working at the moment. Thanks :)


Solution

  • No, it is not possible. One could argue that the connection between the two volume values would be more noticeable, easier to understand, but if you actually substitute 0 in this case, it will be perfectly understandable. If you do want to emphasize the connection, you could write another scenario outline along the lines:

    Given the volume has been set to <volume>
    When action is triggered
    Then the error message should be "Volume must be greater than 0 but is <volume>"
    

    And then all your examples with nonpositive numbers.