我创建了黄瓜测试项目,并成功地配置了黄瓜- Guice对guice的支持。当我添加了宁静-黄瓜并使用CucumberWithSerenity配置测试运行程序时,我得到了一个错误:
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 class path.原因是有两个ObjectFactory实现:
有可能在黄瓜的同时使用宁静的黄瓜吗?
发布于 2015-03-12 14:24:29
根据宁静-黄瓜开发人员,我们不能使用Guice,而应该使用Spring。https://github.com/serenity-bdd/serenity-cucumber/issues/8
发布于 2017-04-10 08:04:21
可以通过在ObjectFactory中添加以下属性来选择src/test/resources/cucumber.properties实现
cucumber.api.java.ObjectFactory = cucumber.runtime.java.guice.impl.GuiceFactory来源:https://cucumber.io/blog/2015/07/08/polymorphic-step-definitions
请注意,您将放松Senerity Page特性。否则,您可以编写自己的ObjectFactory类,它实现了GuiceFactory和SerenityObjectFactory的特性。
https://stackoverflow.com/questions/29000685
复制相似问题