Changes between Version 1 and Version 2 of HowToWriteTests


Ignore:
Timestamp:
2012-03-30T22:42:16Z (13 years ago)
Author:
zooko
Comment:

more about setting up your first test file

Legend:

Unmodified
Added
Removed
Modified
  • HowToWriteTests

    v1 v2  
     1= create a test file =
     2
    13Choose a name for your test file. We'll use {{{test_fname.py}}}:
    24
     
    911}}}
    1012
     13Okay, so it didn't work, because there is no file by that name. Create such a file, with these contents:
     14
     15{{{
     16rom twisted.trial import unittest
     17
     18class T(unittest.TestCase):
     19    def test_a(self):
     20        pass
     21}}}
     22
     23Now install Ned Batchelder's "[http://nedbatchelder.com/code/coverage/ coverage"] tool and run your with code coverage, like this:
     24
     25{{{
     26./bin/tahoe @coverage run --branch --include='src/allmydata/*' @tahoe debug trial allmydata.test.test_fname
     27}}}
     28
     29If you installed coverage from Debian or Ubuntu then you have to name it {{{python-coverage}}}, like this:
     30
     31{{{
     32./bin/tahoe @python-coverage run --branch --include='src/allmydata/*' @tahoe debug trial allmydata.test.test_fname
     33}}}
     34
     35This does the same as running the tests without coverage -- print a list of what happened when each test was run. It also writes out a file named {{{.coverage}}} into the current directory. Run the following command to read that file and produce nice HTML pages:
     36
     37{{{
     38./bin/tahoe @coverage html
     39}}}
     40
     41That will product a directory named {{{htmlcov}}}. View its contents with a web browser.