![](/img/trans.png)
[英]Code Coverage Report for AWS Lambda Integration test using Python
[英]Run test and collect the coverage report using a single command
我正在使用Coverage.py包來收集覆蓋率報告。
現在,我通過運行如下兩個命令來收集覆蓋率報告:
venv) ☁ python-codelab [master] ⚡ coverage run /Users/ldu020/workspace/github.com/mrdulin/python-codelab/src/unittest/with-asyncio/test_person.py
test_create (__main__.TestPerson)
create person ... ok
----------------------------------------------------------------------
Ran 1 test in 0.002s
OK
(venv) ☁ python-codelab [master] ⚡ coverage report
Name Stmts Miss Cover
--------------------------------------------------------------
src/unittest/with-asyncio/person.py 7 0 100%
src/unittest/with-asyncio/test_person.py 21 0 100%
--------------------------------------------------------------
TOTAL 28 0 100%
coverage run
coverage report
如您所見,我運行了兩個命令。 我正在尋找一種能夠運行測試並通過單個命令而不是兩個命令收集覆蓋率報告的方法。 一些命令如:
coverage run --coverage script.py
怎么做?
榮譽屬於@MarekSchwarz。
使用coverage run script.py && coverage report
是一種方法。
例如
(venv) ☁ python-codelab [master] ⚡ coverage run /Users/ldu020/workspace/github.com/mrdulin/python-codelab/src/unittest/with-asyncio/test_person.py && coverage report -m
test_create (__main__.TestPerson)
create person ... ok
----------------------------------------------------------------------
Ran 1 test in 0.003s
OK
Name Stmts Miss Cover Missing
------------------------------------------------------------------------
src/unittest/with-asyncio/person.py 7 0 100%
src/unittest/with-asyncio/test_person.py 21 0 100%
------------------------------------------------------------------------
TOTAL 28 0 100%
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.