Component Testing and Test Driven Development with Jack Donaldson

Meet Jack Donaldson, one of our Software Engineers at Nine. Jack shares some insights on testing.

Component Testing

Cheaper than user interface functional & End to End tests, Component Testing throws away mocked data and performs real operations on our services. Component testing focuses on closely related classes, combining them together to test as one group. Whether it checks if queries are functioning appropriately or whether events are correctly processed, the component testing framework is fundamental to our testing pyramid. 

At Nine tech, once we had the framework established for component testing, we retroactively applied the component testing framework to our much-beloved services.  

However, retroactively adding Component Tests to our repositories is easier said than done.
1. For starters, the fact that we decided to begin with our most critical service has meant that we have had to be more careful in our approach. 

2. Whilst the services would receive the biggest benefit from this form of testing, its size, age and the variety of teams actively contributing have proved to be an interesting challenge. 

3. We often observed that we had a huge opportunity to improve the testability of our services. This meant that some cases were not possible to test without altering the code itself. For example, if a function inserting a record with a date field automatically sets it to Now(), we can’t retroactively test that the field’s value is set properly because we can’t easily work out what time the insertion operation was run. 

Test Driven Development

However, if Test Driven Development practices are followed (that is, test cases written up prior to feature development), it enables a developer to pick up this issue much earlier on as part of the development and fix the inaccuracies accordingly, allowing us to much more easily and comprehensively test the service. 

Whilst Test-Driven Development (TDD) may seem like yet another long scary acronym, it is a valuable practice that our tech teams are adopting, emphasising our team members’ focus on thinking about QUALITY FIRST and making it easier than ever to catch bugs EARLY!

Read our Content

Q&A with Scott Spits, The Age Reporter

Scott is a sports reporter and producer with many years of experience, involving a range of tasks including liaising with other reporters, quality control and presentation of our journalism.