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: source/modules/TestDrivenDevelopment.rst
+5-4Lines changed: 5 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,20 +7,21 @@ FIXME: change the path from my personal to something generic
7
7
Test Driven Development
8
8
#######################
9
9
10
-
"Testing" is any strategy for making sure your code behaves as expected. "Unit Testing" is a particular strategy, that:
10
+
"Testing" is any strategy for making sure your code behaves as expected. "Unit testing" is a particular strategy, that:
11
11
12
12
* is easy to run in an automated fashion.
13
13
* utilizes isolated tests for each individual function.
14
14
15
+
15
16
"Test Driven Development" (TDD) is a development strategy that integrates the development of unit tests with the code itself. In particular, you write the tests *before* you write the code, which seems pretty backward, but it has some real strengths.
16
17
17
18
We'll demonstrate this technique with an example.
18
19
19
-
The Following is adapted from Mark Pilgrim's excellent "Dive into Python":
20
+
The following is adapted from Mark Pilgrim's excellent "Dive into Python":
20
21
21
22
https://diveintopython3.problemsolving.io/
22
23
23
-
The primary difference is that this version uses the simpler pytest testing framework, rather than `unittest`, which is discussed in:
24
+
The primary difference is that this version uses the simpler pytest testing framework, rather than `unittest`, which is discussed in
24
25
:ref:`unit_testing`
25
26
26
27
Unit Testing
@@ -108,7 +109,7 @@ conversion functions — ``to_roman()``, and later ``from_roman()`` — can
108
109
be written and tested as a unit, separate from any larger program that
109
110
uses them.
110
111
111
-
Technically, you can write unit tests with plain Python -- recall the ``assert`` statement that you have already used to write simple tests. But it is very helpful to use a framework to make it easier to write and run your tests. In this program, we use the `pytest` package: it is both very easy to get started with, and provides a lot of powerful features to aide in testing complex systems.
112
+
Technically, you can write unit tests with plain Python -- recall the ``assert`` statement that you have already used to write simple tests. But it is very helpful to use a framework to make it easier to write and run your tests. In this program, we use the `pytest` package: it is both very easy to get started with, and provides a lot of powerful features to aid in testing complex systems.
112
113
113
114
.. note:: ``pytest`` does not come with Python out of the box. But it is easily installable via `pip` (or conda, if you are using conda)::
0 commit comments