TDD is not a testing process it's a Design process
success is not getting green, success is the transition from red to green.
3 law
- Write a failing test for a feature.
- Write just enough code needed to pass the failing test. Quality no matter.
- Refactor your code.
Why?
- Short coding cycle => easier debugging.
- Make your production code more readable and understandable.
- Write test after write code is hard.
- Write test after code leaves holes in test suit.
- Make refactoring a pease of cake.we are confident about our code base and confidently refactor our code.
Challenges
-
How write test before code?
- start developing on paper or you head not you code editor!
after that you can easily write tests first.
- start developing on paper or you head not you code editor!
-
it's wast of time!
- TDD make debugging, refactoring, scaling easier and faster in the future.
There is noting good about driving fast in wrong way