junit -> pythonUnit renames
authorClaus Gittinger <cg@exept.de>
Wed, 03 Aug 2011 12:59:53 +0200
changeset 298 df98ca2a45b6
parent 297 87eb8f911bcf
child 299 4f7577ca5364
junit -> pythonUnit renames
TestResultReporter.st
--- a/TestResultReporter.st	Tue Aug 02 20:14:18 2011 +0200
+++ b/TestResultReporter.st	Wed Aug 03 12:59:53 2011 +0200
@@ -12,12 +12,12 @@
 documentation
 "
     Currently supported formats are:
-        #xml_junit  - a junit-like format
-        #xml        - same, for backward compatibility
-        #tap        - perl TAP unit test format; 
-                      very naive and simple, but there are tools for it...
+        #xml_pythonUnit - a python unit-like xml format
+        #xml            - same, for backward compatibility
+        #tap            - perl TAP unit test format; 
+                          very naive and simple, but there are tools for it...
         #xml_perfPublisher
-                    - can be processed by the perfPublisher jenkins/hudson plugin
+                        - can be processed by the perfPublisher jenkins/hudson plugin
 
     public API entry:
         |aTestResult|
@@ -28,7 +28,7 @@
     modifications:
         cg: I think the name 'xml' is too unspecific; 
             I may want to add a whole bunch of additional xml-based formats. 
-            So I changed #xml to xml_junit (but still support the original #xml for bw-compatibility).
+            So I changed #xml to xml_pythonUnit (but still support the original #xml for bw-compatibility).
             You may be especially interested in xml_perfPublisher, which is great to present
             nice reports in jenkins/hudson...
 
@@ -52,7 +52,7 @@
     |testResult|
 
     testResult := RegressionTests::IntegerTest suite run.
-    TestResultReporter report:testResult format:#xml_junit on:Transcript. 
+    TestResultReporter report:testResult format:#xml_pythonUnit on:Transcript. 
                                                                                [exEnd]
 
                                                                                [exBegin]
@@ -94,47 +94,6 @@
 "
 !
 
-format_xml_junit
-"
-    sample output for one of the st/x regression-tests looks like:
-
-<?xml version='1.0'?>
-<unittest-results>
-<test duration='0'
-    status='success'
-    ficture='RegressionTests::IntegerTest'
-    name='testComparing'
-    file='RegressionTests::IntegerTest.st'>
-</test>
-<test duration='0'
-    status='success'
-    ficture='RegressionTests::IntegerTest'
-    name='testConstants'
-    file='RegressionTests::IntegerTest.st'>
-</test>
-<test duration='0'
-    status='success'
-    ficture='RegressionTests::IntegerTest'
-    name='testCreationFromBytes1'
-    file='RegressionTests::IntegerTest.st'>
-</test>
-<test duration='0'
-    status='success'
-    ficture='RegressionTests::IntegerTest'
-    name='testDivision'
-    file='RegressionTests::IntegerTest.st'>
-</test>
-<test duration='0'
-    status='success'
-    ficture='RegressionTests::IntegerTest'
-    name='testEncodeDecode'
-    file='RegressionTests::IntegerTest.st'>
-</test>
-...
-</unittest-results>
-"
-!
-
 format_xml_perfPublisher
 "
     sample output looks like:
@@ -182,6 +141,47 @@
   </test>
 </report>
 "
+!
+
+format_xml_pythonUnit
+"
+    sample output for one of the st/x regression-tests looks like:
+
+<?xml version='1.0'?>
+<unittest-results>
+<test duration='0'
+    status='success'
+    ficture='RegressionTests::IntegerTest'
+    name='testComparing'
+    file='RegressionTests::IntegerTest.st'>
+</test>
+<test duration='0'
+    status='success'
+    ficture='RegressionTests::IntegerTest'
+    name='testConstants'
+    file='RegressionTests::IntegerTest.st'>
+</test>
+<test duration='0'
+    status='success'
+    ficture='RegressionTests::IntegerTest'
+    name='testCreationFromBytes1'
+    file='RegressionTests::IntegerTest.st'>
+</test>
+<test duration='0'
+    status='success'
+    ficture='RegressionTests::IntegerTest'
+    name='testDivision'
+    file='RegressionTests::IntegerTest.st'>
+</test>
+<test duration='0'
+    status='success'
+    ficture='RegressionTests::IntegerTest'
+    name='testEncodeDecode'
+    file='RegressionTests::IntegerTest.st'>
+</test>
+...
+</unittest-results>
+"
 ! !
 
 !TestResultReporter class methodsFor:'queries'!
