Test Driven Development
TDD
Test-Driven Development is a discipline
Discipline is an arbitrary behavior that are driven by substantial motives
How do doctors wash their hands?
3 Rules
Youre not allowed to write any production until you have first writen a test that fails because the production code does not exist
2nd Law
You are not allowed to write more of a test than is sufficient to fail
3rd Law
You are not allowed to write any production code than its sufficient to pass the failing test
The endless 10 seconds loop.
If everything worked a minute ago for everyone,
how much time would you spend debugging?
Let's assume consuming a third-party library.
Do you read the text that the author has written?
Or do you go straight to the appendix where the code examples are?
When you write code like that:
You have got yourself a well-documented system for the consumers
When you write code like that:
You have snippets of the code that are de-coupled and tell you how to integrate the exact component into your system
When you write code like that:
You have every minute detail of the system on the very low level
How many of you write unit test?
The code inevitably with time becomes untestable.
Manager:
The client has said we need to have code coverage
You're really pissed and but you're writing those stupid tests.
You have added stuff to you're test suite but you don't trust it.
TDD solves that problem
We, programmers, are Wizards
What other field has the same kind of thing?
Accountants.
TDD is like double entry book keeping.
TDD Demonstration
Lets implement a Stack
Test Driven Development
By Minhaj Khan
Test Driven Development
- 133