I am using Cucumber to automate the testing of services and controllers in my app. In addition, I am using the Cucumber Junit runner @RunWith(Cucumber.class)
in the
I used cucumber-jvm to autowire Spring into Cucumber.
info.cukes
cucumber-core
1.1.5
test
info.cukes
cucumber-spring
1.1.5
test
info.cukes
cucumber-junit
1.1.5
test
And import applicationContext.xml into Cucumber.xml
// refer to appContext in test package
// scan package IT and StepDefs class
In CucumberIT.java call @RunWith(Cucumber.class)
and add the 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 { }
In CucumberStepDefs.java you can @Autowired
Spring
@ContextConfiguration("classpath:cucumber.xml")
public class CucumberStepDefs {
@Autowired
SpringDAO dao;
@Autowired
SpringService service;
}