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
In addition to Jewel's answer above do not forget to add in your own additional spring dependencies as "cucumber-spring" artifact seems to only provided the "Glue" between Cucumber and Spring.
In my case I got Spring Injection to work in my step definitions with the following added dependency.
org.springframework
spring-test
test
org.springframework
spring-core
org.springframework
spring-beans
org.springframework
spring-context
org.slf4j
slf4j-api
org.slf4j
jcl-over-slf4j
ch.qos.logback
logback-classic
test
..... Plus the rest of the cucumber dependencies
My Step Definition:
@ContextConfiguration("/cucumber.xml")
@PropertySource("classpath*:qa-test.properties")
public class StepsDefinition {
@Autowired
private ServiceToInject serviceToInject;
}
CukesRunner
@RunWith(Cucumber.class)
@CucumberOptions(format = { "pretty", "html:target/cucumber-html-report", "json:target/cucumber-json-report.json" })
public class CukesRunner {}
Cucumber.xml
applicationContext.xml
---- rest of my beans