Steps matching can be determined by Scope: https://github.com/techtalk/SpecFlow/wiki/Scoped-bindings . But this is static mechanism. Is there a way to make this mechanism dynamic so that:
- In single scenario I have two or more same steps
- There are many step definitions for this step decorated with (attribute?)
- I have step to change context and base on key set in this step different method will be called
This is like Tag restriction from Scope mechanism + dynamicity.
I test application with multiple tables on different pages. I must verify if:
- table contains rows (is subset)
- table have exact rows (items and order) (is equal)
- table have rows (but order is not important).
I am writing:
When I am on Page1
Then I expect that table contains
| Column1Name | Column2Name | Column3Name |
| row1id | true | address |
| row2id | true | address |
When I do some change action on rows
| Column1Name |
| row1id |
Then I expect that table contains
| Column1Name | Column2Name |
| row1id | false |
| row2id | true |
I have only one step definition for “I expect that table contains”. It verifies cells provided in step. This step is used on different pages for different columns and pages. These page shows different business objects, have different columns but ui is quite common. Without this I would have to write steps for each page and each column combination.
But as always there are some specific actions that should be taken before “I expect that table contains”. For instance:
- different search filter to use on different pages.
- timeout that is required before action changes appears on ui (services, cache, etc)
I don’t want to write it explicitly because it makes that scenario is overloaded with unnecessary informations.