@@ -34,6 +34,17 @@ def run_test_suite():
34
34
unittest .TextTestRunner ().run (suite )
35
35
os .chdir (original_cwd )
36
36
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 )
37
48
38
49
class CoverageCommand (Command ):
39
50
"""setup.py command to run code coverage of the test suite."""
@@ -73,6 +84,20 @@ def finalize_options(self):
73
84
def run (self ):
74
85
run_test_suite ()
75
86
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
+
76
101
77
102
class DistCommand (Command ):
78
103
"""setup.py command to create .spl files for modular input and search
@@ -175,6 +200,7 @@ def exclude(path):
175
200
176
201
cmdclass = {'coverage' : CoverageCommand ,
177
202
'test' : TestCommand ,
203
+ 'testjunit' : JunitXmlTestCommand ,
178
204
'dist' : DistCommand },
179
205
180
206
description = "The Splunk Software Development Kit for Python." ,
@@ -202,4 +228,4 @@ def exclude(path):
202
228
"Topic :: Software Development :: Libraries :: Python Modules" ,
203
229
"Topic :: Software Development :: Libraries :: Application Frameworks" ,
204
230
],
205
- )
231
+ )
0 commit comments