我用黄瓜jvm将Spring自动接线到黄瓜中。
<dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-core</artifactId> <version>1.1.5</version> <scope>test</scope> </dependency> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-spring</artifactId> <version>1.1.5</version> <scope>test</scope> </dependency> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-junit</artifactId> <version>1.1.5</version> <scope>test</scope> </dependency>
并将applicationContext.xml导入Cucumber.xml
<import resource="/applicationContext.xml" /> // refer to appContext in test package<context:component-scan base-package="com.me.pos.**.it" /> // scan package IT and StepDefs class
在CucumberIT.java中,调用
@RunWith(Cucumber.class)并添加
CucumberOptions。
@RunWith(Cucumber.class)@CucumberOptions( format = "pretty", tags = {"~@Ignore"}, features = "src/test/resources/com/me/pos/service/it/" //refer to Feature file)public class CucumberIT { }在CucumberStepDefs.java可以
@Autowired春
@ContextConfiguration("classpath:cucumber.xml")public class CucumberStepDefs { @Autowired SpringDAO dao; @Autowired SpringService service;}


