I have a step in SpecFlow to check whether some area is displayed (e.g. User info).
Then "User Info" area is displayed
And I would like to have optional table for this step checking some other information in the area (e.g. First name, Surname, Address...).
Then "User Info" area is displayed
| Surname |
| Smith |
I tried to create a method with optional argument:
public void ThenUserInfoAreaIsDisplayed(Table table = null)
{
...
}
But I got this exception when using a step without the table:
Parameter count mismatch! The binding method 'Example.ThenUserInfoAreaIsDisplayed()' should have 0 parameters
I also tried to overload the method:
public void ThenUserInfoAreaIsDisplayed()
{
...
}
public void ThenUserInfoAreaIsDisplayed(Table table)
{
...
}
In this case I get the following exception:
Parameter count mismatch! The binding method 'Example.ThenUserInfoAreaIsDisplayed()' should have 1 parameters
Any ideas? Thanks.
I think that this is not possible exactly as you want it. You just could add another step definition for the version with the table using a somewhat extended/modified wording:
Then "User Info" area is displayed
and
Then "User Info" area is displayed with this information:
| Surname |
| Smith |
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With