I have installed nose for python 2.6 and it works fine but I was trying use the --cover-html option to generate a html report. I typed the following command from the command line:
nosetests --cover-html
It ran the tests but did not generate the html.
Am I missing something ?
It's old news but the order of the options is important:
nosetests --with-coverage --cover-erase --cover-html-dir=C:/temp/res --cover-html test.py
You also need the --with-coverage option to enable the coverage plugin in the first place.
Related
Need help!
I have a job on Gitlab ci, that runs tests and reruns failed ones. If there are no failed tests, job fails with exit code 5, that means that there are no tests for running. I found out that there is plugin "pytest-custom_exit_code", but I don't know how to correctly use it.
I need just to add command 'pytest --suppress-no-test-exit-code' to my runner.sh?
It looks like this now:
#!/bin/sh
/usr/local/bin/pytest -m test
/usr/local/bin/pytest -m --last-failed --last-failed-no-failures none test
Assumption here is that plugin is installed first using
pip install pytest-custom_exit_code
command like option pytest --suppress-no-test-exit-code should work after that.
If configuration file like .pytest.ini is used , following lines should be added in it
[pytest]
addopts = --suppress-no-test-exit-code
nosetests --processes=2 --process-timeout=1800 -v --nocapture -a=attr --attr=api src/tests/externalapi/test_accounts_api.py --with-html
doesn't work
console says:
nosetests: error: no such option: --with-html
Build step 'Execute shell' marked build as failure
You can publish test results by adding post build action named “Publish JUnit test result report” in configure section.
You will need to generate *.xml file with Nose, tell Jenkins what is the name of that file and Jenkins will be able to interpret it and display it in nice looking form.
Option which is interesting for you instead of --with-html is --with-xunit.
Documentation for this option is available here.
Is there a way to get a list of all the tests currently recognized by nose, without running them?
According to the doc
--collect-only Enable collect-only: Collect and output test names only, don't run any tests. [COLLECT_ONLY]
However when I do nosetests --collect-only I get:
Ran 101 tests in 0.642s
OK
How can I get names those tests?
Try with the -v option:
nosetests -v --collect-only
If you're trying to debug how nose actually finds your tests, go for -vv
I am struggling to get nosetests to output xml.
I have installed nosexml, then in by PYTHONPATH typed ln -s /usr/lib/python2.7/xml/etree/ elementtree.
Now I can type nosetests -plugins and get a list of plugins including xunit.
If I run
nosetests --with-xunit test.py
then I get a file 'nosetests.xml' with test results. So I try to run nose as follows,
nosetests --with-xunit --processes=1 --process-timeout=8000 test.py
and get a file 'nosetests.xml' that says no tests run.
<?xml version="1.0" encoding="UTF-8"?><testsuite name="nosetests" tests="0" errors="0" failures="0" skip="0"></testsuite>
Can I use --with-xunit with other options?
Recently solution appeared - xunitmp. Checked - works for me.
It is a bug in the xunit plug-in.
By what I see it was not fixed, so at the moment there is no way to use --processes and --with-xunit options together.
I'm trying to output the coverage XML of my nosetests so they show up on Hudson. The line I'm executing is:
nosetests --with-gae -v --all-modules --with-xunit --with-coverage
I see the coverage output in the console, but there's no xml file containing the coverage data. How can I get it to output the coverage xml?
Once you've run the nosetests command, there will be a .coverage data file in the directory. If you then run coverage xml, it will create a Cobertura-compatible XML file from the .coverage file.
There is a plugin written for nosetests to do just this.
You just have to add --with-xcoverage once this package is installed. It can be found at:
https://github.com/cmheisel/nose-xcover