Problem:
I have earlier created automation test framework with cucumber-jvm(java) and Spring
I now want to convert into cucumber groovy , convert all code into groovy and use Spring with annotation like @Autowired, @Value
Earlier my all Cucumber Steps classes(java) used to extend BaseStep which has Spring components like mentioned below
Sample Base Step class
@ContextConfiguration(locations = {"classpath:cucumber.xml"})
public abstract class BaseStep {
@Autowired
protected ScenarioSession scenarioSession;
public static final String TIME_STAMP = new SimpleDateFormat("yyyyMMddHHmmsss").format(new Date());
public static final String VERSION = "999";
public static final int TIN_IN_SECS = 10;
// Environment name like QA, Stage, Dev etc
@Value("${env.name}")
public String env;
public ScenarioSession getScenario() {
return scenarioSession;
}
}
1. Above ScenarioSession is singleton object shared across various steps to share data between steps and also share state of webdriver/selenium state
2. @Value use to retrieve test environment name from property file
3 Environment related configuration parameter like baseUrl, userName and password read from property file e.g Dev.properties, Stage.properties, Prod.properties.
environment is specified from command line .eg mvn clean test -DEnv=Dev
4. Cucumber.xml has following
<context:component-scan base-package="com.company.prooject.protests"/>
<context:property-placeholder location="classpath:env/${Env}.properties"/>
<context:annotation-config />
<bean class="org.springframework.beans.factory.config.CustomScopeConfigurer">
<property name="scopes">
<map>
<entry key="cucumber-glue">
<bean class="cucumber.runtime.java.spring.GlueCodeScope"/>
</entry>
</map>
</property>
</bean>
Question:
1. As Cucumber groovy Step is DSL script without class. It can not extend equivalent Base Common Step Class, How to share singleton common ScenarioSession Object with various groovy Step file
2. How to inject various configuration parameter with the help of Spring @Value in Step class? When I added @Autowired or @Value in Step class. It says "not applicable to local variable"
3. How to inject various property read from properties file into step file with help of Spring
Thanks
Mohan
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.