Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将Specflow语句中的字母数字文本转换为参数而忽略?_C#_Specflow - Fatal编程技术网

C# 如何将Specflow语句中的字母数字文本转换为参数而忽略?

C# 如何将Specflow语句中的字母数字文本转换为参数而忽略?,c#,specflow,C#,Specflow,我正在创建一个SpecFlow场景(使用Visualt Studio),其中字母数字文本是语句的一部分 但当我创建它的定义时,字母数字文本的数字部分将更改为参数。e、 g. 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

我正在创建一个SpecFlow场景(使用Visualt Studio),其中字母数字文本是语句的一部分
但当我创建它的定义时,字母数字文本的数字部分将更改为参数。e、 g.

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

是的,在这些情况下,您必须手动更改正则表达式。扩展尝试尽可能准确地猜测什么是参数,什么不是参数。不能保证它总是创建您想要的正则表达式。