Sharing dictionary data between tests

advertisements

I have the following scenario in Specflow:

Scenario Outline: K_KRED_FIELD - validation
    Given that K_KRED_FIELD has value <value>
    And that K_STATUS_FIELD has value <value_status>
    When I run rule K_KRED_RULE
    Then value of this field is <validation_result>

Examples:
    | value         | value_status| validation_result |
    | 0.00          | Cancelled   | valid             |
    | 0.00          |             | invalid           |

The general idea is as follows: I check if the value of field K_KRED_FIELD is valid, depending on value of other field - K_STATUS_FIELD using rule K_KRED_RULE. I have many fields and many rules like that.

Field K_STATUS_FIELD has many valid values (around 50). Of course it's possible to create example for each of those values but it's time-consuming and some other fields are dependent of K_STATUS_FIELD, so for each of them I need around 50 examples.

Is it possible to create something like a dictionary with valid values of K_STATUS_FIELD and run test against each of them? I was thinking about something like

Scenario Outline: K_KRED_FIELD - validation
    Given that K_KRED_FIELD has value <value>
    And that K_STATUS_FIELD value is valid
    When I run rule K_KRED_RULE
    Then value of this field is <validation_result>

Examples:
    | value         |  validation_result |
    | 0.00          |  valid             |
    | 0.00          |  invalid           |

where And that K_STATUS_FIELD value is valid iterates over each valid value for field K_STATUS_FIELD with each value K_KRED_FIELD taken from the Examples table.


You could use a dictionary in your step definitions. When you say something like: "And that the K_STATUS_Fields are valid" and that you use a loop in your step definitions to go through all the values.

Is that a possible solution to you, or am I totally of on understanding the problem?