Spring boot @给定或@When cucumber的注释抛出与spring引导配置相关的错误
我正在编写BDD测试用例Spring boot @给定或@When cucumber的注释抛出与spring引导配置相关的错误,spring-boot,cucumber,bdd,Spring Boot,Cucumber,Bdd,我正在编写BDD测试用例 cucumber的所有依赖项都包含在pom.xml中 <dependency> <groupId>io.cucumber</groupId> <artifactId>cucumber-java</artifactId> <version>${cucumber.version}</version> <scope>t
cucumber的所有依赖项都包含在pom.xml中
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-spring</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.trivago.rta</groupId>
<artifactId>cluecumber-report-plugin</artifactId>
<scope>test</scope>
<version>2.3.3</version>
</dependency>
我得到一个错误-
当我运行测试时mvn -DAccessProfileFeatureBDDTest clean test
java.lang.IllegalStateException:找不到@SpringBootConfiguration,您需要在测试中使用@ContextConfiguration或@SpringBootTest(类=…)
mvn -DAccessProfileFeatureBDDTest clean test
如果我在步骤定义文件中注释@Given子句,那么我不会得到与@SpringBootConfiguration相关的错误
其他文件。在下面
package com.igtb.dcp.cbxaccessprofile.bdd;
import org.junit.runner.RunWith;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
@RunWith(Cucumber.class)
@CucumberOptions(features = "src/test/resources/features/accessprofile/", plugin = {
"json:target/cucumber-report/cucumber.json", "com.igtb.dcp.cbxaccessprofile.bdd.TestInitialization" })
public class AccessProfileFeatureBDDTest {
}
accessprofile.feature具有该功能,并包含在src/test/resources/features/accessprofile/文件夹中
如果我在步骤定义文件中注释@Given子句,那么我不会得到与@SpringBootConfiguration相关的错误
如果在使用上下文配置注释的类中没有步骤定义,Cucumber将根本检测不到任何上下文配置,并返回到GenericaApplicationContext
有了这个错误,Spring告诉您,@SpringBootTest
找不到任何用于构建应用程序上下文的配置
您必须显式引用用@SpringBootconfiguration
注释的类,或者确保@springbootcapplication
注释的类位于同一个包中,或者将@ContextConfiguration
注释添加到AccessProfileStepDefinition
中
java.lang.IllegalStateException: Unable to find a
@SpringBootConfiguration, you need to use @ContextConfiguration or
@SpringBootTest(classes=...) with your test