@@ -3,17 +3,17 @@ Testing Your Code
3
3
4
4
Testing your code is very important.
5
5
6
- Getting used to writing the testing code and the running code in parallel is
7
- now considered a good habit. Used wisely, this method helps you define more
6
+ Getting used to writing testing code and running this code in parallel is now
7
+ considered a good habit. Used wisely, this method helps you define more
8
8
precisely your code's intent and have a more decoupled architecture.
9
9
10
10
Some general rules of testing:
11
11
12
12
- A testing unit should focus on one tiny bit of functionality and prove it
13
13
correct.
14
14
15
- - Each test unit must be fully independent. Each of them must be able to run
16
- alone, and also within the test suite, regardless of the order they are
15
+ - Each test unit must be fully independent. Each test must be able to run
16
+ alone, and also within the test suite, regardless of the order that they are
17
17
called. The implication of this rule is that each test must be loaded with
18
18
a fresh dataset and may have to do some cleanup afterwards. This is
19
19
usually handled by :meth: `setUp() ` and :meth: `tearDown() ` methods.
@@ -27,8 +27,8 @@ Some general rules of testing:
27
27
tests as often as needed.
28
28
29
29
- Learn your tools and learn how to run a single test or a test case. Then,
30
- when developing a function inside a module, run this function's tests very
31
- often , ideally automatically when you save the code.
30
+ when developing a function inside a module, run this function's tests
31
+ frequently , ideally automatically when you save the code.
32
32
33
33
- Always run the full test suite before a coding session, and run it again
34
34
after. This will give you more confidence that you did not break anything
@@ -63,11 +63,11 @@ Some general rules of testing:
63
63
64
64
- Another use of the testing code is as an introduction to new developers. When
65
65
someone will have to work on the code base, running and reading the related
66
- testing code is often the best they can do. They will or should discover the
67
- hot spots, where most difficulties arise, and the corner cases. If they have
68
- to add some functionality, the first step should be to add a test and, by this
69
- means, ensure the new functionality is not already a working path that has not
70
- been plugged into the interface.
66
+ testing code is often the best thing that they can do to start . They will
67
+ or should discover the hot spots, where most difficulties arise, and the
68
+ corner cases. If they have to add some functionality, the first step should
69
+ be to add a test to ensure that the new functionality is not already a
70
+ working path that has not been plugged into the interface.
71
71
72
72
The Basics
73
73
::::::::::
0 commit comments