我在 SpecFlow 中有一个步骤来检查是否显示了某些区域(例如用户信息)。
Then "User Info" area is displayed
而且我希望有可选的表格来检查该地区的一些其他信息(例如名字、姓氏、地址...)。
Then "User Info" area is displayed
| Surname |
| Smith |
我尝试创建一个带有可选参数的方法:
public void ThenUserInfoAreaIsDisplayed(Table table = null)
{
...
}
但是我在没有表格的情况下使用步骤时遇到了这个异常:
Parameter count mismatch! The binding method 'Example.ThenUserInfoAreaIsDisplayed()' should have 0 parameters
我也试过重载方法:
public void ThenUserInfoAreaIsDisplayed()
{
...
}
public void ThenUserInfoAreaIsDisplayed(Table table)
{
...
}
在这种情况下,我得到以下异常:
Parameter count mismatch! The binding method 'Example.ThenUserInfoAreaIsDisplayed()' should have 1 parameters
有什么想法吗?谢谢。
最佳答案
我认为这不可能完全如您所愿。您可以使用稍微扩展/修改的措辞为带有表格的版本添加另一个步骤定义:
Then "User Info" area is displayed
和
Then "User Info" area is displayed with this information:
| Surname |
| Smith |
关于c# - SpecFlow 中的可选表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40084649/