A Guided Path to Test-Driven Development - TDD
I do not recall who introduced me to Test-Driven Development (TDD), but I have always been interested in the testing aspect of software development. I vividly remember reading the iconic book Test-Driven Development By Example by Kent Beck on my commute. Every page was a discovery, and I felt a sense of frustration, as the baby steps conflicted with my confidence that my code would work.
However, given the context of my early career, I did not have the opportunity to explore TDD further. The places I worked at unfortunately cared more about delivering tasks quickly than sacrificing time for testing. I share more about my TDD history in a blog post, but I was astonished by the lack of care for testing among practitioners. My intention here is to share my previous experience with writing tests and resources that I think are helpful. This is not a definitive guide to testing, but rather a structured way to get started.
Table of contents
1. Introduction
- What is testing? - Discover what a test is from the perspective of a practitioner and the different shapes that are out there to distribute the different types of tests from the point of view of TDD
- Should you test? - In this section there is a discussion about testing or not and its benefits are discussed. More specifically on the automation part of it
- A gentle introduction to TDD - TDD is introduced as a methodology and describes its different flavors
- The many types of tests in software testing - Integration? End-to-end? Acceptance? Let’s see how they fit from a testing point of view
- The differences between frontend and backend - Tips that are hidden from practitioners’ point of view writing tests for client and server applications.
2. Changing your mindset
3. Building software with tests X software without tests
4. Frameworks available for testing
- PHPUnit
- Jest
- Jasmine
- Testing library
- Junit
5. Test doubles
- The history
- Mocks, dummies, spies, fakes - testing your code
- Are true mocks evil?
7. Advanced topics
- On one hundred percent code coverage - how to approach coverage and void misusing it
- Test Driven Development anti-patterns
- TDD anti-patterns - The liar, excessive setup, the giant, slow poke
- TDD anti-patterns - The mockery, the inspector, the generous leftovers and the local hero
- TDD anti-patterns - The nitpicker, the secret catcher, the dodger and the Loudmouth
- TDD anti-patterns - The greedy catcher, The sequencer, Hidden dependency and The enumerator
- TDD anti-patterns - The stranger, The operating system evangelist, Success against all odds and The free ride
- TDD anti-patterns - The One, The Peeping Tom, The Flash and The Jumper