🧪Test-Driven Development (TDD)
Also known as TDD, Test-First Development, Red Green Refactor
Write a test that fails first. Then write just enough code to pass.
Think of it like
Think of it like writing the quiz before you study. You know the goal before you start.
Example
Emma needs a function that rounds prices. She writes a test that 2.345 becomes 2.35, sees it fail, then writes the function until it passes.
Why it matters
Every line of code comes with a test. You also think about how code is used before you write it.
Definition
Common mistake
Key takeaways
- 1Red. Write a test that fails.
- 2Green. Write code until it passes.
- 3Refactor. Tidy, keep it green.