Thanks Mauro, I am so happy to be a subscriber of this form as I always learn something new each day! I was not aware that you can do this:
Given I have a first line
followed by a second one
both part of the same step
@Given("I have a first line\nfollowed by a second one\nboth part of the same
step")
That is great news and I will start using as I am writing this. A pity intelij
plugin does not like it but I can live with this or try it in eclipse.
However from the purpose I described earlier, being able to add those 'And'
synonyms would still be a good to have thing. Without that even if you now can
achieve natural sounding stories with multi line steps you will still have to
implement those steps with too many arguments. The synonyms would help us have
a better separations of steps.
Cheers,
Julian
--- On Wed, 13/2/13, Mauro Talevi <[email protected]> wrote:
From: Mauro Talevi <[email protected]>
Subject: Re: [jbehave-user] User defined keyword
To: [email protected]
Received: Wednesday, 13 February, 2013, 2:14 AM
That's not possible as JBehave parsing
is not done not by line but by keyword. This allows for
multiple-line steps.
The And keyword identifies a new step of the same time of the
preceding, which may or may not be over multiple lines.
On 11/02/2013 22:13, Iulian Greculescu wrote:
About point 2.
Actually we don’t even need to define
“And” synonyms and we
just adopt the convention that if a step has none of the
“Given/When/Then/And” keywords
in front then by default is should be considered an
“And”. I don’t think this
would be hard to implement and in my opinion would make
our stories really
sound natural.
Cheers,
Julian
--- On Tue, 12/2/13, Mauro Talevi <[email protected]>
wrote:
From: Mauro Talevi <[email protected]>
Subject: Re: [jbehave-user] User defined keyword
To: [email protected]
Received: Tuesday, 12 February, 2013, 1:54 AM
1. Yes, I agree - GivenStory syntax is often
preferable to be a declarative precondition rather
than setup/teardown paradigm which is more akin to
unit testing.
2. The synonyms of 'And' are definitely easier to
implement because they map to pre-defined types.
Please raise a JIRA issue for it.
On 11/02/2013 11:05, Iulian Greculescu wrote:
@Handa,
If I understand well the sub scenario need
this can be achieved by including that sub
scenario part of a standalone story and
then making your each scenario that has
your sub scenario a prerequest running
with a GivenStories pointing to that
common story.
We applied this lots of time when
exercising a banking system.
Say you have the user login story your
common thing and then you have: a BPay
payment, a Bank Transfer, an International
Payment, etc. All these scenarios would
gave a GivenStories UserLoginStory, etc
@Mauro
The user defined keyword attracted my
attention quite a lot. I accept that you
can describe a business case just using
Given/When/Then/And suite. However when
the scenario you need to write is a long
one (say 30 or more steps) I have to
accept that the story starts sounding a
bit to fade (say made up). It works
but....:)
When this post came I was just about to
come up with an idea/proposal to bring
some spice in our stories and make them
sounds more natural. What about including
the flexibility of defining "And" synonyms
with exactly the same functionality as the
actual "And"?
So you can say something like this:
Given our Payments system supports SWIFT
messages
When a FX transaction message arrives
And the "from" currency is USD
And the "to" currency is GBP
And the exchange rate is 0.71002
And the transaction date is the next
business day
And the transaction amount is $200.00
And the payer account no is 1234567890
....
And 30 others "when" steps describing the
Foreigner Exchange message
Then.....
Someone would say (me included) that if I
can say "With' and "Having" are synonyms
of "And" and rewrite the story like below
then it would sound more natural.
Given our Payments system supports SWIFT
messages
When a FX transaction message arrives
Having the "from" currency as USD
And the "to" currency as GBP
With an exchange rate is 0.71002
......
What do u think? I was thinking to
research a bit how difficult that would
be.
Regards,
Julian
--- On Mon, 11/2/13, Mauro Talevi
<[email protected]>
wrote:
From: Mauro Talevi <[email protected]>
Subject: Re: [jbehave-user] User defined
keyword
To: [email protected]
Received: Monday, 11 February, 2013,
2:36 AM
You can request new features on
JIRA:
http://jbehave.org/issue-tracking.html
That said, your features require
substantial changes and are more
likely to be considered for the
4.x releases.
On 10/02/2013 15:13, Handa,
Ramneek wrote:
I
would love to have ability
to write a sub scenario
which is a part of many
scenarios so as to avoid
repetition.
@Before/@AfterScenario/...
– as a coder of my tool I
wouldn’t know what the story
writer would like to do at
teardown and setup.
Unfortunately
these two are very basic
needs for me to use JBehave.
Is it not done because its
complex given how JBehave is
implemented or has it never
been the priority?
I can
write my requirement and
file an issue if you think
this can be supported soon?
Regards
From: Mauro Talevi
[mailto:[email protected]]
Sent: Sunday,
February 10, 2013 10:39
PM
To: [email protected]
Subject: Re:
[jbehave-user] User
defined keyword
You
can define "composite steps"
from other defined steps:
http://jbehave.org/reference/stable/composite-steps.html
User-defined keywords are
not supported, the only
keywords allowed in the
scenario steps are
"Given/When/Then/And" but
the rest of the step
language is entire up to you
to define. You can also
change the existing ones, ie
use different values for
them, via i18n support.
The idea being that
Given/When/Then represent
generic step types
(precondition/event/result)
and you should be able to
fit comfortably into these
types by appropriate use of
the step language that
follows.
There is no setup/teardown
in the story syntax, i.e.
something executed before
and after *each* scenario or
story. There is however :
- GivenStories ... i.e. one
or more stories executed on
demand (i.e. on explicit
invocation) before scenarios
or stories.
-
@Before/@AfterScenario/Story/Stories
... i.e. annotated steps in
code that are executed
before each
scenario/story/group of
stories
On 10/02/2013 13:59, Handa,
Ramneek wrote:
Hi
Guys,
Is
it possible for the story
writer to create new
higher level steps (which
consists of multiple
steps)? I am moving from
robot framework and it has
this feature of user
defined keywords that i
couldn’t find in jbehave
website. Could someone
please point me in the
right direction?
Also,
i would like to know if
there is a way for story
writer to write
setup/teardown in gherkin?
Regards,
Ramneek
This email and any
attachments are
confidential and may also
be privileged. If you are
not the intended
recipient, please delete
all copies and notify the
sender immediately. You
may wish to refer to the
incorporation details of
Standard Chartered PLC,
Standard Chartered Bank
and their subsidiaries at
http://www.standardchartered.com/en/incorporation-details.html.
This email and any attachments are
confidential and may also be
privileged. If you are not the
intended recipient, please delete
all copies and notify the sender
immediately. You may wish to refer
to the incorporation details of
Standard Chartered PLC, Standard
Chartered Bank and their
subsidiaries at
http://www.standardchartered.com/en/incorporation-details.html.
