What I would change about POE::Test::Helpers

Since plunging into the event-based programming world POE offers, I've been infatuated with combining the tests I've learned to write (Perl Testing Handbook FTW!), which proved to be a pesky task.

Writing tests was fun, writing POE was a bit difficult for me at first and combining them seemed close to impossible.

I started off by using MooseX::POE by (++Chris Prather) and it helped me instantaneously understand and write event-based code. However, with time I learned to separate Moose and POE (while still working with both at the same time) and have more control over the matter. Still, testing my event-based code looked like a far goal. It bugged me.

I set out to write a testing framework for this which dngor named POE::Test::Helpers. It used the power of Moose to provide your MooseX::POE-based event code with the ability to write rather complex tests in an almost-declarative manner.

You could write down what the order of events should be, how many times each event is run and even what parameters each event will have (even in a specific order, if you like). Rather nifty, I should say!

However, this was only possible using the power of Moose, and I had no idea how to manage that without it. It became apparent that providing this ability to any POE program (whether infused in MooseX::POE or not) is a worthwhile endeavor.

This would require a major overhaul of POE::Test::Helpers in the following order:
- Design a new API for declaring and checking tests and events
- Test it thoroughly
- Port all the tests to the new spec (defined by the new API)
- Provide a Moose-based spec (similar to the regular API) for those using MooseX::POE

I wanted to write about it earlier but felt like it's a no-started but a few talks with the cool people at #poe, a good sum of Data::Dumper prints and I was able to get the prototype working. After speaking to BinGOs at YAPC::EU I figured it's time to finalize it.

Recently I've uploaded POE::Test::Helpers 1.05 and today even POE::Test::Helpers 1.10. I already got a RT ticket which I resolved and hopefully soon I'll also have a POE::Test::Helpers::Tutorial up there so it's easier for people to understand it better and learn how to use it.

You can now use POE::Test::Helpers with any POE code and if you've using MooseX::POE you could use POE::Test::Helpers::MooseRole.

Leave a comment

About Sawyer X

user-pic Gots to do the bloggingz