Test Case After Code
|
Test Case Before Code (TDD)
|
-
Focus is on artefacts
-
Writing tests after the code is a combination of recall of what has
been coded and re-reading.
-
Relies much more on the discipline of the coder.
-
As a coder you may end up writing more code than is necessary when
doing a test case after code
|
-
Requires coder
to have a clue about where they are heading with the code.
-
It is the
beginning of a detailed code design
-
We use the
tests to literally drive function into the code, so that the fit between the
test and code is much higher.
-
By writing a
test before we are challenging ourselves to pass it.
-
TDD creates a
narrowed focus, a narrow bandwidth to solve the issue on hand thereby
ensuring optimized solution.
|
By writing test first, we force ourselves to design the program to be both testable as well as callable. This leads the class to be decoupled from its surroundings.
Diagram courtesy: Cohn
Diagram courtesy: Cohn
- TDD takes about 15% longer than not doing TDD. But there is evidence that TDD leads to fewer defects. Bugs go down by 24% to 38%.
- TDD may initially take a longer time, but will benefit the team in terms of reduced defects, reduced bug fixing and maintenance time.
No comments:
Post a Comment