question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CustomPicoFactory Not getting picked after upgrading to io.cucumber versions 4.7.2

See original GitHub issue

Tried above mentioned solution. Cucumber runner is not picking CustomPicoFactory I am not using DynamicBrowserManager at this moment because I am writing BDD for REST API’s

public class CustomPicoFactory implements ObjectFactory {
    private PicoFactory delegate = new PicoFactory();

    public CustomPicoFactory() {
       addClass(SomeImplementation.class)
    }

    @Override
    public void start() {
        delegate.start();
    }

    @Override
    public void stop() {
        delegate.stop();
    }

    @Override
    public boolean addClass(Class<?> aClass) {
        return delegate.addClass(aClass);
    }

    @Override
    public <T> T getInstance(Class<T> aClass) {
        return delegate.getInstance(aClass);
    }
}

Even added entry of CustomPicoFactory to cucumber.properties No error while running feature files Logs

INFO: Loading ObjectFactory via service loader: io.cucumber.picocontainer.PicoFactory

Cucumber Version = 4.7.2

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
toepicommented, Oct 17, 2019

FQN = Full Quallified Name

Given your packages is com.example and your custom Objectfactory has CustomPicoFactory as classname then the fqn is com.example.CustomPicoFactory

The shown service-descriptor is for the default picofactory. You need your own io.cucumber.core.backend.ObjectFactory in your jar.

0reactions
LearningPurcommented, Nov 17, 2019

After upgrading pico-container version 5.0.0-RC1 from 1.2.5 i have started getting error message and desperately looking for help as our current production code is failing due to this migration.

Any help asap would be appreciated.

Maven pom.xml change

Upgraded from this info.cukes cucumber-picocontainer 1.2.5

To this io.cucumber cucumber-picocontainer 5.0.0-RC1 test

I am creating an instance of page class during runtime using these 4 list of classes

Basepage.java

public class BasePage {

public static HomePage goToHomePage(Scenario scenario, String UserEmailID) {

    Selenide.refresh();
    if (WebDriverRunner.url().equalsIgnoreCase("https://www.footlocker.com/")) {
   }
    return page(HomePage.class);
}

}

BaseSteps.java

import io.cucumber.java8.En; import org.picocontainer.annotations.Inject;

public class BaseSteps implements En {

@Inject
private PageContainer pageContainer;

protected void update(BasePage newPage) {
    pageContainer.updatePage(newPage);
}

protected BasePage page() {
    return pageContainer.getPage();
}

}

PageContainer.java

public class PageContainer {

private BasePage currentPage;

public void updatePage(BasePage newPage) {
    currentPage = newPage;
}

public BasePage getPage() {
    return currentPage;
}

}

PicoDependencyInjector.java

import io.cucumber.core.backend.ObjectFactory; import io.cucumber.picocontainer.PicoFactory;

public class PicoDependencyInjector implements ObjectFactory {

private PicoFactory delegate = new PicoFactory();

public PicoDependencyInjector() {
    addClass(PageContainer.class);
}


@Override
public void start() {
    delegate.start();
}

@Override
public void stop() {
    delegate.stop();
}

@Override
public boolean addClass(Class<?> aClass) {
    return delegate.addClass(aClass);
}

@Override
public <T> T getInstance(Class<T> aClass) {
    return delegate.getInstance(aClass);
}

}

cucumber.properties

io.cucumber.core.backend.ObjectFactory = com.footlocker.core.PicoDependencyInjector

Error i am getting is

org.picocontainer.injectors.AbstractInjector$UnsatisfiableDependenciesException: com.footlocker.steps.RegisterMultiUserSteps has unsatisfied dependency for fields [com.footlocker.core.PageContainer.pageContainer] from org.picocontainer.DefaultPicoContainer@661972b0:5<|

at org.picocontainer.injectors.AbstractFieldInjector.unsatisfiedDependencies(AbstractFieldInjector.java:30)
at org.picocontainer.injectors.IterativeInjector.getMatchingParameterListForSetters(IterativeInjector.java:104)
at org.picocontainer.injectors.IterativeInjector.access$000(IterativeInjector.java:33)
at org.picocontainer.injectors.IterativeInjector$2.run(IterativeInjector.java:153)
at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
at org.picocontainer.injectors.IterativeInjector.getComponentInstance(IterativeInjector.java:160)
at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:678)
at io.cucumber.picocontainer.PicoFactory.getInstance(PicoFactory.java:47)
at io.cucumber.java8.Java8Backend.buildWorld(Java8Backend.java:62)
at io.cucumber.core.runner.Runner.buildBackendWorlds(Runner.java:165)
at io.cucumber.core.runner.Runner.runPickle(Runner.java:61)
at io.cucumber.junit.PickleRunners$NoStepDescriptions.run(PickleRunners.java:149)
at io.cucumber.junit.FeatureRunner.runChild(FeatureRunner.java:83)
at io.cucumber.junit.FeatureRunner.runChild(FeatureRunner.java:24)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at io.cucumber.junit.Cucumber.runChild(Cucumber.java:174)
at io.cucumber.junit.Cucumber.runChild(Cucumber.java:82)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at io.cucumber.junit.Cucumber$RunCucumber.evaluate(Cucumber.java:208)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Cucumber V4 [io.cucumber] is not identifying @Given/When ...
I have resolved the issue and sharing correct set of dependency. Please add JUnit/TestNG based on your framework requirement.
Read more >
Using Dependency Injectors to Simplify Your Code in Cucumber
At their core, Dependency Injectors (DIs) are about being able to extend an object's behavior at runtime by injecting business logic.
Read more >
Upgrading - Cucumber Documentation
We try to add new features to Cucumber periodically. This means you may want to upgrade to a newer version to take advantage...
Read more >
Getting started with Cucumber in Java — A 10 minute tutorial
Create a Maven project · Click the menu option File > New > Project · In the New project dialog box, select Maven...
Read more >
Deprecated List (Cucumber-JVM: Core 4.7.2 API) - javadoc.io
as of version 4.0.0; use EventListener and Plugin instead. ... in favor of StepDefinedEvent , as Lambda Step Definitions are not reported through...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found