@@ -34,6 +34,17 @@ def run_test_suite():
3434 unittest .TextTestRunner ().run (suite )
3535 os .chdir (original_cwd )
3636
37+ def run_test_suite_with_junit_output ():
38+ try :
39+ import unittest2 as unittest
40+ except ImportError :
41+ import unittest
42+ import xmlrunner
43+ original_cwd = os .path .abspath (os .getcwd ())
44+ os .chdir ('tests' )
45+ suite = unittest .defaultTestLoader .discover ('.' )
46+ xmlrunner .XMLTestRunner (output = '../test-reports' ).run (suite )
47+ os .chdir (original_cwd )
3748
3849class CoverageCommand (Command ):
3950 """setup.py command to run code coverage of the test suite."""
@@ -73,6 +84,20 @@ def finalize_options(self):
7384 def run (self ):
7485 run_test_suite ()
7586
87+ class JunitXmlTestCommand (Command ):
88+ """setup.py command to run the whole test suite."""
89+ description = "Run test full test suite with JUnit-formatted output."
90+ user_options = []
91+
92+ def initialize_options (self ):
93+ pass
94+
95+ def finalize_options (self ):
96+ pass
97+
98+ def run (self ):
99+ run_test_suite_with_junit_output ()
100+
76101
77102class DistCommand (Command ):
78103 """setup.py command to create .spl files for modular input and search
@@ -175,6 +200,7 @@ def exclude(path):
175200
176201 cmdclass = {'coverage' : CoverageCommand ,
177202 'test' : TestCommand ,
203+ 'testjunit' : JunitXmlTestCommand ,
178204 'dist' : DistCommand },
179205
180206 description = "The Splunk Software Development Kit for Python." ,
@@ -202,4 +228,4 @@ def exclude(path):
202228 "Topic :: Software Development :: Libraries :: Python Modules" ,
203229 "Topic :: Software Development :: Libraries :: Application Frameworks" ,
204230 ],
205- )
231+ )
0 commit comments