环境: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)
尽管前6个字符串匹配,但“给出”步骤文本却不同:
"^that "([^"]*)" is a rejected case"
"^that "([^"]*)" is a rejected case in kommune "([^"]*)"$"
方法名称根本不相似:
isARejectedCase(String)
isARejectedCaseInKommune(String,String)
IntelliJ / Cucumber为何声称这些含糊不清?
此代码之前确实有效。之间可能有一些插件更新或其他更新,但是我不明白为什么它应该表现得如此?
答案 0 :(得分:0)
在这里回答我自己的帖子:
原因是在步骤定义的末尾缺少“ $”,以标记句子的末尾。否则,它将匹配以相同单词开头的定义。示例:
When X does Y because of W
When X does Y becayse of W in addition to P