我的功能文件中包含以下步骤:
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 {
}
我的Spec类:
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类,它们都非常有用,因为我什至没有在类中扩展或实现任何东西。
有什么我想念的东西吗?
答案 0 :(得分:0)
原来问题出在我的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 regex指南,却一无所获。也许有人更好的告密者可以告诉我问题出在哪里?