--- a/TestResultReporter.st Sat Jul 30 10:11:24 2011 +0200
+++ b/TestResultReporter.st Sat Jul 30 10:11:54 2011 +0200
@@ -7,6 +7,32 @@
category:'SUnit-Report'
!
+!TestResultReporter class methodsFor:'documentation'!
+
+documentation
+"
+ public API entries are:
+ |aTestResult|
+
+ aTestResult := aUnitTest suite run.
+ TestResultReporter report:aTestResult format:#xml on: aStream
+"
+!
+
+examples
+"
+ |testResult|
+
+ testResult := RegressionTests::IntegerTest suite run.
+ TestResultReporter report:testResult format:#xml on:Transcript
+"
+! !
+
+!TestResultReporter class methodsFor:'others'!
+
+version_CVS
+ ^ '$Id: TestResultReporter.st,v 1.2 2011-07-30 08:11:54 cg Exp $'
+! !
!TestResultReporter class methodsFor:'reporting'!
@@ -18,17 +44,28 @@
report: aTestResult format: format on: stream
self new report: aTestResult format: format on: stream
+
+ "
+ self report:(RegressionTests::IntegerTest runTests) format:#xml on:Transcript
+ "
+
+ "Modified (comment): / 30-07-2011 / 09:37:53 / cg"
! !
!TestResultReporter methodsFor:'reporting'!
-report:format
+report:formatSymbol
+ "currently supported formatSymbols:
+ xml"
+
|reportFormatSelector|
- reportFormatSelector := self reportFormatSelector:format.
+ reportFormatSelector := self reportFormatSelector:formatSymbol.
(self respondsTo: reportFormatSelector)
- ifTrue:[self perform: reportFormatSelector]
- ifFalse:[self error:'Unsupported format: ', format].
+ ifTrue:[self perform: reportFormatSelector]
+ ifFalse:[self error:'Unsupported format: ', formatSymbol].
+
+ "Modified (comment): / 30-07-2011 / 09:37:31 / cg"
!
report: aTestResult format: format as: stringOrFilename
@@ -53,19 +90,20 @@
!TestResultReporter methodsFor:'reporting - xml'!
reportXml
-
- "JUnit like XML unittest report format"
+ "JUnit-like XML unittest report format"
stream
- nextPutLine: '<?xml version="1.0"?>';
- nextPutLine: '<unittest-results>'.
+ nextPutLine: '<?xml version="1.0"?>';
+ nextPutLine: '<unittest-results>'.
result passed do:[:each|self reportXmlTest: each result: #success].
result failures do:[:each|self reportXmlTest: each result: #failure].
result errors do:[:each|self reportXmlTest: each result: #error].
stream
- nextPutLine: '</unittest-results>'
+ nextPutLine: '</unittest-results>'
+
+ "Modified (format): / 30-07-2011 / 09:54:16 / cg"
!
reportXmlTest: test result: testResult
@@ -73,27 +111,33 @@
"
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'>
+ 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 |
+ | testClassName executionTime |
+
testClassName := self sunitNameOf: test class.
+ "most tests do not know, and return nil here!!"
+ executionTime := test executionTime ? 0.0.
+
stream
- nextPutLine:'<test duration="0.0"'; "As we don't know the duration :-("
- tab; nextPutAll:'status="'; nextPutAll: testResult; nextPutLine:'"';
- tab; nextPutAll:'ficture="'; nextPutAll: testClassName; nextPutLine:'"';
- tab; nextPutAll:'name="'; nextPutAll: test selector; nextPutLine:'"';
- "I seems that some tools requires the file attributes. So we supply one :-)"
- tab; nextPutAll:'file="'; nextPutAll: testClassName , '.st'; nextPutLine:'">'.
+ 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 reportXmlTraceback: test].
stream nextPutLine:'</test>'.
+
+ "Modified: / 30-07-2011 / 10:10:02 / cg"
!
reportXmlTraceback: test
@@ -137,7 +181,7 @@
!TestResultReporter class methodsFor:'documentation'!
version
- ^ '$Id: TestResultReporter.st,v 1.1 2011-06-29 19:15:49 cg Exp $'
+ ^ '$Id: TestResultReporter.st,v 1.2 2011-07-30 08:11:54 cg Exp $'
!
version_SVN