I have a Cucumber/Java project whose glue package is x.y.z
test.resources.features/dropDatabaseFeature.feature which makes use of methods in the corresponding java steps code dropDatabaseSteps.java
test.resources.features/transferFileFeature.feature which makes use of methods in the corresponding java steps code transferFileSteps.java
At test.java.x.y.z.databaseSteps/dropDatabaseSteps.java I use @ContextConfiguration=CucumberConfig.class
At test.java x.y.z.fileSteps/transferFileSteps.java I use @ContextConfiguration=CucumberConfig.class
and get an error saying both classes attempt to configure the spring context. If only 1 class has the @ContextConfiguration=CucumberConfig.class it works ok.
Since I do not want to hide the SpringContext setup in any one feature file, since I will eventually have many, I created test.java.x.y.z.SpringContextSetup.java, and empty class which had @ContextConfiguration=CucumberConfig.class before the class statement. This resulted in nullPointerException for the injected objects, so the Spring container config was not being configured. Why is this? It because there's no features file using the SpringContextSetup class and so the class is not being loaded at runtime?