root/releases/pkgcore/0.2.10/dev-notes/tests.rst @ masterdriverz%2540gentoo.org-20070309221744-6u30xw5rb8n13cjj

Revision masterdriverz%2540gentoo.org-20070309221744-6u30xw5rb8n13cjj, 1.3 KB (checked in by Charlie Shepherd <masterdriverz@…>, 22 months ago)

Whitespace fixes

Line 
1========
2Testing
3========
4
5We use twisted.trial for our tests, to run the test framework run:
6
7 trial pkgcore
8
9Your own tests must be stored in pkgcore.test - furthermore, tests must
10pass when ran repeatedly (-u option). You will want at least twisted-2.2
11for that, <2.2 has a few false positives.
12
13Testing for negative assertions
14===============================
15
16When coding it's easy to write test cases asserting that you get result xyz
17from foo, usually asserting the correct flow. This is ok if nothing goes
18wrong, but that doesn't normally happen. :)
19
20Negative assertions (there probably is a better term for it) means asserting
21failure conditions and ensuring that the code handles zyx properly when it
22gets thrown at it. Most test cases seem to miss this, resulting in bugs
23being able to hide away for when things go wrong.
24
25Using --coverage
26================
27
28When writing tests for your code (or for existing code without any tests), it
29is very useful to use --coverage. Run `trial --coverage <path/to/test>`, and
30then check <cwd>/_trial_temp/coverage/<test/module/name>. Any lines prefixed
31with '>>>>>' have not been covered by your tests. This should be rectified
32before your code is merged to mainline (though this is not always possible).
33Those lines prefixed with a number show the number of times that line of code
34is evaluated.
Note: See TracBrowser for help on using the browser.