What is TDD
TDD is a testing, development and design methodology.
The TDD cycle consists of three steps:
Write a failing test.
Write production code to make the test pass.
Refactor
Why do TDD
With TDD we get 100% behavior coverage.
TDD is user-first. It helps us drive the design of the software.
We aren’t writing more code than necessary, so we automatically stick to YAGNI.
TDD lets you focus on one thing at a time. It helps you avoid becoming overwhelmed by all the production code you need to write.
By aggressively refactoring, we’re always writing clean code.
We do TDD trust our code.
How to get into TDD
You need to learn how to write good tests.
Learn the purpose behind writing automated tests. It’s gonna motivate you to do TDD.
Start by doing TDD on smaller problems.
Proper design, code smells and refactoring practices are also needed for successful TDD.
Common mistakes
Skipping the refactoring step of the TDD cycle.
Writing too large tests before diving into production code.
Writing tests coupled with the implementation detail.
But, is TDD not slow?
TDD takes time to learn. It doesn’t happen overnight.
In the beginning, TDD will slow you down. Once you’ve learned it, it will actually speed up the process.
Take into account, TDD is a complete package. It’s gonna help you become more Agile. You’re not by default not just writing better software but shipping fewer bugs to customers.
Three laws of TDD
Don’t deviate from these laws for a successful TDD flow:
You are not allowed to write any production code unless it is to make a failing unit test pass.
You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures.
You are not allowed to write any more production code than is sufficient to pass the one failing unit test.
I could not attend the event, and there is no recording so will need to do with these notes.
One important thing not clearly mentioned is what KentBeck called todo list.
Awesome summary, Tiger, we had a great fun in the Software Crafters event!