With following tox.ini, coverage.xml is not generated, but .covearge is created.
The output is listed below.
commands = py.test ./tests --junitxml=unittest-{envname}.xml --cov=mypkg --cov-report xml
py27 runtests: PYTHONHASHSEED='123456'
py27 runtests: commands[0] | py.test ./tests --junitxml=unittest-py27.xml --cov=mypkg --cov-report xml
============================= test session starts ==============================
platform linux2 -- Python 2.7.10, pytest-2.9.1, py-1.4.31, pluggy-0.3.1
rootdir: /data/jenkins/workspace/mypkg-unittest, inifile:
plugins: cov-2.3.0
tests/test_sth.py ..........
generated xml file: /data/jenkins/workspace/mypkg-unittest/unittest-py27.xml
---------- coverage: platform linux2, python 2.7.10-final-0 ----------
Coverage XML written to file coverage.xml
========================== 10 passed in 21.87 seconds ==========================
___________________________________ summary ____________________________________
py27: commands succeeded
@SDET_Liang the output claims the file was written, can you take a look at the folder called rootdir?
it's likely rather about finding where it was written, and the original poster is not here, likely. so closing.
I'm having exactly the same problem - the file gets not written. And it is nowhere on my whole drive.
A workaround is to use absolute paths like this:
py.test --cov {envsitepackagesdir}/<package> --cov-report xml:{envdir}/../../coverage.xml --junitxml=unittest_{envname}.xml
But the issue is not related to tox because I have the same issue running pytest with the pytest-cov plugin from command line.
Hi @ubmarco, thanks for providing the workaround. As you say it is not a tox issue though, but doesn't hurt to have this here, for other seekers :)
My tests were changing the current working directory to a temporary directory. It seems that this change messes up pytest-cov as it relies on the working directory to be where you ran the tests from. My fix was to simply add a simple pytest fixture with autouse=True which resets the current working directory after each test.
Most helpful comment
I'm having exactly the same problem - the file gets not written. And it is nowhere on my whole drive.
A workaround is to use absolute paths like this:
py.test --cov {envsitepackagesdir}/<package> --cov-report xml:{envdir}/../../coverage.xml --junitxml=unittest_{envname}.xmlBut the issue is not related to tox because I have the same issue running pytest with the pytest-cov plugin from command line.