ऊपर गहना के जवाब के अलावा के रूप में "ककड़ी वसंत" अपनी खुद की अतिरिक्त वसंत निर्भरता में जोड़ने के लिए भूल नहीं है सकते हैं विरूपण साक्ष्य केवल प्रदान की जा रहा है ककड़ी और वसंत के बीच "गोंद"।
मेरे मामले में मुझे निम्नलिखित अतिरिक्त निर्भरता के साथ मेरी चरण परिभाषाओं में काम करने के लिए स्प्रिंग इंजेक्शन मिला।
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
..... Plus the rest of the cucumber dependencies
मेरे चरण परिभाषा:
@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
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<import resource="classpath:applicationContext.xml"/>
</beans>
applicationContext.xml
012,
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="com.mypackage"/>
<bean id="propertiesPlaceholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="qa-test.properties"/>
</bean>
---- rest of my beans
</beans>
Autowiring वसंत के साथ ककड़ी-JVM में यहां से समझाया गया है - http://liminescence.blogspot.com/2013/08/integration-testing-with-spring.html – nilesh