You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: using/solving-exercises/tdd.md
+24-19Lines changed: 24 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,21 +20,6 @@ You have solved an exercise when all the provided tests run and pass.
20
20
In other words, your solution is not just an interpretation of the instructions that "looks right", your solution is a program that _satisfies the given tests_.
21
21
**The tests represent the complete requirements for the exercise.**
22
22
23
-
## Rationale for Test-Driven Development
24
-
25
-
While it may seem like "putting the cart before the horse", there are several good reasons why you might want to write unit tests before writing the implementation code:
26
-
27
-
1. Design.
28
-
It forces you to think first about the design of the **interface** to the code, instead of jumping straight to the implementation.
29
-
Having a well-designed (and testable!) interface is often more important than having an efficient implementation.
30
-
31
-
1. Discipline.
32
-
Writing tests is often seen as a chore or an afterthought; writing the tests _first_ guarantees that at the end of the day you will have written enough unit tests to cover most or all of your code's functionality (rather than possibly never getting around to it).
33
-
34
-
1. Less Work.
35
-
If you apply a tight cycle of write one test, then write the code to implement that test, then write the next test, your code ends up growing organically.
36
-
This often (though not always) leads to less wasted effort; you end up writing all the code you need, and none of the code you don't need.
37
-
38
23
## How does Exercism apply TDD?
39
24
40
25
We've done the work of writing a unit test suite for you.
@@ -69,10 +54,30 @@ We do this to encourage you to follow this workflow:
69
54
Exactly how tests are "unskipped" (or selected) depends on the track.
70
55
For some tracks, it might be commenting or removing an annotation.
71
56
For some tracks, it might be changing an attribute from true to false.
72
-
Take the time to read the track documentation: it will explain these details.
57
+
Take the time to read [the documentation for your track][track-docs]: it will explain these details.
58
+
59
+
## Rationale for Test-Driven Development
60
+
61
+
While it may seem like "putting the cart before the horse", there are several good reasons why you might want to write unit tests before writing the implementation code:
62
+
63
+
1. Design.
64
+
It forces you to think first about the design of the **interface** to the code, instead of jumping straight to the implementation.
65
+
Having a well-designed (and testable!) interface is often more important than having an efficient implementation.
66
+
67
+
1. Discipline.
68
+
Writing tests is often seen as a chore or an afterthought; writing the tests _first_ guarantees that at the end of the day you will have written enough unit tests to cover most or all of your code's functionality (rather than possibly never getting around to it).
69
+
70
+
1. Less Work.
71
+
If you apply a tight cycle of write one test, then write the code to implement that test, then write the next test, your code ends up growing organically.
72
+
This often (though not always) leads to less wasted effort; you end up writing all the code you need, and none of the code you don't need.
73
73
74
74
## Further reading
75
75
76
-
*[About Test-First Teaching](https://web.archive.org/web/20220918221108/http://testfirst.org/about) at the archived TestFirst\.org site.
77
-
*[Test-driven development](https://en.wikipedia.org/wiki/Test-driven_development) at Wikipedia.
78
-
*[Test Driven Development](https://exercism.org/docs/tracks/python/test-driven-development) on the Python track.
76
+
*[About Test-First Teaching][test-first.org] at the archived TestFirst\.org site.
77
+
*[Test-driven development][tdd-wiki] at Wikipedia.
78
+
*[Test Driven Development][tdd-python] on the Python track.
0 commit comments