TDD: Get me started
by Chance Smith
In case you haven’t heard, we first need to talk about what Test Driven Development (TDD) is.
It’s a seemingly simple workflow. You just write a failing test first and then write code that passes your test. One at a time.
Yeah, sounds nuts, right?! Let me explain the steps…
- RED: Write a failing test
- GREEN: Write just enough production code to pass that test
- REFACTOR: Refactor any of your code without failing a test. Stay green.
These steps are all thanks to Kent Beck and Uncle Bob. Go read their books. Uncle Bob wrote code for 20 years before he went on all in on TDD. 🤯
TDD is a simple but challenging process. You will struggle, but with much software engineering maturity, you will get better at this. Start now. Worry about doing it wrong later.
Why you need TDD
Let’s list the ways:
- less browser refreshing, because your tests are testing that part of the code for you
- run your code less, because your tests are testing that part of the code for you
- let the failing tests show you what to fix or add next
- refactor or abstract anything you want, just keep the green lights on
How do I start writing tests?
Here is a collection of testing videos that our team found helpful to get us started.
Go write some tests
Next time you code, ask yourself, “How can I write a test first?”
I’m going to say it again…
Start now. Worry about doing it wrong later.
Need help getting started?