Create a textual story file with a name that expresses the behaviour to verify, e.g. i_can_toggle_a_cell.story and define steps in it:
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..
Steps must start with one of the keywords highlighted (see Concepts for more details) and are not limited to a single line. Also, unless otherwise indicated, a story has at least one implicit scenario, each of which is a collection of steps.
Define your GridSteps class, a simple POJO, which will contain the Java methods that are mapped to the textual steps. The methods need to annotated with one of the JBehave annotations and the annotated value should contain a regex pattern that matches the textual step:
Define your Embeddable class (in our case JUnitStory) with a name that can be mapped to the textual story filename, e.g. ICanToggleACell.java:
The story is now configured to use the GridSteps that hold the step mappings.
Open your favourite IDE, the ICanToggleACell.java class will allow itself to run as a JUnit test. Be sure to check that you have all the required dependencies in your classpath.