Behavior Driven Development in Perl

Testing is hard - not necessarily to do, but to start with - it is so hard, that yet I haven't started writing tests for my code and I considered this to be a handicap for me as a developer.

I've heard about this Behavior Driven Development stuff ( BDD ) and I said to give it a try.

After some research to see what is available for Perl, I found Pete Sergeant's Test::BDD::Cucumber module and although it's only at version 0.05, it is usable and functional.

Comming back to BDD, the main idea behind it is that your user stories are your tests. As an implication, you could get to the stage where your business analysts write your tests (with little, or even no developer intervention).

I like this BDD stuff because it was really easy to get started with. It was so easy, that during a weekend I learned what is all this about (without any kind of previous experience or background in writing tests), prepared a short presentation on Behavior Driven Development with Perl, and also implemented some Feature Based Tests to the Mojolicious Boilerplate (about which you can read here ).

Some of the tests from the Boilerplate are passing and some are failing (most probably because there is no content in the Test::Mojo object used for testing the application) but I am not in hurrying to make them pass - because other people could use those failing tests as a starting point for learning BDD.

In conclusion, I don't like the name Behavior Driven Development, mainly because it is not reflecting what its core focus (like TDD does for Test Driven Development). I think it was more appropriate to name it Feature Driven Development, or User Story Based Driven Development, but I think the ruby fellows that started this Cucumber wanted to leave the impression of a fresh start so they have chosen some name totally unrelated to the content.

If you like my BDD presentation and want to learn/use BDD, I warmly recommend Pete's rich documentation which in my opinion makes a much much better job in getting you up and running with BDD than does the ruby Cucumber site.

For myself, until I'll get the chance to take part to one of Gabor Szabo trainings on Perl Test Automation, or I'll get the time to have an overview on the plenitude of Perl Testing Modules and how they work, I'll be focusing on this BDD,


I too have inspired recently by BDD. I think the name holds as each scenario tests a usage-pattern and not just methods.

Furthermore, I've looked at the ruby Cucumber docs and Test::BDD::Cucumber and decided to roll-my-own parser for fun which is available here:

It sounds very nice but in the real world I find that:

  • No analysis has been done.
  • The requirements are are hodgepodge of ideas thrown together.
  • The developers are kept far away from the customers.
  • Test cases are created when there's time for them (meaning never).

I wish I could implement BDD just it doesn't seem possible in the foreseeable future. :(

Hi Tudor,

I'm glad you're enjoying using Test::BDD::Cucumber! Please let me know how you get on, and which features you're interested in - at the moment, development is very much driven by what people are missing. I've added tag support and fixed the implementation of Background sections as a result of user input so far (in the two releases since the once you linked to).

Hi Al,

I'm curious as to why you started your own Cucumber implementation - were there features missing from Test::BDD::Cucumber you were relying on?

Hey Pete,

No, Test::BDD::Cucumber is great and from what little I've seen of the source code, it follow the Cucumber spec whereas mine doesn't.

I wrote my own merely for fun, also I wanted more control over how feature specifications are parsed and how tests are run.

Test::Qcmbr is not coupled with a testing framework nor does it provide facilities for testing, its sole purpose is to parse features specs and provide sugar functions for stepping through scenarios.

Leave a comment

About Tudor Constantin

user-pic Perl Is My Cocaine