[Fixed]-What Django TEST_RUNNER supports xunit xml and logging capture?

12👍

I have had success with unittest-xml-reporting:

TEST_RUNNER = 'xmlrunner.extra.djangotestrunner.XMLTestRunner'

https://github.com/xmlrunner/unittest-xml-reporting#django-support

The output directory can be configured with the TEST_OUTPUT_DIR setting.

5👍

You may still use nose runner:

INSTALLED_APPS += ['django_nose']
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
NOSE_ARGS = [
    '--with-xunit',
    '--xunit-file=nosetests.xml',
    '--with-coverage',
    '--cover-erase',
    '--cover-xml',
    '--cover-xml-file=nosecover.xml',
]
👤awka

2👍

So pytest produces some very nice test output. I’ve unset TEST_RUNNER in settings.py and changed my test script to:

python -m coverage run -m pytest --junitxml=./reports/junit.xml
python -m coverage report --include="app/*" --show-missing --fail-under=100
python -m coverage xml --include="app/*" -o ./reports/coverage.xml

This works, and captures ALL logging output (nose was a little buggy and let one or two logging statements slip through, very strange behavior).

The only thing is that I’m a django novice so I don’t know if there are any bad side-effects of not using manage.py test for testing django. Any guidance is appreciated, thanks!

👤robru

Leave a comment