Skip to content
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

Step definition constructor injection #37

Merged
merged 7 commits into from
Sep 9, 2011
Merged

Step definition constructor injection #37

merged 7 commits into from
Sep 9, 2011

Conversation

jbandi
Copy link

@jbandi jbandi commented Sep 7, 2011

Registering classes that are constructor arguments of step definition classes into the object-factory. This enables injecting pure pojos into step definition classes.

@aslakhellesoy aslakhellesoy merged commit d9de90e into cucumber:master Sep 9, 2011
@mattnathan
Copy link
Contributor

This change introduces a number of problems when using Guava to inject dependencies.

The error I get is:

WARNING: Cucumber/Guice could not create instance for byte[]:
Guice configuration errors:

1) No implementation for byte[] was bound.
  while locating byte[]

1 error
WARNING: Cucumber/Guice could not create instance for char[]:
Guice configuration errors:

1) No implementation for char[] was bound.
  while locating char[]

1 error
WARNING: Cucumber/Guice could not create instance for int:
Guice configuration errors:

1) Could not find a suitable constructor in java.lang.Integer. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private.
  at java.lang.Integer.class(Integer.java:37)
  while locating java.lang.Integer

1 error
WARNING: Cucumber/Guice could not create instance for int[]:
Guice configuration errors:

1) No implementation for int[] was bound.
  while locating int[]

1 error
WARNING: Cucumber/Guice could not create instance for java.lang.CharSequence:
Guice configuration errors:

1) No implementation for java.lang.CharSequence was bound.
  while locating java.lang.CharSequence

1 error
WARNING: Cucumber/Guice could not create instance for java.nio.charset.Charset:
Guice configuration errors:

1) No implementation for java.nio.charset.Charset was bound.
  while locating java.nio.charset.Charset

1 error

The reason for the error is the recursive addition of all constructor arguments to the objectFactory. This should not happen. If anything the addition of constructor arguments should be an implementation detail of whichever ObjectFactory you are using.

@mattnathan
Copy link
Contributor

Should note that there is a workaround: where I have a class being injected into a constructor I could replace it with an interface and specify a binding in my Guice module. I'd prefer not to do this though.

@aslakhellesoy
Copy link
Contributor

@mattnathan please open a new ticket for this. This pull request is closed, and cannot be reopened.

@mattnathan
Copy link
Contributor

Will do

@lock
Copy link

lock bot commented Oct 25, 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.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants