gpt4 book ai didi

java - cucumber AmbigouslyStepDefinitionsException

转载 作者:太空宇宙 更新时间:2023-11-04 09:26:39 24 4
gpt4 key购买 nike

我在以下情况下收到 AmbigeousStepDefinitionsException,我没有找到此问题的任何原因。请帮忙!

场景

 Scenario Outline: Testing the stars hotel filter
When the <star> stars hotel filter is clicked
Then all hotels are <star> stars
Examples:
| star |
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |

步骤文件

    @When("^the ([^\\\"]*) stars hotel filter is clicked$")
public void theStarStarsHotelFilterIsClicked(String star) {
hotelPage.activateStarsFilter(star);
}

@Then("^all hotels are ([^\\\"]*) stars$")
public void allHotelsAreStarStars(String star) throws InterruptedException {
hotelPage.checkHotelStars(star);
}

@When("^the ([^\\\"]*) filter is clicked$")
public void thePriceOrderFilterIsClicked(String priceOrder) {
hotelPage.activatePriceFilter(priceOrder);
}

错误

cucumber.runtime.AmbiguousStepDefinitionsException: ✽.When the 5 stars hotel filter is clicked(hotelSearches.feature:16) matches more than one step definition:
^the ([^\"]*) filter is clicked$ in HotelSearchesSteps.thePriceOrderFilterIsClicked(String)
^the ([^\"]*) stars hotel filter is clicked$ in HotelSearchesSteps.theStarStarsHotelFilterIsClicked(String)

最佳答案

异常(exception)情况非常明显:

“已点击 5 星级酒店过滤器”匹配

@When("^([^\\\"]*) 过滤器被点击$")

这似乎不是你的本意。也许将第一个表达式更改为:

@When("^点击 (\\d+) 星级酒店过滤器$")

对第二个表达式执行相同的操作。使其更具体。

关于java - cucumber AmbigouslyStepDefinitionsException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57616559/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com