May 29, 2008 3:48 am
svn co http://svn.codehaus.org/jbehave/trunk
No ‘official releases’ yet, but if you want to play, go ahead. Examples of examples are checked into trunk.
Features include:
Our goal with JBehave 2 was to make a framework that was lightweight, easy to use and didn’t take as long to set up as 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.
i_can_toggle_a_cell and define steps in it thus:
Given a 5 by 5 game When I toggle the cell at (2, 3) Then the grid should look like ..... ..... ..... ..X.. ..... When I toggle the cell at (2, 4) Then the grid should look like ..... ..... ..... ..X.. ..X.. When I toggle the cell at (2, 3) Then the grid should look like ..... ..... ..... ..... ..X..
ICanToggleACell.javapublic class ICanToggleACell extends Scenario {
public ICanToggleACell() {
super(new GridSteps()); // varargs, can have lots of steps
}
}
public class GridSteps extends Steps {
private Game game;
private StringRenderer renderer;
@Given("a $width by $height game")
public void theGameIsRunning(int width, int height) {
game = new Game(width, height);
renderer = new StringRenderer();
game.setObserver(renderer);
}
@When("I toggle the cell at ($ column, $row)")
public void iToggleTheCellAt(int column, int row) {
game.toggleCellAt(column, row);
}
@Then("the grid should look like $grid")
public void theGridShouldLookLike(String grid) {
ensureThat(renderer.asString(), equalTo(grid));
}
}
Future features we’re thinking of:
Give it a go and tell us what you think! Release 2.0 can’t be far away…
Posted by Liz
Categories: jbehave
Mobile Site | Full Site
Get a free blog at WordPress.com Theme: WordPress Mobile Edition by Alex King.