Integration Testing with the JBehave BDD framework
If you prefer a BDD style of programming you might decide to use JBehave.
Here is what you might end up withJBehave is a Behaviour Driven Development (BDD) framework for Java.
The sections below illustrate using JBehave for the examples from Using Testing Frameworks with Groovy.
The Stack Example
Here is how you might use JBehave to test the Stack Example:
| Code Block |
|---|
The Item Storer Example
Here is how you might use JBehave to test the Item Storer Example:
| Code Block |
|---|
// require(url:'http://jbehave.org/', jar='jbehave-1.0.1.jar')
import org.jbehave.core.Run
class JBehaveStorerBehavior {
def storer = new Storer()
def static checkPersistAndReverse(cut, value, reverseValue) {
cut.put(value)
assert value == cut.get()
assert reverseValue == cut.getReverse()
}
void shouldReverseStrings() {
checkPersistAndReverse storer, 'hello', 'olleh'
}
void shouldReverseNumbers() {
checkPersistAndReverse storer, 123.456, -123.456
}
void shouldReverseLists() {
checkPersistAndReverse storer, [1, 3, 5], [5, 3, 1]
}
}
Run.main('JBehaveStorerBehavior')
|