-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cucumber with Spring issue #786
Comments
@Sonali77, thank you for report. Actually, the case is different, because the fluentlenium-cucumber does not use Spring or Guice dependencies at all. I have implemented special ObjectFactory for FL and this is the reason why Cucumber says there are few Object Factories. The FluentObjectFactory was created to handle creating instances and injecting FluentLenium context into step definitions classes. You can check the mentioned class here: https://github.com/FluentLenium/FluentLenium/blob/develop/fluentlenium-cucumber/src/main/java/cucumber/runtime/java/fluentlenium/FluentObjectFactory.java |
Basically i am getting this for my Spring related tests. I have defined one step def as below- } The other step definitions doesn't have the - I also have other stepdefinitions where Before and After hooks defined for all step defs. This error is even present there. Please let me know, if i need to do something different now. |
We have added before and after hooks in all of our step definitions which run UI tests(which uses Fluentlenium). Additionally, we also have spring related tests, where we initialize spring context with only one step definition class-
We use Spring's context for both API testing (doesn't extend FluentCucumberTest) and UI testing (does extend FluentCucumberTest). |
Thank you for this input - I will try to find workaround for this matter and back to you with the anwser. |
@Sonali77,
Your BaseTest should inherit after you.package.FluentCucumberTest. |
I will test your suggestion and let you know the update. Just to let you know, we use Spring, Cucumber, Fluentlenium in our project. Also we would like to use Single step definition class with a before and after hook in our project, instead of adding to each step definition class. I work with Rich, who opened the below issue - We would like to have one step def to have before and after hook, instead of all. Before and After hook in all step definition classes will instance all step definiton files for every scenario regardless if they are used or not within the test. |
I tested your suggestion. It works but its the same as fluentlenium 3.7.1 and is not solving the issue if multiple step definition and also need to have my own FluentCucumberTest. So it does not make sense to make an upgrade to fluentlenium 3.8.1. |
Hi,
Initially we used fluentlenium 3.7.1,cucumber 3.0.2 , Spring 4 (Jdk 1.8) and our cucumber tests(using spring 4) seemed to work fine. Now we upgraded to fluentlenium 3.8.1,cucumber 4.2.6(Keeping back Spring 4 and JDk 1.8) and or cucumber tests (using spring 4) is having the below error-
Expected only one instance, but found too many: [cucumber.runtime.java.spring.SpringFactory@29372, cucumber.runtime.java.fluentlenium.FluentObjectFactory@3b3b2f]
More than one Cucumber ObjectFactory was found in the classpath
You probably may have included, for instance, cucumber-spring AND cucumber-guice as part of
your dependencies. When this happens, Cucumber falls back to instantiating the
DefaultJavaObjectFactory implementation which doesn't provide IoC.
In order to enjoy IoC features, please remove the unnecessary dependencies from your classpath.
I tried excluding cucumber-guice in my POM.xml but still i am getting this error. Not sure if some other API also have this as a transitive dependency.
Please let me know, the possible solution for the same.
Regards,
Sonali
The text was updated successfully, but these errors were encountered: