0%
Source
A simple explain to TDD
Why should I do it:
- Tests have a short feedback loop, enabling you and your team to learn faster and adjust
- Less time is spent debugging, allowing you to spend more time writing code
- Tests act as documentation for your code!
- They improve code quality while reducing bugs
- After refactoring code, your tests will tell you whether the change has broken previously working code, and…
- Tests can prevent your hair line from receding!
This is how it works:
- Write a test. – The test will flesh out some functionality in your app
- Then, run the test – The test should fail, since there’s no code to make it pass.
- Write the code – To make the test pass
- Run the test – If it passes, you are confident that the code you’ve written meets the test requirements
- Refactor code – Remove duplication, prune large objects and make the code more readable. Re-run the tests every time you refactor the code
- Repeat – That’s it!