TestResultReporter.st
changeset 504 81de3dfd9886
parent 502 86ebb087d590
child 511 b42b302eb952
--- a/TestResultReporter.st	Tue Nov 06 23:02:31 2012 +0100
+++ b/TestResultReporter.st	Wed Nov 07 02:08:39 2012 +0100
@@ -60,6 +60,7 @@
 
     suite := TestSuite named:'SelfTest'.
     #(
+        'JavaScriptTests'
         'FloatTest'
         'IntegerTest'
     ) do:[:className |
@@ -532,7 +533,10 @@
     errorMessage := errorMessage copyReplaceAll:$" withAll:'"'.
 
     stream
-        nextPutAll:('    <%1 message="%2" type="%3">' bindWith:stateTag with:errorMessage with:errorType);
+        nextPutAll:('    <%1 message="%2" type="%3">' 
+                            bindWith:stateTag 
+                            with:errorMessage 
+                            with:errorType);
         cr.
 
     "
@@ -570,54 +574,39 @@
         nextPutAll:(' status="%1"' bindWith:testResult);
         nextPutAll:(' time="%1"' bindWith:executionTimeString).
 
-    testResult = (TestResult statePass) ifTrue:[
-        stream nextPutAll:' />'; cr.
+    ((testResult = TestResult statePass) 
+    and:[ testOutcome collectedOutput isEmptyOrNil ]) ifTrue:[
+        stream nextPutAll:'/>'; cr.
     ] ifFalse:[
         stream nextPutAll:'>'; cr.
-        self reportXml_jUnitResultAndTraceback:testOutcome state:testResult.
+
+        testResult = TestResult statePass ifFalse:[
+            self reportXml_jUnitResultAndTraceback:testOutcome state:testResult.
 
-        testClass := Smalltalk classNamed:testClassName.
-        testClass notNil ifTrue:[
-            testClassSourceFile := TestResultStX sourceFilenameOfClass:testClass.
-            testClassSourceFile notNil ifTrue:[
-                stream
-                    nextPutAll:'    <system-out>'; cr;
-                    nextPutAll:('[[ATTACHMENT | %1]]' bindWith:testClassSourceFile); cr;
-                    nextPutAll:'    </system-out>'; cr.
-            ]
+            "/ generate a link to the source file
+            testClass := Smalltalk classNamed:testClassName.
+            testClass notNil ifTrue:[
+                testClassSourceFile := TestResultStX sourceFilenameOfClass:testClass.
+                testClassSourceFile notNil ifTrue:[
+                    stream
+                        nextPutAll:'    <system-err>'; cr;
+                        nextPutAll:('[[ATTACHMENT|%1]]' bindWith:testClassSourceFile); cr;
+                        nextPutAll:'    </system-err>'; cr.
+                ]
+            ].
         ].
-        stream
-            nextPutAll:'  </testcase>'; cr.
+
+        testOutcome collectedOutput notEmptyOrNil ifTrue:[
+            stream
+                nextPutAll:'    <system-out>'; cr;
+                nextPutAll: (testOutcome collectedOutput copyReplaceAll:$" withAll:'&quot;');
+                nextPutAll:'    </system-out>'; cr.
+        ].
+
+        stream nextPutAll:'  </testcase>'; cr.
     ].
 
     "Created: / 18-08-2011 / 20:30:50 / cg"
-!
-
-sourceFilenameOfClass:aClass
-    "that is ST/X specific"
-
-    "Smalltalk/X dialect detection..."
-    ((Smalltalk respondsTo: #isSmalltalkX) and:[Smalltalk isSmalltalkX]) ifTrue:[ 
-        |sourceStream testClassSourceFile|
-
-        sourceStream := aClass sourceStream.
-        sourceStream notNil ifTrue:[
-            [
-                sourceStream := sourceStream stream.
-                sourceStream isFileStream ifTrue:[
-                    testClassSourceFile := sourceStream pathName asFilename pathName.
-                ].
-            ] ensure:[
-                sourceStream close.
-            ]
-        ].
-        ^ testClassSourceFile
-    ].
-
-    "/ use something like...
-"/    ^ aClass classFilename asFilename pathName.
-
-    ^ nil
 ! !
 
 !TestResultReporter methodsFor:'reporting - xml-perfPublisher'!
@@ -860,11 +849,11 @@
 !TestResultReporter class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestResultReporter.st,v 1.50 2012-11-06 22:01:34 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestResultReporter.st,v 1.51 2012-11-07 01:08:39 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestResultReporter.st,v 1.50 2012-11-06 22:01:34 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestResultReporter.st,v 1.51 2012-11-07 01:08:39 cg Exp $'
 !
 
 version_SVN