diff options
author | Gaurang033 <gaurangnshah@gmail.com> | 2014-12-12 17:01:01 +0530 |
---|---|---|
committer | Gaurang033 <gaurangnshah@gmail.com> | 2014-12-14 20:21:54 +0530 |
commit | 3f930d734237a7b6b68b1b7dadb12fa25458bd49 (patch) | |
tree | 57c28313d9d491e546479146c5f3eec17ebc8c16 /nose | |
parent | 347352af79dfced2827266986a22c0259e1a8012 (diff) | |
download | nose-3f930d734237a7b6b68b1b7dadb12fa25458bd49.tar.gz |
Fix #859 Xunit plug-in not able to change testsuite name
Added command line parameter in Xunit plug-in to specify test suite
name. Also added functional test case.
Incorporated Comments
Diffstat (limited to 'nose')
-rw-r--r-- | nose/plugins/xunit.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/nose/plugins/xunit.py b/nose/plugins/xunit.py index e1ec0e1..90b52f5 100644 --- a/nose/plugins/xunit.py +++ b/nose/plugins/xunit.py @@ -19,6 +19,9 @@ under the Post-build Actions and enter this value for Test report XMLs:: If you need to change the name or location of the file, you can set the ``--xunit-file`` option. +If you need to change the name of the test suite, you can set the +``--xunit-testsuite-name`` option. + Here is an abbreviated version of what an XML test report might look like:: <?xml version="1.0" encoding="UTF-8"?> @@ -155,7 +158,7 @@ class Xunit(Plugin): taken = time() - self._timer else: # test died before it ran (probably error in setup()) - # or success/failure added before test started probably + # or success/failure added before test started probably # due to custom TestResult munging taken = 0.0 return taken @@ -176,6 +179,13 @@ class Xunit(Plugin): "Default is nosetests.xml in the working directory " "[NOSE_XUNIT_FILE]")) + parser.add_option( + '--xunit-testsuite-name', action='store', + dest='xunit_testsuite_name', metavar="PACKAGE", + default=env.get('NOSE_XUNIT_TESTSUITE_NAME', 'nosetests'), + help=("Name of the testsuite in the xunit xml, generated by plugin. " + "Default test suite name is nosetests.")) + def configure(self, options, config): """Configures the xunit plugin.""" Plugin.configure(self, options, config) @@ -188,6 +198,7 @@ class Xunit(Plugin): } self.errorlist = [] self.error_report_file_name = os.path.realpath(options.xunit_file) + self.xunit_testsuite_name = options.xunit_testsuite_name def report(self, stream): """Writes an Xunit-formatted XML file @@ -198,11 +209,12 @@ class Xunit(Plugin): self.error_report_file = codecs.open(self.error_report_file_name, 'w', self.encoding, 'replace') self.stats['encoding'] = self.encoding + self.stats['testsuite_name'] = self.xunit_testsuite_name self.stats['total'] = (self.stats['errors'] + self.stats['failures'] + self.stats['passes'] + self.stats['skipped']) self.error_report_file.write( u'<?xml version="1.0" encoding="%(encoding)s"?>' - u'<testsuite name="nosetests" tests="%(total)d" ' + u'<testsuite name="%(testsuite_name)s" tests="%(total)d" ' u'errors="%(errors)d" failures="%(failures)d" ' u'skip="%(skipped)d">' % self.stats) self.error_report_file.write(u''.join([force_unicode(e, self.encoding) |