gpt4 book ai didi

java - 当其他步骤正常工作时,Cucumber java 会抛出单个未定义的步骤

转载 作者:行者123 更新时间:2023-12-01 19:24:04 24 4
gpt4 key购买 nike

我的功能文件中有以下步骤:

    Then Validate in total, how much is <firstCreditor> owed by everyone else. They are owed £<firstCreditorValue>

在我的步骤中定义类:

@Slf4j
@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT)
public class StepsDefinition {

@Then("^Validate in total, how much is (.+) owed by everyone else. They are owed £(.d)$")
public void validateCreditor1(String firstCreditor, double firstCreditorValue) throws Throwable {
}

我的规范类别:

package com.bsocial.integration;

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(
strict = true,
monochrome=true,
plugin = {"pretty", "html:build/cucumber-reports"},
tags = {"@myproject"},
features = {"classpath:features/IntegrationTestRequest.feature"}
)
public class IntegrationTestRequestSpecs {

}

我的 gradle 配置有:

    testCompile("io.cucumber:cucumber-core:${cucumberVersion}")
testCompile("io.cucumber:cucumber-java8:${cucumberVersion}")
testCompile("io.cucumber:cucumber-junit:${cucumberVersion}")
testCompile("io.cucumber:cucumber-spring:${cucumberVersion}")

其中cucumberVersion = '4.7.4'

但我仍然收到错误:

The step "Validate in total, how much is David owed by everyone else. They are owed £2225.50" is undefined
io.cucumber.junit.UndefinedThrowable: The step "Validate in total, how much is David owed by everyone else. They are owed £2225.50" is undefined

我在这里阅读了几篇关于此错误的帖子,但大多数似乎与胶水有关,就我而言,我确信它正在工作,因为这是唯一让我悲伤的步骤。

所有其他步骤都正常。我使用一个功能文件、一个 Spec 类和一个 StepsDefinition 类,所有这些都非常普通,因为我什至没有用我的类扩展或实现任何内容。

我有什么遗漏的地方吗?

最佳答案

结果发现问题出在我的 Steps 定义类中。

我已更改注释

    @Then("^Validate in total, how much is (.+) owed by everyone else. They are owed £(.d)$")

    @Then("^Validate in total, how much is (.*) owed by everyone else. They are owed £(.*)$")

注意:所有其他步骤都使用 (.+)(.d) 就可以了,只是这一步出现了这个问题。我什至想知道当我从 Word 复制该步骤时是否最终得到了一个不可见的字符,或者我有一些无效的特殊字符(例如 £)。我还认为也许,只是也许,然后有与其他注释不同的实现,并用 And 替换它,但没有运气。我不知道为什么或如何工作,但我确实查看了 Gherkin 正则表达式指南,但什么也没发现。也许有更好的线人可以告诉我问题是什么?

关于java - 当其他步骤正常工作时,Cucumber java 会抛出单个未定义的步骤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59328421/

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