Java和Cucumber:奇怪的不明确步骤定义异常

Java和Cucumber:奇怪的不明确步骤定义异常,java,intellij-idea,cucumber,Java,Intellij Idea,Cucumber,环境:Java/IntelliJ/cumber 最近,我经历了好几次IntelliJ声称一个模棱两可的步骤定义,而实际上并没有 cucumber.runtime.AmbiguousStepDefinitionsException: "that "saken" is a rejected case in kommune "5000"" matches more than one step definition: "^that "([^"]*)" is a rejected case" in Sa

环境:Java/IntelliJ/cumber

最近,我经历了好几次IntelliJ声称一个模棱两可的步骤定义,而实际上并没有

cucumber.runtime.AmbiguousStepDefinitionsException: "that "saken" is a 
rejected case in kommune "5000"" matches more than one step definition:
"^that "([^"]*)" is a rejected case" in SakSteps.isARejectedCase(String)
"^that "([^"]*)" is a rejected case in kommune "([^"]*)"$" in 
SakSteps.isARejectedCaseInKommune(String,String)
“给定”步骤文本不相同,尽管前6个字符串匹配:

"^that "([^"]*)" is a rejected case"
"^that "([^"]*)" is a rejected case in kommune "([^"]*)"$"
方法名称完全不同:

isARejectedCase(String)
isARejectedCaseInKommune(String,String)
为什么IntelliJ/Cumber声称这些都是模棱两可的


这段代码以前确实有效。可能有一些插件更新或其他之间的,但我不明白为什么它应该这样做?

在这里翻译我自己的帖子:

原因是在步骤定义的末尾缺少一个“$”来标记句子的结尾。否则,它将匹配以相同单词开头的定义。例如:

When X does Y because of W
When X does Y becayse of W in addition to P

我遇到了类似的问题,我将其归因于这样一个事实:第一个regexp表达式(
“^that”([^“]*)”是被拒绝的案例“
”)是第二个(
“^that”([^“]*)”是kommune中被拒绝的案例([^“]*)“$”
)的子案例。我通常做的是找到不同的措辞来区分它们。也许你也可以在第一个结尾处添加
$
,以表示句子的结尾。哇!我怎么没看到?!你完全正确-似乎用“$“这是关键。把你的评论写在一个答案里,这样我就可以给你评分了:-)