黄瓜小黄瓜AmbigiousStepDefinition问题

时间:2015-12-17 00:48:24

标签: cucumber gherkin

我收到一个AmbigiousStepDefinitionsException,我不知道为什么我会收到错误。我怎么能绕过它?

      And I look for an apple in yellow basket with the following items
or
      And I look for an apple in basket with the following items


        @When("^I look for an? (apple|pear|grape) in (.*) basket with the following items:$")
        Public void findStoreItems(String fruit, Map<string,String> itemList)

        @When("^I look for an? (apple|pear|grape) in basket for the shop with the following items:$)
        Public void findColorItems(String fruit, String color, Map<string,String> itemList)

2 个答案:

答案 0 :(得分:0)

执行时使用cucumber path_to_file.feature --guess

这将解决不明确的匹配错误。

示例:

{{1}}

答案 1 :(得分:0)

这是你的(。*)正则表达式。这根本不算什么。我使用“([^”] *)“并用引号括起我的形容词(在这种情况下是颜色)。或者你可以使用(。+),它至少需要一个字符匹配,并且应该消除歧义。

And I look for an apple in "yellow" basket with the following items

@When("^I look for an? (apple|pear|grape) in "([^"]*)" basket with the following items:$"
顺便说一下,没有被问到,但你错过了你的文章。作为一名软件测试人员,这会“惹恼”我; - )

@When("^I look for an? (apple|pear|grape) in an? "([^"]*)" basket with the following items:$"