nose でテスト実行時のカバレッジを取得する。
カバレッジを取得する
nose と python-coverage がインストールされている必要があります。
nosetests コマンド実行時に、 --with-coverage オプションを付けることでカバレッジを取得できます。
--cover-tests を付与すると実行されたテスト用コードのカバレッジを取得できます。
インストール手順
$ easy_install -ZU nose $ easy_install -ZU coverage
nose からのカバレッジ取得し、HTMLに変換する。
$ cd myproject $ nosetests -v --with-coverage tests/test.py $ coverage html
- coverage xml とすることで、Jenkins Cobertura Plugin と連携できます。
Jenkins との連携例
$ nosetests -v -w tests/ --with-coverage --with-xunit $ coverage xml