[
http://jira.codehaus.org/browse/JBEHAVE-247?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=214324#action_214324
]
Stephen Cresswell commented on JBEHAVE-247:
-------------------------------------------
Hi Paul,
Using Who and And interchangeably on a per step cases would work well. The
Given steps I used as examples are some of our more simplistic, there are lots
more variations...
"a $gender, $speciality patient called $name, in "$location" who is $state
e.g. Given a male, cardiovascular patient called Bob Holness, in "Bed 05, Ward
1", who is not medically fit
Being able to split these up into smaller steps would make the scenarios more
readable and reduce the number of complex steps....
{quote}Given a male patient called Bob Holness // we should probably auto
assign gender based on known names
{color:red}with{color} a cardiovascular speciality
{color:red}located{color} in Bed 05, Ward 1
{color:red}who{color} is not medically fit{quote}
"but" would be a useful synonym too
{quote}Then Bob's bed changes to Bed 6
{color:red}but{color} his* admission date stays as 15/07/74{quote}
\*our PatientParameterConverter is smart enough to recognise "his/her" and use
the "current" patient from our test context instead of doing a db retrieval on
first name
> jBehave should be more intelligent/flexible with regards to priortisation of
> steps
> ----------------------------------------------------------------------------------
>
> Key: JBEHAVE-247
> URL: http://jira.codehaus.org/browse/JBEHAVE-247
> Project: JBehave
> Issue Type: Improvement
> Reporter: Stephen Cresswell
> Priority: Minor
> Attachments: LevenshteinDistance.java,
> PrioritizableUnmatchedToPendingStepCreator.java
>
>
> BDD's strength relies on being able to write fluent scenarios. jBehave's
> support for this is very good, but there is still room for improvement. For
> example a typical scenario might read...
> {quote}
> Scenario: Schedule Patient Discharge
> Given a medical patient called Bob Holness who is not medically fit
> When I change Bob's state to medically fit
> And select a discharge time of tomorrow morning
> And select a discharge complexity of 3
> {color:red}Then Bob's discharge schedule should be displayed on the ward
> board{color}
> {quote}
> Now in a related scenario let's say I want to cancel while rescheduling a
> discharge...
> Scenario: Cancel Rescheduling Patient Discharge
> {quote}
> Given a medical patient called Bob Holness who already has a discharge
> schedule
> When I reiterate that Bob's state is medically fit
> And select a discharge time of tomorrow morning
> And cancel the discharge schedule
> {color:red}Then Bob's *old* discharge schedule should be displayed on the
> ward board{color}
> {quote}
> The underlying implementation of assserting Bob's actual discharge schedule
> is the same, but I want to emphasise *the expression of intent* through use
> of words such as old, new, still, etc.
> jBehave partially supports this through aliases
> {code:title=MySteps.java|borderStyle=solid}
> @Then('''$patient discharge schedule should be displayed on the ward board''')
> @Aliases(values=['''$patient old discharge schedule should be displayed on
> the ward board'''])
> public void assertDischargeScheduleOnWardPage(Patient patient) {
> wardBoardPage.assertDischargeSchedule(patient)
> }
> {code}
> The trouble is that the above fails because of the way in which jBehave
> matches and prioritises steps. Both "Then" and "Alias" steps will match the
> sentence
> "Bob's old discharge schedule should be displayed on the ward board", but
> "Then" will be prioritised based on it's declaration order, causing the value
> "Bob's old" to be passed to the PatientParameterConverter. Since no patient
> exists with the name "Bob's old", the parameter converter will return null
> and the test fails.
> Currently the workaround is to reword the steps slightly to prevent both of
> them matching...
> {quote}Then {color:red}"{color}Bob's{color:red}"{color} discharge schedule
> should be displayed on the ward board
> Then {color:red}"{color}Bob's{color:red}"{color} old discharge schedule
> should be displayed on the ward board{quote}
> or
> {quote}Then Bob's discharge schedule should be displayed on the ward board
> Then Bob's old discharge schedule should {color:red}now{color} be displayed
> on the ward board{quote}
> but both are inferior to the original. A nicer (and fairly easy) solution
> would be to base this priortisation on similarity with the string step, using
> something like the Levenshtein distance. Harder, but better yet would be to
> make the prioritsation configurable.
> I've attached the first solution (with lots of printlns so you can see how
> well the prioriisation works).
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email