Cucumber-guice Injector specified with the runners properties
See original GitHub issueSummary
I would like to be able to specify the Injector I want to use inside the CucumberOptions
annotation on my runner file. This way I don’t have to create a separate property file for the module.
This is a problem for me since i want to several separate Injectors in the same module
Current Behavior and Expected Behavior
For custom injectors we are required to create a properties file at the root of the
classpath. and specify one property in it .
guice.injector-source=
Possible Solution
@CucumberOptions(guice.injector-source = "...", ...)
public class Runner {
}
Context & Motivation
- I am using cucumber to perform my integration test.
- I want to test the same feature in multiple different enviorments which require different configs.
- I was planning on using different runners to set up and instantiate the different environments like This is what i am doing now
import org.junit.BeforeClass;
//So i can test against other service that are deployed
public class DeployedTest {
@beforeClass
public static before() {
//start server
Config config = new config(...);
Steps.setup(config) //sets up a static the static variables in my step files
}
}
and
import org.junit.BeforeClass;
//so i can test against mock services
public class LocalTest {
@beforeClass
public static before() {
//mock other services
//start server
Config config = new config(...);
Steps.setup(config) //sets up a static the static variables in my step files
}
}
I would really like if i didn’t have to set static variables in my test because i feel like that is a bad practice. And to resolve that I would like to setup and specify what injector to use with my Runner.
P.S. If having multiple runners is also a bad practice I would be interested to here others way around this problem
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (5 by maintainers)
Top GitHub Comments
Sounds like a good idea. A few caveats:
--junit
. This should eventually be solved by creating different annotations for junit and testing.So instead of adding a guice specific option it might be better to create an option to set environment properties. Equivalent to Javas
-Dkey=value
.The environment variables override cucumber options. This should be reversed and would be a major breaking change but a good one none the less.
Making the properties file used configurable through a config parameters would also help e.g.
--settings=cucumber. properties
.The order of precedence should be
--property key=value
1b.--settings cucumber. properties
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.