@@ -190,7 +190,7 @@
    "return a list of formats and short-info-string, as per supported format symbol"
 
     ^ #(
-        (#'xml_junit'           'a junit-like format')
+        (#'xml_pythonUnit'      'a python unit-like xml format')
         (#'xml_perfPublisher'   'xml-based format for jenkins/hudson')
         (#'tap'                 'perl TAP unit test format')
     )
@@ -220,7 +220,7 @@
 
 report:formatSymbol
     "currently supported formatSymbols:
-            xml_junit, tap"
+            xml_pythonUnit, xml_perfPublisher, tap"
 
     |reportFormatSelector|
 
@@ -229,7 +229,7 @@
         ifTrue:[self perform: reportFormatSelector]
         ifFalse:[self error:'Unsupported format: ', formatSymbol].
 
-    "Modified (comment): / 30-07-2011 / 11:40:42 / cg"
+    "Modified (comment): / 03-08-2011 / 12:57:54 / cg"
 !
 
 report: aTestResult format: format as: stringOrFilename
@@ -307,95 +307,6 @@
     "Created: / 30-07-2011 / 10:28:06 / cg"
 ! !
 
-!TestResultReporter methodsFor:'reporting - xml-junit'!
-
-reportXml
-    "backward compatible: JUnit-like XML unittest report format"
-
-    self reportXml_junit
-
-    "Created: / 30-07-2011 / 11:41:24 / cg"
-!
-
-reportXml_junit
-    "JUnit-like XML unittest report format"
-
-    stream
-        nextPutLine: '<?xml version="1.0"?>';
-        nextPutLine: '<unittest-results>'.
-
-    result passed   do:[:each|self reportXml_junitTest: each result: #success].
-    result failures do:[:each|self reportXml_junitTest: each result: #failure].
-    result errors   do:[:each|self reportXml_junitTest: each result: #error].
-
-    stream
-        nextPutLine: '</unittest-results>'
-
-    "Created: / 30-07-2011 / 11:37:10 / cg"
-!
-
-reportXml_junitTest: test result: testResult
-
-    "
-    Example:
-    <test
-        duration='0.0188629627228'
-        status='error'
-        fixture='bitten.tests.web_ui.SourceFileLinkFormatterTestCase'
-        name='test_format_link_not_in_repos_with_line'
-        file='/usr/src/trac-bitten-0.6b2.dfsg/bitten/tests/web_ui.py'>
-    "
-
-    | testClassName executionTime |
-
-    testClassName := self sunitNameOf: test class.
-
-    "most tests do not know, and return nil here!!"
-    executionTime := (test executionTime ? 0.0) printString.
-
-    stream
-        nextPutAll:'<test duration="'; nextPutAll:executionTime; nextPutLine:'"'; 
-        tab; nextPutAll:'status="'; nextPutAll: testResult; nextPutLine:'"';
-        tab; nextPutAll:'ficture="'; nextPutAll: testClassName; nextPutLine:'"';
-        tab; nextPutAll:'name="'; nextPutAll: test selector; nextPutLine:'"';
-        "It seems that some tools requires the file attributes. So we supply one :-)"
-        tab; nextPutAll:'file="'; nextPutAll: testClassName , '.st'; nextPutLine:'">'.
-
-    testResult ~= #success ifTrue:[self reportXml_junitTraceback: test].
-
-    stream nextPutLine:'</test>'.
-
-    "Created: / 30-07-2011 / 11:37:47 / cg"
-!
-
-reportXml_junitTraceback: test
-
-    "
-        Prints a traceback to the stream.
-        This is dialect-specific, so we have to check...
-    "
-
-    "Smalltalk/X dialect detection..."
-    ((Smalltalk respondsTo: #isSmalltalkX) and:[Smalltalk isSmalltalkX])
-        ifTrue:[^self reportXml_junitTracebackStX: test]
-
-    "Created: / 30-07-2011 / 11:37:36 / cg"
-!
-
-reportXml_junitTracebackStX: test
-    stream nextPutLine:'<traceback><!![CDATA['.
-
-    [ test debug ]
-        on: GenericException
-        do: [:ex|
-            ex suspendedContext fullPrintAllOn: stream].
-
-    stream nextPutLine:']]></traceback>'.
-
-    "Modified: / 07-12-2009 / 14:06:48 / Jan Vrany <jan.vrant@fit.cvut.cz>"
-    "Created: / 30-07-2011 / 11:37:26 / cg"
-! !
-
 !TestResultReporter methodsFor:'reporting - xml-perfPublisher'!
 
 reportXml_perfPublisher
@@ -522,18 +433,98 @@
     stream
         nextPutLine:'  </result>'.
 
-"/
-"/             nextPutAll:'duration="'; nextPutAll:executionTime; nextPutLine:'"'; 
-"/        tab; nextPutAll:'status="'; nextPutAll: testResult; nextPutLine:'"';
-"/        tab; nextPutAll:'ficture="'; nextPutAll: testClassName; nextPutLine:'"';
-"/        "It seems that some tools requires the file attributes. So we supply one :-)"
-"/        tab; nextPutAll:'file="'; nextPutAll: testClassName , '.st'; nextPutLine:'">'.
-"/
-"/    testResult ~= #success ifTrue:[self reportXml_junitTraceback: test].
+    stream nextPutLine:'</test>'.
+
+    "Created: / 30-07-2011 / 12:19:03 / cg"
+! !
+
+!TestResultReporter methodsFor:'reporting - xml-python-unit'!
+
+reportXml
+    "backward compatible: python unit-like XML unittest report format"
+
+    self reportXml_pythonUnit
+
+    "Created: / 30-07-2011 / 11:41:24 / cg"
+!
+
+reportXml_pythonUnit
+    "python unittest-like XML unittest report format"
+
+    stream
+        nextPutLine: '<?xml version="1.0"?>';
+        nextPutLine: '<unittest-results>'.
+
+    result passed   do:[:each|self reportXml_pythonTest: each result: #success].
+    result failures do:[:each|self reportXml_pythonTest: each result: #failure].
+    result errors   do:[:each|self reportXml_pythonTest: each result: #error].
+
+    stream
+        nextPutLine: '</unittest-results>'
+
+    "Created: / 03-08-2011 / 12:56:04 / cg"
+!
+
+reportXml_pythonUnitTest: test result: testResult
+
+    "
+    Example:
+    <test
+        duration='0.0188629627228'
+        status='error'
+        fixture='bitten.tests.web_ui.SourceFileLinkFormatterTestCase'
+        name='test_format_link_not_in_repos_with_line'
+        file='/usr/src/trac-bitten-0.6b2.dfsg/bitten/tests/web_ui.py'>
+    "
+
+    | testClassName executionTime |
+
+    testClassName := self sunitNameOf: test class.
+
+    "most tests do not know, and return nil here!!"
+    executionTime := (test executionTime ? 0.0) printString.
+
+    stream
+        nextPutAll:'<test duration="'; nextPutAll:executionTime; nextPutLine:'"'; 
+        tab; nextPutAll:'status="'; nextPutAll: testResult; nextPutLine:'"';
+        tab; nextPutAll:'ficture="'; nextPutAll: testClassName; nextPutLine:'"';
+        tab; nextPutAll:'name="'; nextPutAll: test selector; nextPutLine:'"';
+        "It seems that some tools requires the file attributes. So we supply one :-)"
+        tab; nextPutAll:'file="'; nextPutAll: testClassName , '.st'; nextPutLine:'">'.
+
+    testResult ~= #success ifTrue:[self reportXml_pythonUnitTraceback: test].
 
     stream nextPutLine:'</test>'.
 
-    "Created: / 30-07-2011 / 12:19:03 / cg"
+    "Created: / 03-08-2011 / 12:56:37 / cg"
+!
+
+reportXml_pythonUnitTraceback: test
+
+    "
+        Prints a traceback to the stream.
+        This is dialect-specific, so we have to check...
+    "
+
+    "Smalltalk/X dialect detection..."
+    ((Smalltalk respondsTo: #isSmalltalkX) and:[Smalltalk isSmalltalkX])
+        ifTrue:[^self reportXml_pythonUnitTracebackStX: test]
+
+    "Created: / 03-08-2011 / 12:56:54 / cg"
+!
+
+reportXml_pythonUnitTracebackStX: test
+    stream nextPutLine:'<traceback><!![CDATA['.
+
+    [ test debug ]
+        on: GenericException
+        do: [:ex|
+            ex suspendedContext fullPrintAllOn: stream].
+
+    stream nextPutLine:']]></traceback>'.
+
+    "Modified: / 07-12-2009 / 14:06:48 / Jan Vrany <jan.vrant@fit.cvut.cz>"
+    "Created: / 03-08-2011 / 12:57:01 / cg"
 ! !
 
 !TestResultReporter methodsFor:'utilities'!
@@ -551,11 +542,11 @@
 !TestResultReporter class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestResultReporter.st,v 1.15 2011-08-02 16:21:18 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestResultReporter.st,v 1.16 2011-08-03 10:59:53 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestResultReporter.st,v 1.15 2011-08-02 16:21:18 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestResultReporter.st,v 1.16 2011-08-03 10:59:53 cg Exp $'
 !
 
 version_SVN