Archive for August, 2010

Concurrency testing in Erlang with libtest

I’ve just started a new project, with the aim of making it easier to test the concurrent programs I write in Erlang. My stated aims are quite simple:

  • Provide services for capturing inter-process messages and context
  • Provide support for stubbing out processes and OTP behaviours
  • Provide hamcrest matchers that make it simple to define assertions about your application’s behaviour

It’s all in a very early stage (apart from my Erlang implementation of hamcrest, which is coming along nicely now) and the source code is available on github here. Here are a couple of samples to whet the appetite:

?assertThat(registered_name(Mod), observed_message_from(self(), Msg)),
?assertThat(registered_name(Slave, ProcessName), observed_message(Msg)),
?assertThat(Pid, observed_message({message, "hello"})),
categorises(observed_message({message, "woo hoo"}),

Stubbing of OTP behaviours will almost certainly be based on emock, and I’m planning on integrating nicely with PropEr as I’ve started using this library quite a lot myself. The mechanics of replacing registered gen_servers and the like (using runtime code generation and/or re-registration/config), I’ll probably leave alone as there are plenty of good libraries out there that do this already.


Leave a comment