152 | | Unit tests should test one method only. This allows you to easily identify what failed if the test fails. |
153 | | Unit tests should not be coupled together, therefore one unit test CANNOT rely on another unit test having completed first. |
154 | | Unit tests should use small and simple data sets. |
155 | | Tests should be fast, ideally really fast - certainly not more than a few seconds. |
156 | | Untestable code is a code-smell, if you can't get the code under test it probably needs refactoring. |
157 | | Weight your testing to be destructive rather than demonstrative. Destructive tests are more efficient in finding bugs. |
158 | | Use long and descriptive names for testing functions. The reason is testing functions are never called explicitly. square() or even sqr() is ok in running code, but in testing code you would have names such as test_square_of_number_2(),test_square_negative_number(). These function names are displayed when a test fails, and should be as descriptive as possible. |
159 | | Attributes of a good test: Fast, Clear, Isolated, Reliable |
| 152 | * Unit tests should test one method only. This allows you to easily identify what failed if the test fails. |
| 153 | * Unit tests should not be coupled together, therefore one unit test CANNOT rely on another unit test having completed first. |
| 154 | * Unit tests should use small and simple data sets. |
| 155 | * Tests should be fast, ideally really fast - certainly not more than a few seconds. |
| 156 | * Untestable code is a code-smell, if you can't get the code under test it probably needs refactoring. |
| 157 | * Weight your testing to be destructive rather than demonstrative. Destructive tests are more efficient in finding bugs. |
| 158 | * Use long and descriptive names for testing functions. The reason is testing functions are never called explicitly. square() or even sqr() is ok in running code, but in testing code you would have names such as test_square_of_number_2(),test_square_negative_number(). These function names are displayed when a test fails, and should be as descriptive as possible. |
| 159 | * Attributes of a good test: Fast, Clear, Isolated, Reliable |
173 | | Code reviews by another developer are encouraged for minor functionality and required for major changes |
174 | | When developing in the branch it is easy to ask for pull requests. One can also test your code easily by pulling your branch and not messing up with master branch |
175 | | Follow the standard practices: |
176 | | Review no more than 400 lines of code at a time |
177 | | Take your time. Inspection rates should be under 500 LOC per hour |
178 | | Don't review code for more than 90 minutes at a time |
179 | | Authors should annotate source code before the review. (Annotations guide the reviewer through the changes, showing which files to look at first and defending the reason behind each code modification. Annotations should be directed at other reviewers to ease the process and provide more depth in context) |
180 | | Use checklists - they substantially improve results for both authors and reviewers (It's very likely that each person on your team makes the same 10 mistakes over and over. Omissions in particular are the hardest defects to find because it's difficult to review something that isn't there. Checklists are the most effective way to eliminate frequently made errors and to combat the challenges of omission finding) |
181 | | Remember to review related unit tests - they are as important as the code. |
182 | | Verify that the defects are actually fixed |
| 173 | * Code reviews by another developer are encouraged for minor functionality and required for major changes |
| 174 | * When developing in the branch it is easy to ask for pull requests. One can also test your code easily by pulling your branch and not messing up with master branch |
| 175 | * Follow the standard practices: |
| 176 | 1. Review no more than 400 lines of code at a time |
| 177 | 2. Take your time. Inspection rates should be under 500 LOC per hour |
| 178 | 3. Don't review code for more than 90 minutes at a time |
| 179 | 4. Authors should annotate source code before the review. (Annotations guide the reviewer through the changes, showing which files to look at first and defending the reason behind each code modification. Annotations should be directed at other reviewers to ease the process and provide more depth in context) |
| 180 | 5. Use checklists - they substantially improve results for both authors and reviewers (It's very likely that each person on your team makes the same 10 mistakes over and over. Omissions in particular are the hardest defects to find because it's difficult to review something that isn't there. Checklists are the most effective way to eliminate frequently made errors and to combat the challenges of omission finding) |
| 181 | 6. Remember to review related unit tests - they are as important as the code. |
| 182 | 7. Verify that the defects are actually fixed |