Specflow场景中的强类型值

时间:2019-03-07 14:18:21

标签: specflow feature-file

在方案的示例表中是否可以使用强类型值? (或替代解决方案)

我想知道是否在编码过程中(而不是在运行测试过程中)在Enable StyleCop support列中输入了错字。

已更新

file.feature

userType

steps.cs

Scenario Outline: Scenario123
Given Create new user of type "<userType>"
Examples:
| userType     |
| PlatinumUser |
| CommonUser   |

1 个答案:

答案 0 :(得分:0)

您喜欢它的StepArgumentTransformation吗?

https://github.com/techtalk/SpecFlow/wiki/Step-Argument-Conversions

按以下方式使用:

[Binding]
public class Transforms
{
    [StepArgumentTransformation]
    public UserTypeEnum UserTypeTransform(string UserType)
    {
      // return the string converted into the required Enum
    }
}

步骤绑定将看到它需要一个UserTypeEnum作为参数,因此它将在具有Binding属性的任何类中搜索所有可用的步骤参数转换,并使用此方法执行转换。

相关问题