|
|
easyb is a BDD framework (like RSpec & JBehave) that provides a domain specific language which makes application verification simple, fun, and easy. easyb provides support for two types of specifications, Behaviors and Stories. Behaviors are created with before and it. Stories are created with scenario, given, when and then.
easyb in action
easyb enables you to verify behavior of normal Java objects, work-flows, etc (basically, anything you write in Java) in a more natural way-- for instance, imagine having a conversation with a customer who wants you to write something to validate zip codes.
"Could you please write something that lets my customers know when they've provided an invalid zip code?"
"Sure! So, given an invalid zip code, this validation service should notify someone that the zip code is incorrect?"
"Right on! Man, you are smart!"
Notice that nowhere in this conversation did anyone say test! Whether or not you write specifications first or afterwards is up to you; however, assuming that you've already written the zip code validator, you could construct a story like so:
- Given that someone mistypes a zip code
- And given the zip code validation service is up and running
- When validate is invoked
- Then the service should indicate the zip code is invalid
Using the text above, you can then construct an easyb story like so:
given "an invalid zip code", {
invalidzipcode = "221o1"
}
and "given the zipcodevalidator is initialized", {
zipvalidate = new ZipCodeValidator()
}
when "validate is invoked with the invalid zip code", {
value = zipvalidate.validate(invalidzipcode)
}
then "the validator instance should return false", {
value.shouldBe false
}Is that easy or what? Notice the shouldBe call in the then phrase-- slick, eh?
BDD in Java can't get any easier!
For more information on easyb, check out easyb.org where you can find more examples, a tutorial, how to run easyb and much, much more!
