Java 和 Cucumber:奇怪的模糊步骤定义异常

Java and Cucumber: Strange ambiguous step definition exception

环境:Java/IntelliJ/Cucumber

最近,我遇到过几次 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)

"Given"步骤文本不一样,虽然前6个字符串匹配:

"^that "([^"]*)" is a rejected case"
"^that "([^"]*)" is a rejected case in kommune "([^"]*)"$"

方法名称完全不相似:

isARejectedCase(String)
isARejectedCaseInKommune(String,String)

为什么 IntelliJ/Cucumber 声称这些是模棱两可的?

此代码以前确实有效。中间可能有一些插件更新或其他更新,但我不明白为什么它会这样?

在这里回答我自己的 post:

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

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