Unit testing is easy, especially in a functional language like Erlang that minimizes side effects. But what about applications where you *want* side effects — such as delivering information or writing data to disk — and need to test multi-step workflows effectively? Test code quickly becomes littered with set-up code, teardown routines, and mock objects, and as the application complexity grows, the test suite runs slower, and slower, and slowwwwwer, and…
In this talk, I will introduce an approach to functional testing that makes the developer’s life easier by maintaining a *stack of state*. Here’s how it works. Say you have a 10-step workflow and want to test two mutually exclusive transactions in step 10 (say, “Complete Checkout” and “Cancel Order”). Instead of executing steps 1-9 twice, you execute them once, but keep around an “undo button” so that after you’ve tested the first path in step 10, you can retrace your steps and try another path. The result? Cleaner code, faster tests, and happier developers!
After laying out the basic ideas, I’ll discuss how to implement this approach with in-memory data (such as gen_server data), file systems, and popular databases. I’ll also explain why the approach works particularly well with Erlang code. For reference, I’ll show how the Chicago Boss web framework uses these ideas with its one-of-a-kind Deep Dish module, which can — and should — be integrated into other projects.
After attending, you’ll have everything you’ll need to build your very own Chicago-style test framework. But bring some salt, because the talk will be peppered with Erlang!
Talk objectives: The goal of the talk is to educate Erlang developers about the hows and whys of “Chicago-style” testing, and help them see that functional tests of large projects can be fast, simple, and clean.
Target audience: The talk will appeal to anyone who writes or maintains software with complex, multi-step interactions. Whether you’re struggling under the weight of a monolithic test suite, or thinking “Tests? Yeah we should probably have a few of those…”, you’ll come away from the talk with a new perspective on functional testing.