Question

We are using Cucumber JVM for Scala and as the application grows it would be nice to cucumber-guice in the picture as well.

The problem is that I can't see any useable examples/tutorials/documentation on how to do it.

I do have a working @RunWith(classOf[Cucumber]) RunCukesTest class, which kicks off, finds the .feature files, and the StepDefinition classes. The problem is that this Cucumber class instantiates step definitions without Guice, and all my injections stay null, causing my tests to fail.

Maybe there is a way to configure Cucumber to use GuiceFactory and cucumber-guice.properties like in Configuring cucumber-guice?

Était-ce utile?

La solution

I tried to figure out how this may work with the cucumber-scala library. While browsing the sourcecode I got the imression that dependency injection is not designed in that library. Unfortunately this was affirmed by the following discussion:

https://github.com/cucumber/cucumber-jvm/issues/469

There might be a way to add the dependencies using the cake pattern...

Autres conseils

I am successfully using Guice with cucumber-jvm. Cucumber natively supports guice. This is my setup- I have my Module defined in cucumber-guice.properties contents of which look like guiceModule=com.ios.app.modules.TestModule. cucumber-guice.properties is placed under src/test/resources folder. I think you would also need this dependency below,

<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-guice</artifactId>
    <version>1.1.2</version>
</dependency>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top