One minute tutorial
Create a Behaviour Class that extends UsingJMock from the jmock extension library. UsingJMock brings together a bunch of “sugar” methods for use when creating/setting up mocks and expectations. It also provides auto-verification for all mocks.
You use jMock like so:
public class CheeseBehaviour extends UsingJMock {
public void shouldRequireTheUseOfMocks() {
// given
Mock cheese = new Mock(Cheese.class);
Sheep sheep = new Sheep((Cheese)cheese.proxy());
//expect
cheese.expects(once()).method("squelch").withAnyArguments();
// when
sheep.eatCheese();
// then
verify();
}
}
You then run your behaviour like so:
java -cp org.jbehave.jar;jmock.jar;your_classpath SheepBehaviour
