My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
SharedBehaviors  
easyb supports shared behaviors
Featured, Cookbook
Updated Sep 10, 2009 by ajglo...@gmail.com

Introduction

As of easyb 0.9.6, the notion of shared behaviors is supported; that is, you can create a base behavior (at this point it must live within the context of a single story (i.e. a file)) and then refer to that behavior inline using the keywords shared_behavior and it_behaves_as like so:

shared_behavior "shared behaviors", {
  given "a string", {
    var = ""
  }
  
  when "the string is hello world", {
    var = "hello world"
  }
}

scenario "first scenario", {
  it_behaves_as "shared behaviors"
  
  then "the string should start with hello", {
    var.shouldStartWith "hello"
  }
}

scenario "second scenario", {
  it_behaves_as "shared behaviors"
  
  then "the string should end with world", {
    var.shouldEndWith "world"
  }
}
Comment by pascal.b...@gmail.com, Dec 10, 2010

The problem is when you produce an html report (-html with BehaviorRunnerTask? ) your don't see the details (given...when...then) of your shared behaviour

Comment by djo...@gmail.com, Dec 13, 2010

An additional (maybe temporary) tip for early adopters, got from andy's blog and source code : since version 0.9.8, shared behaviors can be shared by multiple stories: - put the shared behaviors in a dedicated story file (ex: shared.story) - referer to it from a story using following instruction:

shared_stories "shared.story"

I would agree with you the instruction is strangely named; but it's WIP !

Comment by rogovs...@gmail.com, Sep 6, 2011

It would be interesting to see more realistic example of shared stories. As it stands right now I don't see it approaching reusable steps in Cucumber - there is no clear readability of the features.


Sign in to add a comment
Powered by Google Project Hosting