Easyb – easy BDD in Groovy
Some time ago I got interested in Ruby and one of the things that I was extremely impressed about was RSpec. RSpec is a library that allows to define a testable specification that can be run similar to unit tests. Let’s say I want a write a Stack implementation (for some reason BDD people always use stack as their “hello world” alternative). So before I begin I can define some specifications for that Stack class, like this: given empty stack, size() should return 0. Now, the beutiful thing about RSpec is that because of power of Ruby it allowed writing specs like this almost in a natural language, and then run those specs to verify the code behaves correctly. This concept is called Behavior Driven Development or BDD.
By the way, if you think this is almost the same as normal unit testing, you will be mostly right. The difference is in the “user-friendliness” not in the technology. With unit tests, you get the spec, than you need to think of ways to test it, then you implement the test, then if it breaks you need to reverse-lookup what part of spec that test was testing anyway so you can fix it. BDD is mostly the same, but just more straightforward – right spec in English, extend it with code, when it fails it will tell you in English what failed.
Anyway, this was some time ago, and I remember that I got a bit jealous of Ruby people for having this tool. Fast forward to now, and turns out that like most good things in Ruby (RoR to Grails) RSpec was also imported to Java, or more specifically Groovy. It is called Easyb and from examples on the website it looks fantastic. I haven’t used it yet, but I am looking forward to it.
Entry filed under: Uncategorized.