Approval Testing
Last night we had our February NE Bytes developer meetup, this time with the excellent Emily Bache running a remote workshop from her home in Sweden.
Emily spoke on approval testing, what it was and how to use it to improve the quality of software.
We kicked off with a discussion in small groups of what makes for a good unit test with plenty of suggestions from the delegates. Because this was a remote session, I had Emily's feed from my laptop projected onto the big room display and my webcam facing out into the room. Despite this, it was difficult for Emily to hear all the feedback so I acted as her local proxy and relayed feedback when she asked for it.
Staying in our small groups, after this discussion of general unit tests, Emily asked us to look at some sample tests which we had pinned around the room earlier. They were different styles, levels of complexity, format and layout and again we had a good discussion about the relative pros and cons of each approach. We put up post-it notes of feedback against each of the reviewed samples.
We then moved onto the main topic, approval tests and how to use them to tame legacy code which doesn't already have tests written for it. Emily took us through several different applications to show how to use an approval test library in Java using a shopping cart example where the original tests were verbose with a lot of repetition. Approval testing made the code easier to read at the expense of having to regenerate the golden copy and maintain it in source control along with the test code itself.
Last, Emily ran through the Gilded Rose kata to demonstrate the use of approval tests when refactoring "untestable", complex, code into a more readable form. Having the approval tests there to act as a safe guard she was able to make some bolder refactorings than she could have without them and was confident that she hadn't broken anything.
Feedback
As a final exercise, Emily asked us to come up with some thoughts for things we could take away from the workshop and capture them on a few post-it notes.
Not everyone was comfortable saying what their feedback was aloud or writing it down but I got lots of feedback in the form of private comments that everyone had learned a huge amount and had been encouraged to think about the topic. I was even contacted by a team who had heard about the session later and asked for an overview with a chance to implement it for an existing project.
Again this was an event hosted by Scott Logic at their Newcastle offices and we are grateful to them for their continued support.