Now that we have seen what tests look like and how to run them, let's dive into testing ChatStat. When I was first writing ChatStat, I designed it with testability in mind. The key practice here is to make as many components of the application work as possible without depending on other parts of the application. Testing a Perl class is very easy, but firing up a Catalyst application and testing it by making requests and looking at the HTML is hard. So, I tried to keep the need for the second type of test down by not doing much inside Catalyst. All the hard stuff is inside the easily-testable Perl modules. This not only makes testing easy, it's just a plain good design. Without any effort on my part, I can use the same code to write a command-line version of the application, or perhaps an IRC interface.
Let's get started by writing some tests for the ChatStat message parser. This isn't particularly related to the Catalyst part of the application, but if this doesn't work,...