如何忽略Specflow语句中转换为参数的字母数字文本



我正在创建一个SpecFlow场景(使用Visualt Studio(,其中字母数字文本是语句的一部分
但是当我创建它的定义时,字母数字文本的数字部分会变为parameter。例如

Scenario: Add two variables
Given the first number is of type S1 and is 50
And the second number is of type S2 and is 70
When the two numbers of type S1 and S2 are added
Then the result should be 120

当我右键单击Given语句并创建定义时,我得到以下定义:

[Given(@"the first number is of type S(.*) and is (.*)")]
public void Function(int p0, int p1)

相反,我想要的是:

[Given(@"the first number is of type S1 and is (.*)")]
public void Function(int p0)

SpecFlow猜测在为步骤定义生成存根时正则表达式应该是什么。步骤中出现的任何数字都被猜测为一个参数。这是默认行为,我不知道如何更改它。只需修改步骤定义模式,使其适合您的特定用例。

最新更新