2. Test-driven Development (TDD)
• Test-driven development (TDD) is a software
development process that employs very short
development cycle:
– Testing
– Coding
– Refactoring
• TDD = Test-first Programming + Refactoring.
– Test-first programming is used in XP.
3. Test-driven Development (TDD)
• TDD substantially reduces the incidence of
defects.
• It helps to improve the design of coding.
• It minimizes the usage of debuggers.
4. Write Test Code
• At each cycle of TDD, each new feature begins
with writing a test.
• If the feature is not very small, only a very
small part of it is taken as a feature. This rule
is applied for the rest of the initial feature.
• After writing the test, execute it. It will fail. If it
does not fail, repeat the process until failure.
• Test codes should not be dependent to each
other.
5. Write Some Code
• Before coding actual feature, you should have
taken the failure for the test.
• Write some code which is just enough to pass
the test. In other words, the failure will not be
taken.
6. Refactor
• Remove duplications.
• Improve your code quality.
• Use good naming.
• Increase readibility.
• Modularize the codes.
• Use design patterns.
• Do not change the external behaviour of the
code. Change only the internal behaviour of the
code to get technical excellence.
7. Reversible Changes
• If the new feature addition takes a complex
error, go to the last stable state.
• Implement the same feature from the
beginning.
• Instead of using debugging and solving the
problem, use reversible changes property of
TDD.
• Every change should be reversible. Start from
the last stable state.
8. Documentation
• Every test code is a kind of documentation.
• It describes the interface of the actual coding.
• Every test code is a sample program to
investigate the actual program.
9. Code Base
• In addition to actual codes, there are test
codes.
• The test codes should also be managed
carefully.
• The test codes should be kept as simple as you
can like the actual codes.