How to add JBehave BeforeStory AfterStory in a story file -


in jbehave, beforestory or afterstory annotation can added in step level. if there multiple steps classes beforestory annotation, beforestory annotated methods executed before each , every story start (which not needed).

in junit can add or leave beforeclass or before needed in test classes separately. need way add beforestory or afterstory in story level junit test class.

is there way add beforestory lifecycle in story file ? or alternative solution ?

following example shows adding before in lifecycle.

http://jbehave.org/reference/stable/story-syntax.html

lifecycle:  before: given step executed before each scenario  after: outcome:     given step executed after each scenario regardless of outcome outcome: success  given step executed after each successful scenario outcome: failure  given step executed after each failed scenario 

thanks.

in opinion jbehave not have such facility of now. try following - in class file execute given initialize users , in end of story scenarios define given release resources. know approach breaks bdd paradigm of whole , business defined scenarios, atleast work around. ensure executes first , last use (priority=1) initusers() , (priority=n) cleanup().


Comments