Cucumber-picocontainer fails to provide default constructors for String.
See original GitHub issueWhen 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:
- Created 7 years ago
- Comments:12 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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.