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


I have had success with unittest-xml-reporting:

TEST_RUNNER = 'xmlrunner.extra.djangotestrunner.XMLTestRunner'


The output directory can be configured with the TEST_OUTPUT_DIR setting.


You may still use nose runner:

INSTALLED_APPS += ['django_nose']
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'


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!


Leave a comment