Two minute tutorial
You create a Behaviour Class, which is a plain Java class that by convention
has the name of the class whose behaviour we are specifying followed
by the word "Behaviour", so Foo has FooBehaviour.
Inside the Behaviour Class are a bunch of methods that specify the behaviour we expect. These are just public void methods that start with the word "should" and describe the specific behaviour (e.g. CustomerServiceBehaviour might have shouldFindCustomerBySurname()).
These will typically set up a known environment, execute some behaviour and then verify that stuff happened. There are some static methods in com.thoughtworks.jbehave.core.Verify that help with this, for instance Verify.that(somethingHappened) and Verify.equal(expectedValue, actualValue).
Our template behaviour method looks like this:
public void should[DoSomething]() {
// setup
// execute
// verify
}
The DoSomething is highlighted so we know we have to change it to actually describe some behaviour. Templates are nice like that.
Behaviour classes can be contained in, wait for it, a behaviour class container. This is a plain Java class that implements the com.thoughtworks.jbehave.core.BehaviourClassContainer interface. This has a single method: getBehaviourClasses(), which returns an array of Class objects representing the behaviour classes to run. Naturally behaviour class containers can contain other behaviour class containers.
Behaviour is verified by reflecting into the behaviour classes and invoking the methods. A Listener is notified whenever something interesting happens.
A single behaviour method is verified by a MethodVerifier, a behaviour class is verified by a BehaviourClassVerifier
So how do we tie this all together? There is a small main method inside com.thoughtworks.jbehave.core.Run that takes a behaviour class name as its argument and invokes a BehaviourVerifier on it passing in a TextListener. Run that with jbehave-core.jar on your classpath. And, um, that's it. So:
java -cp jbehave.jar;your_classpath com.thoughtworks.jbehave.core.Run your.ApplicationBehaviour