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.

Cucumber-picocontainer fails to provide default constructors for String.

See original GitHub issue

When picocontainer tries to resolve the constructor for the class String it detects that there are multiple satisfiable constructors.

I am using picocontainer to resolve dependencies for Steps and Hooks. One of my Steps has constructor which takes a String as parameter.

This problem also happens with other classes like Integer, Double, Float, Boolean, etc.

Version: 1.2.5-SNAPSHOT Module: cucumber-picocontainer Command: Running tests Output: 3 satisfiable constructors is too many for ‘class java.lang.String’. Constructor List:[<init>(<init>Buffer), <init>(<init>Builder), <init>()] Pull Request: #1045 Steps to reproduce: Add the following test in PicoFactoryTest and run it.

@Test
    public void shouldGetStringInstance() {
        // Given
        ObjectFactory factory = new PicoFactory();
        factory.addClass(String.class);

        // When
        factory.start();
        String str = factory.getInstance(String.class);

        // Then
        assertNotNull(str);
    }
'''

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mlvandijkcommented, Nov 8, 2017

From the discussion on gitter (edited for brevity; you can find the full discussion on gitter: https://gitter.im/cucumber/cucumber-jvm) -

Aslak Hellesøy @aslakhellesoy Aug 13 2016 00:00 that’s PicoContainer saying "I don’t know what string to pass in here - let me see if I can construct one myself from the other components I know about. And then it blows up because it has too many choices. Did you consider where that string constructor argument would come from? [edited] Aslak Hellesøy @aslakhellesoy Aug 13 2016 09:10 I don’t think pico should make up primitive values to satisfy your constructors. Provide empty constructors instead, delegating to your string constructor. [edited] Alonso A. Ortega @alayor Aug 14 2016 02:10 [edited] I understand the this is not a common problem for many people, so for the time being I’ll use a default constructor.

0reactions
lock[bot]commented, Nov 9, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

cucumber/cucumber-jvm - Gitter
I don't think pico should make up primitive values to satisfy your constructors. Provide empty constructors instead, delegating to your string constructor.
Read more >
Dependency Injection - Cucumber Pico Container
In your step definition class , create a constructor and instantiate the baseFoundation object with the context.
Read more >
Using Dependency Injectors to Simplify Your Code in Cucumber
One major thing to note is that both Controller and User don't have constructors. This is important, as otherwise, PicoContainer would not ...
Read more >
Sharing state between steps in Cucumber-JVM using ...
Using PicoContainer to share state between steps in a scenario is easy and non intrusive. All you need is a constructor that requires...
Read more >
Cucumber .Hoook class is throwing errors due to not having ...
I get the non empty constructor error, as above. Regarding the cucumber-picocontainer on the classpath approach, I have created an ...
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