I have an application that has been tested with Cucumber, but since the upgrade (Cucumber 1.1.6 to 1.2.5, java 1.6 to 1.8, Spring 3.2.0 to 4.2.6) it no longer works because it complains about Annotations differs on glue classes found
The structure is as follows:
- Some common steps requiring property values
- More specific steps requiring some
@ContextConfiguration
Both of them must also share a bean.
The common part will never start on its own. But I have several tests, each of which uses its own special steps. Now he refuses to run due Annotations differs on glue classes found.
Is there a way to make this work without polluting the general context with the specifics of a particular context?
Step Definitions:
@ContextConfiguration("classpath:cucumber-common.xml")
public class CommonStepdefs {
@Autowired
private SharedBean sharedBean;
@Value("${some.property}")
private String someProperty;
}
@ContextConfiguration("classpath:cucumber-concrete.xml")
public class ConcreteStepdefs {
@Autowired
private SharedBean sharedBean;
@Autowired
private OtherBean otherBean;
}
Spring general configuration:
<?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:property-placeholder location="classpath:com/example/cucumber-common.properties"/>
<context:spring-configured/>
<context:annotation-config/>
<bean id="glueCodeScope" class="cucumber.runtime.java.spring.GlueCodeScope"/>
<bean id="glueCodeScopeConfigurer" class="org.springframework.beans.factory.config.CustomScopeConfigurer">
<property name="scopes">
<map>
<entry key="cucumber-glue" value-ref="glueCodeScope"/>
</map>
</property>
</bean>
<bean id="sharedBean" class="com.example.SharedBean" scope="cucumber-glue"/>
</beans>
Another Spring configuration (which imports the generic):
<?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">
<import resource="classpath:cucumber-common.xml"/>
<context:spring-configured/>
<context:annotation-config/>
<context:component-scan base-package="com.example.rest"/>
</beans>
Tests are performed using:
@RunWith(Cucumber.class)
@CucumberOptions(
format = { "html:target/cucumber-html-report", "json:target/cucumber-json-report.json" },
glue = { "com.example.common", "com.example.concrete" },
monochrome = true,
strict = true)