Ok, I see.
What tricked me is that I first used a composite step more along the line
@Given("users logs on")
@Composite(steps = {
"Given that user Agatha has logged in",
"When the user logs out",
"When user Charlie has logged in",
"When the user logs out",
"When user Dickens has logged in",
"When the user logs off,"
"When Agatha user has logged in",
"When the user logs off"})
public void logTest(@Named("userId")
String userId) throws Exception {
}
Which successfully sent Agatha, Charlie and Dickens as the user Ids to the
login step.
So I assumed (you should never assume, right) I could get away with
parameterizing the composite step.
I'll change my setup :)
Thanks a lot,
Christian
Christian Karlsson
CAG Contactor AB
Adress: Jan Stenbecks Torg 17, SE-164 40 Kista
Mobil: +46 (0)706694527
Mail: christian.karlsson <at> cag.se
www.cag.se<https://wmail.cag.se/owa/redir.aspx?C=G2EjVQkj7kGZyieqy24uGB6NV2uAkM9Iy3xqV4cZFUaEVGXCGlWIq_V5O25t1jIUtjHgAaGFl0U.&URL=http%3a%2f%2fwww.cag.se%2f>
Från: Mauro Talevi [mailto:[email protected]]
Skickat: den 23 april 2013 09:25
Till: [email protected]
Ämne: Re: [jbehave-user] Using composite steps
Ahhh, now I understand :-) No, it's not going to work that way. Composite
steps can only use "parametrised" data. In other words, these steps are not
re-parsed to extract the parameter values.
So you need to use @Named("userId") in all composite steps that need the
parameter originally parsed in the composing step. Make sense?
On 23/04/2013 08:48, Karlsson Christian wrote:
Well
When the third step is executed (when user Charlie has logged in) I expected
'Charlie' to be passed as $userId in the step @When("user $userId has logged
in")
My use case is that I have some managers (Charlie and dickens) that always have
to approve a step each in the workflow but I use different users to administer
the first actions.
But I guess I can hard code it in if there's no other way.
Thanks for quick response.
Regards
Christian Karlsson
från min iPhone
22 apr 2013 kl. 22:24 skrev "Mauro Talevi"
<[email protected]<mailto:[email protected]>>:
Hi,
well, what other behaviour did you expect?
The intended one is that if you provide some parameters to the composing step,
these parameter values are passed to the composite steps (where appropriate).
So you should userId=Agatha passed to the steps that declare the
@Named("userId").
If you provide a working example project, we can investigate further.
Cheers
On 22/04/2013 18:23, Karlsson Christian wrote:
Hello
I'm trying to use composite steps in my scenarios. Right now I'm facing a
situation I can't get to work and I wonder if I'm doing it wrong or if my use
case is out of scope.
Reproducing steps:
@Given("user $userId logs on first")
@Composite(steps = {
"Given that user <userId> has logged in",
"When the user logs out",
"When user Charlie has logged in",
"When the user logs out",
"When user Dickens has logged in",
"When the user logs off,"
"When <userId> user has logged in",
"When the user logs off"})
public void logTest(@Named("userId")
String userId) throws Exception {
}
@Given("that user <userId> has logged in")
@When("user $userId has logged in")
public void login(@Named("userId")
String userId) throws Exception {
}
Scenario: Test composite steps
Given user Agatha logs on first
I get user "Agatha" as the userId in all my steps. Is that the intended
behavior?
Regards,
Christian
Christian Karlsson
CAG Contactor AB
Adress: Jan Stenbecks Torg 17, SE-164 40 Kista
Mobil: +46 (0)706694527
Mail: christian.karlsson <at> cag.se<http://cag.se>
www.cag.se<https://wmail.cag.se/owa/redir.aspx?C=G2EjVQkj7kGZyieqy24uGB6NV2uAkM9Iy3xqV4cZFUaEVGXCGlWIq_V5O25t1jIUtjHgAaGFl0U.&URL=http%3a%2f%2fwww.cag.se%2f>