From ca9e38c3d95a871eef26d2d927b5c7e4fd90c55f Mon Sep 17 00:00:00 2001 From: Sascha Peilicke Date: Thu, 8 Sep 2011 11:42:45 +0200 Subject: [PATCH] Generate JUnit-compatible XML test result reports if 'xmlrunner' is available. --- .gitignore | 1 + tests/suite.py | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6363e1de..78443b8f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ *.swp tags build +tests/junit-xml-results diff --git a/tests/suite.py b/tests/suite.py index d4a3379f..8e5142cb 100644 --- a/tests/suite.py +++ b/tests/suite.py @@ -1,5 +1,13 @@ +import os.path import sys import unittest + +try: + import xmlrunner # JUnit like XML reporting + have_xmlrunner = True +except ImportError: + have_xmlrunner = False + import test_update import test_addfiles import test_deletefiles @@ -28,5 +36,9 @@ suite.addTests(test_package_status.suite()) suite.addTests(test_project_status.suite()) suite.addTests(test_request.suite()) suite.addTests(test_setlinkrev.suite()) -result = unittest.TextTestRunner(verbosity=1).run(suite) + +if have_xmlrunner: + result = xmlrunner.XMLTestRunner(output=os.path.join(os.getcwd(), 'junit-xml-results')).run(suite) +else: + result = unittest.TextTestRunner(verbosity=1).run(suite) sys.exit(not result.wasSuccessful())