Skip to content

Instantly share code, notes, and snippets.

@goodtune
Last active October 19, 2017 23:27
Show Gist options
  • Save goodtune/90cb7269b2dc76e71c5530fc9547043d to your computer and use it in GitHub Desktop.
Save goodtune/90cb7269b2dc76e71c5530fc9547043d to your computer and use it in GitHub Desktop.
How to run unit tests in parallel and produce JUnit XML output

nose + junit report

I have been using the excellent unittest-xml-report for my simpler needs, however I now have a really long running test suite that I need to use parallelization for performance reasons.

Reading #2 I learned of a work-around so this is a test of it that I will try to apply to my use case.

import time
import unittest
class LongTestCase(unittest.TestCase):
_multiprocess_can_split_ = True
def test_sleep_1(self):
time.sleep(1)
def test_sleep_5(self):
time.sleep(5)
def test_sleep_10(self):
time.sleep(10)
def test_sleep_15(self):
time.sleep(15)
[tox]
skipsdist = True
[testenv]
deps =
nose
junit_xml
nose_xunitmp
commands =
nosetests --processes=8 --process-timeout=20 --with-xunitmp --xunitmp-file report.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment