simplify commands to run tests with coverage

[Imported from Trac: page HowToWriteTests, version 9]
daira 2015-02-25 13:34:10 +00:00
parent 3e587dcc56
commit 0d4aaca537

@ -7,7 +7,7 @@ touch src/allmydata/test/test_fname.py
``` ```
``` ```
./bin/tahoe debug trial --rterrors allmydata.test.test_fname python setup.py trial -s allmydata.test.test_fname
``` ```
Okay, so it didn't work, because there is no file by that name. Create such a file, with these contents: Okay, so it didn't work, because there is no file by that name. Create such a file, with these contents:
@ -27,19 +27,24 @@ Now run it!
Now install Ned Batchelder's "[coverage"](http://nedbatchelder.com/code/coverage/) tool and run your with code coverage, like this: Now install Ned Batchelder's "[coverage"](http://nedbatchelder.com/code/coverage/) tool and run your with code coverage, like this:
``` ```
./bin/tahoe @coverage run --branch --include='src/allmydata/*' @tahoe debug trial --rterrors allmydata.test.test_fname python setup.py trial --coverage -s allmydata.test.test_fname
``` ```
If you installed coverage from Debian or Ubuntu then you have to name it `python-coverage`, like this:
``` ```
./bin/tahoe @python-coverage run --branch --include='src/allmydata/*' @tahoe debug trial --rterrors allmydata.test.test_fname python setup.py trial --coverage -s allmydata.test.test_fname
``` ```
This 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: This 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:
``` ```
./bin/tahoe @coverage html coverage html
```
If you installed coverage from Debian or Ubuntu then you have to name it `python-coverage`, like this:
```
python-coverage html
``` ```
That will product a directory named `htmlcov`. View its contents with a web browser. That will product a directory named `htmlcov`. View its contents with a web browser.