我不确定自己做错了什么。通过Cucumber测试类运行时,Spring没有加载bean。 我运行CucumberTestSuite。
我不使用spring-boot,仅使用spring 5。
我已经具有这些依赖项
<junit.version>5.3.2</junit.version>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-spring</artifactId>
<version>1.2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
@ContextConfiguration(classes = {BaseIT.TestConfiguration.class})
public class BaseIT {
@Configuration
@ComponentScan(
basePackages = {"com.test.integration"}
)
public static class TestConfiguration {
}
}
@RunWith(Cucumber.class)
@CucumberOptions(
features = "classpath:features",
glue = "com.test.service"
)
public class CucumberTestSuite {
}
@RunWith(SpringRunner.class)
public class CucumberStepDefinition extends BaseIT {
@Autowired
private SomeClass someClass ;
@Given("^the following attributes are available for the :$")
public void the_following_attributes_are_available_for_the(Map<String, String>
}
}