Getting Started

Our goal with JBehave 2 was to make a framework that was lightweight, easy to use and overcome some of the usability limitations of JBehave 1. To that end, we've been driving this entirely from example code - no guessing, unless it's obvious - and we've ended up with something that works quite a lot like RSpec's story runner, but for Java.

To use it, simply name your scenario file with underscores, eg i_can_toggle_a_cell (although the file name resolution is configurable) and define steps in it: A few more elements are required:

  • Extend the Scenario class with a similarly named Java class: ICanToggleACell.java
  • Extend the Steps class - this is where your steps will be defined, and you can have as many as you want
  • Inject these into the Scenario:
  • Annotate methods in your step class to match the ones in your plain text scenario.
  • Run your new scenario as JUnit test.
  • Check out the working examples in the source repository.

Future features we're thinking of:

  • tagging scenarios
  • better tolerance of whitespace
  • an option for pending steps to break the build
  • anything you persuade us you need.