Hi, 

The context is a user defined object so it is not known to JBehave.

If you want to inject parameters in methods you could use the @Named 
annotation, specifying the name-value pairs in the Meta: section.

That said, it's not clear why you'd want to do this, as the values of the 
Context will be already accessible without injection in the signature.

Could you explain your usecase better?

> On 17 May 2016, at 20:05, Laura Ruiz <laura.rli...@gmail.com> wrote:
> 
> Hi there,
> 
> I'm currently working with JBehave and we implemented a Context object where 
> we store data that we need to share between different steps.
> 
> Now, we are considering some improvements on this, like explicitly passing 
> this data to the methods that implement these steps.
> 
> Imagine you have a first step which will create a user and store its 
> credentials into the Context.
> These credentials are needed in the second step. We would like to have some 
> kind of annotation that allowed us to implement our step like this:
> 
> @When("...some step definition which includes some $parameterFromStep")
> public void someMethod(String parameterFromStep, 
> @FromContext("userCredentials") String userCredentials) { ... }
> 
> 
> We tried to implement some logic that would take the parameter from the 
> Context and pass it to the method. The problem with this is that JBehave 
> doesn't find a method matching this step, as the method has the wrong number 
> of parameters (it expects 1 but the method has 2).
> 
> So my question is: Is there any way of doing this with the current 
> implementation? Is there any way to force JBehave, for example, ignore the 
> parameters that are annotated?
> 
> I would really appreciate some guidance on this. Let me know if something is 
> something needs extra clarifications, please.
> 
> Thank you guys.
> -- 
> You received this message because you are subscribed to the Google Groups 
> "JBehave User" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to jbehave-user+unsubscr...@googlegroups.com.
> To post to this group, send email to jbehave-user@googlegroups.com.
> To view this discussion on the web, visit 
> https://groups.google.com/d/msgid/jbehave-user/0fae230a-b5f6-4dc8-95ff-d3f4bb500ad1%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"JBehave User" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jbehave-user+unsubscr...@googlegroups.com.
To post to this group, send an email to jbehave-user@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/jbehave-user/893CB175-7C99-4E67-B557-9C78294B57ED%40aquilonia.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to