Multiple Match bindings found on line with two different parameters

你说的曾经没有我的故事 提交于 2019-12-05 15:22:59

The problem is that your second regex:

with (.*) in (.*)

matches both these lines

with a partridge in a pear tree
with a partridge for Christmas in a pear tree

In the first instance, it'll pick up "partridge" and "a pear tree" as the two arguments. In the second, it will pick up "partridge for Christmas" and "a pear tree" as the arguments. Since your first regex also matches that second line, it is indeed finding multiple bindings.

You could use a different regex. For instance, if you want to pick out a whole word and not have any whitespace included, try (\S*) instead of (.*). That . matches anything, including spaces. More on regex here.

AFAIK the Visual Studio integration jumps to the first step definition it finds.

The Regex of the def()- Steps catches also the cases of the abc- Step. Did you tried to put the parameters within single quotes?

Like that:

Feature:

When user '$action1$' '$key1$' with '$value1$' for '$atttributeType_Value$' in   '$Filename1_SectionId1$'
Then abc
When user '$action2$' '$key2$' with '$value2$' in '$Filename2_SectionId2$'
Then def

Step Bindings:

[When(@"user '(.*)' '(.*)' with '(.*)' for '(.*)' in '(.*)'")]
public void abc()
{   //operation }

[When(@"user '(.*)' '(.*)' with '(.*)' in '(.*)'")]
public void def()
{   //operation }

That should fix your problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!