I got some of our project packages installed in a venv
by a jenkins job. After installing, the job pulls some unittests from a separate repository and runs them against the installed package.
My problem is coverage
only covers the test scripts but not the installed packages.
Here's the folder structure:
JenkinsWorkspace
|_Venv
|_MyProject
|_trunk
|_Python
|_Package1
|_Package2
|_temp_tests
|_test_suite1.py
|_...
So for further explanation, I iterate over the packages in MyProject
, checkout the tests for each one into temp_tests
, cd
in temp_tests
and call nose2 -t ..\..\..\Venv\Lib\site-packages
I thought the -t
param would set the top level directory, and use the stuff installed there. And yes, the tests run succesfully. But the coverage
only covers the test suites themselves.
Is there a way to tell nose to do the coverage for the installed package?
For completeness here my unittest.cfg
:
[coverage]
coverage-report = term-missing
always-on = True
coverage-config = .coveragerc
[junit-xml]
always-on = True
keep_restricted = False
path = nose2-junit.xml
test_fullname = False
and .coveragerc
:
# .coveragerc
[run]
branch = True
[report]
show_missing = True
omit =
build/*
tests/*
setup.py
*/__init__.py
I solved my problem by using the coverage
package after testing.
I did:
nose2 --plugin nose2.plugins.junitxml -s tests -c unittest.cfg
python -m coverage xml
where the folder tests
is containing my tests.
My unittest.cfg
is set to:
[coverage]
coverage-report = term-missing
always-on = True
coverage-config = .coveragerc
[junit-xml]
always-on = True
keep_restricted = False
path = nose2-junit.xml
test_fullname = False
And in .coveragerc
I excluded all unwanted (system) packages:
# .coveragerc
[run]
branch = True
[report]
show_missing = True
omit =
build/*
tests/*
setup.py
*/__init__.py
*/nose/*
*/pkg_resources/*
*/six.py
*/nose2/*
*/coverage/*
*/cov_core.py