On Wed, 30 Apr 2014, at 04:52 AM, Roberto Lo Giacco wrote:
I'm already working on this, aiming at using spring framework bean
initialization procedure: something I never didi before but I'm pretty
sure is somewhere in there :)
Cool!
On Wed, Apr 30, 2014 at 11:46 AM, Seb Rose <[1]seb-4t77m37/***@public.gmane.org>
wrote:
On Tue, 29 Apr 2014, at 02:12 AM, Roberto Lo Giacco wrote:
Il giorno marted� 29 aprile 2014 11:02:41 UTC+2, Roberto Lo Giacco ha
scritto:
Il giorno marted� 29 aprile 2014 07:27:18 UTC+2, Seb Rose ha scritto:
I've been trying to understand the Cucumber/Spring integration (helped
massively by Paolo) and have hit an issue. Everything's working fine
for field injection, but soon as I switch to constructor injection I
get the following error:
cucumber.runtime.CucumberException: wrong number of arguments
at
cucumber.runtime.java.spring.SpringFactory.getTestInstance(SpringFactor
y.java:162)
at
cucumber.runtime.java.spring.SpringFactory.getInstance(SpringFactory.ja
va:142)
at
cucumber.runtime.java.JavaStepDefinition.execute(JavaStepDefinition.jav
a:35)
I've put an example on github
at [2]https://github.com/sebrose/spring-dummy.git
How should it work? Should it work? Will it work?
having a look right now, but from the exception I would say the
cucumber.runtime.java.spring.SpringFactory is not querying the Spring
Context for a bean instance, instead it is instantiating one and then
asking Spring to "populate" it's dependencies.
I confirm it is relative to Cucumber Spring implementation: we
instantiate a step definition by instantiating it's no argument
constructor: if that's missing, like in your example, then you get that
error.
I wouldn't consider this a major issue, it might even be considered
good practice to have no argument constructors. There is a solution to
this, but it has to be applied withing the SpringFactory class.... Do
we want to support this?
While I agree that this is not a major issue, it does make the
Cucumber-Spring integration different from all the other integrations.
PicoContainer instantiates non-default steps out of the box.
Guice and Weld require an @Inject annotation on the relevant
constructor, but it's exactly the same annotation as you would use for
field injection.
EITHER:
public class MySteps {
@Inject
private MyData myField;
// snip
}
OR:
public class MySteps {
private MyData myField;
@Inject
public MySteps(MyData data) { myField = data; }
// snip
}
Shouldn't we aim for the same behaviour in the Spring integration?
Cheers
Seb
--
Posting rules: [3]http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google
Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [4]cukes+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit [5]https://groups.google.com/d/optout.
--
Posting rules: [6]http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to a topic in the
Google Groups "Cukes" group.
To unsubscribe from this topic, visit
[7]https://groups.google.com/d/topic/cukes/q95I0s1r80g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
[8]cukes+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit [9]https://groups.google.com/d/optout.
--
Posting rules: [10]http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google
Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [11]cukes+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit [12]https://groups.google.com/d/optout.
References
1. mailto:seb-4t77m37/***@public.gmane.org
2. https://github.com/sebrose/spring-dummy.git
3. http://cukes.info/posting-rules.html
4. mailto:cukes+unsubscribe-/***@public.gmane.org
5. https://groups.google.com/d/optout
6. http://cukes.info/posting-rules.html
7. https://groups.google.com/d/topic/cukes/q95I0s1r80g/unsubscribe
8. mailto:cukes+unsubscribe-/***@public.gmane.org
9. https://groups.google.com/d/optout
10. http://cukes.info/posting-rules.html
11. mailto:cukes+unsubscribe-/***@public.gmane.org
12. https://groups.google.com/d/optout
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/d/optout.