[jbehave-dev] [jira] (JBEHAVE-1070) Loose StepType

2015-03-11 Thread Alberto Scotto (JIRA)
Title: Message Title










 

 Alberto Scotto created an issue


















 JBehave /  JBEHAVE-1070



  Loose StepType 










Issue Type:

  Improvement




Assignee:


 Unassigned




Components:


 Core




Created:


 11/Mar/15 3:33 PM




Priority:

  Major




Reporter:

 Alberto Scotto










Hi,
I've recently started working with jbehave, and I am noticing duplication when a step method can be more than one StepType, e.g.:



@When(the cart is empty)
@Then(the cart is empty)
public void cartIsEmpty() {}



An easy  workaround could be to support the following syntax



@When(the cart is empty)
@Then
public void cartIsEmpty() {}



i.e. in case a method has multiple StepType annotations, only one value needs to be not empty.
But I think there's a more elegant solution. The Cucumber Book says something interesting about this:

Given, When, Then Are the Same. It doesn€™t actually matter which of the three methods you use to register a step definition, because Cucumber ignores the keyword when matching a step. Under the hood, all of the keyword methods are aliases for Cucumber:: 

[jbehave-dev] [jira] (JBEHAVE-1070) Loose StepType

2015-03-11 Thread Alberto Scotto (JIRA)
Title: Message Title










 

 Alberto Scotto updated an issue


















 JBehave /  JBEHAVE-1070



  Loose StepType 










Change By:

 Alberto Scotto









 Hi,I'verecentlystartedworkingwithjbehave,andIamnoticingduplicationwhenastepmethodcanbemorethanoneStepType,e.g.:{code}@When(thecartisempty)@Then(thecartisempty)publicvoidcartIsEmpty(){}{code}Aneasy(?)workaroundcouldbetosupportthefollowingsyntax{code}@When(thecartisempty)@ThenpublicvoidcartIsEmpty(){}{code}i.e.incaseamethodhasmultipleStepTypeannotations,onlyone[value|http://jbehave.org/reference/stable/javadoc/core/org/jbehave/core/annotations/Given.html#value()]needstobenotempty.ButIthinkthere'samoreelegantsolution.TheCucumberBooksayssomethinginterestingaboutthis:{quote}Given,When,ThenAretheSame.It doesn€™ doesn‚„ tactuallymatterwhichofthethreemethodsyouusetoregisterastepdefinition,becauseCucumberignoresthekeywordwhenmatchingastep.Underthehood,allofthekeywordmethodsarealiasesforCucumber::RbDsl#register_rb_step_definition.Thekeywordsarereallyjustthereforextradocumentationtohelpyouexpresstheintentofeachsteporstepdefinition.Thismeansthat,whetheritwascreatedwiththemethodGiven,When,orThen,astepdefinitionwillmatchanyGherkinstepaslongastheregular_expression_matchesthemaintextofthestep{quote}Ilikethisconcept.Attheendoftheday,thedifferencebetweenaGivenandaThenisjustamatterofmeaning.Andof*position*(i.e.givenbeforethen),atmost.Sowhataboutgoingalittlebitfartheranddefiningageneric {code} @ Step {code} annotation?{code}@Step(thecartisempty)publicvoidcartIsEmpty(){}{code}Thereisaproblem,though,asIthinkthiswouldbreakJBEHAVE-196(?).Butthen,asfarasIunderstand,theultimatesolutionwouldbetosupportregexes,wouldn'tit?Whichisanotherfeaturethatwouldbeavery-nice-to-have,Ithink.Thanks












   

 Add Comment






















 This message was sent by Atlassian JIRA (v6.1.6#6162-sha1:7af547c)