5 classVariableNames:'' |
5 classVariableNames:'' |
6 poolDictionaries:'' |
6 poolDictionaries:'' |
7 category:'SUnit-Report' |
7 category:'SUnit-Report' |
8 ! |
8 ! |
9 |
9 |
|
10 !TestResultReporter class methodsFor:'documentation'! |
|
11 |
|
12 documentation |
|
13 " |
|
14 public API entries are: |
|
15 |aTestResult| |
|
16 |
|
17 aTestResult := aUnitTest suite run. |
|
18 TestResultReporter report:aTestResult format:#xml on: aStream |
|
19 " |
|
20 ! |
|
21 |
|
22 examples |
|
23 " |
|
24 |testResult| |
|
25 |
|
26 testResult := RegressionTests::IntegerTest suite run. |
|
27 TestResultReporter report:testResult format:#xml on:Transcript |
|
28 " |
|
29 ! ! |
|
30 |
|
31 !TestResultReporter class methodsFor:'others'! |
|
32 |
|
33 version_CVS |
|
34 ^ '$Id: TestResultReporter.st,v 1.2 2011-07-30 08:11:54 cg Exp $' |
|
35 ! ! |
10 |
36 |
11 !TestResultReporter class methodsFor:'reporting'! |
37 !TestResultReporter class methodsFor:'reporting'! |
12 |
38 |
13 report: aTestResult format: format as: stringOrFilename |
39 report: aTestResult format: format as: stringOrFilename |
14 |
40 |
16 ! |
42 ! |
17 |
43 |
18 report: aTestResult format: format on: stream |
44 report: aTestResult format: format on: stream |
19 |
45 |
20 self new report: aTestResult format: format on: stream |
46 self new report: aTestResult format: format on: stream |
|
47 |
|
48 " |
|
49 self report:(RegressionTests::IntegerTest runTests) format:#xml on:Transcript |
|
50 " |
|
51 |
|
52 "Modified (comment): / 30-07-2011 / 09:37:53 / cg" |
21 ! ! |
53 ! ! |
22 |
54 |
23 !TestResultReporter methodsFor:'reporting'! |
55 !TestResultReporter methodsFor:'reporting'! |
24 |
56 |
25 report:format |
57 report:formatSymbol |
|
58 "currently supported formatSymbols: |
|
59 xml" |
|
60 |
26 |reportFormatSelector| |
61 |reportFormatSelector| |
27 |
62 |
28 reportFormatSelector := self reportFormatSelector:format. |
63 reportFormatSelector := self reportFormatSelector:formatSymbol. |
29 (self respondsTo: reportFormatSelector) |
64 (self respondsTo: reportFormatSelector) |
30 ifTrue:[self perform: reportFormatSelector] |
65 ifTrue:[self perform: reportFormatSelector] |
31 ifFalse:[self error:'Unsupported format: ', format]. |
66 ifFalse:[self error:'Unsupported format: ', formatSymbol]. |
|
67 |
|
68 "Modified (comment): / 30-07-2011 / 09:37:31 / cg" |
32 ! |
69 ! |
33 |
70 |
34 report: aTestResult format: format as: stringOrFilename |
71 report: aTestResult format: format as: stringOrFilename |
35 |
72 |
36 | s | |
73 | s | |
51 ! ! |
88 ! ! |
52 |
89 |
53 !TestResultReporter methodsFor:'reporting - xml'! |
90 !TestResultReporter methodsFor:'reporting - xml'! |
54 |
91 |
55 reportXml |
92 reportXml |
56 |
93 "JUnit-like XML unittest report format" |
57 "JUnit like XML unittest report format" |
|
58 |
94 |
59 stream |
95 stream |
60 nextPutLine: '<?xml version="1.0"?>'; |
96 nextPutLine: '<?xml version="1.0"?>'; |
61 nextPutLine: '<unittest-results>'. |
97 nextPutLine: '<unittest-results>'. |
62 |
98 |
63 result passed do:[:each|self reportXmlTest: each result: #success]. |
99 result passed do:[:each|self reportXmlTest: each result: #success]. |
64 result failures do:[:each|self reportXmlTest: each result: #failure]. |
100 result failures do:[:each|self reportXmlTest: each result: #failure]. |
65 result errors do:[:each|self reportXmlTest: each result: #error]. |
101 result errors do:[:each|self reportXmlTest: each result: #error]. |
66 |
102 |
67 stream |
103 stream |
68 nextPutLine: '</unittest-results>' |
104 nextPutLine: '</unittest-results>' |
|
105 |
|
106 "Modified (format): / 30-07-2011 / 09:54:16 / cg" |
69 ! |
107 ! |
70 |
108 |
71 reportXmlTest: test result: testResult |
109 reportXmlTest: test result: testResult |
72 |
110 |
73 " |
111 " |
74 Example: |
112 Example: |
75 <test |
113 <test |
76 duration='0.0188629627228' |
114 duration='0.0188629627228' |
77 status='error' |
115 status='error' |
78 fixture='bitten.tests.web_ui.SourceFileLinkFormatterTestCase' |
116 fixture='bitten.tests.web_ui.SourceFileLinkFormatterTestCase' |
79 name='test_format_link_not_in_repos_with_line' |
117 name='test_format_link_not_in_repos_with_line' |
80 file='/usr/src/trac-bitten-0.6b2.dfsg/bitten/tests/web_ui.py'> |
118 file='/usr/src/trac-bitten-0.6b2.dfsg/bitten/tests/web_ui.py'> |
81 " |
119 " |
82 |
120 |
83 | testClassName | |
121 | testClassName executionTime | |
|
122 |
84 testClassName := self sunitNameOf: test class. |
123 testClassName := self sunitNameOf: test class. |
85 |
124 |
|
125 "most tests do not know, and return nil here!!" |
|
126 executionTime := test executionTime ? 0.0. |
|
127 |
86 stream |
128 stream |
87 nextPutLine:'<test duration="0.0"'; "As we don't know the duration :-(" |
129 nextPutAll:'<test duration="'; nextPutAll:executionTime; nextPutLine:'"'; |
88 tab; nextPutAll:'status="'; nextPutAll: testResult; nextPutLine:'"'; |
130 tab; nextPutAll:'status="'; nextPutAll: testResult; nextPutLine:'"'; |
89 tab; nextPutAll:'ficture="'; nextPutAll: testClassName; nextPutLine:'"'; |
131 tab; nextPutAll:'ficture="'; nextPutAll: testClassName; nextPutLine:'"'; |
90 tab; nextPutAll:'name="'; nextPutAll: test selector; nextPutLine:'"'; |
132 tab; nextPutAll:'name="'; nextPutAll: test selector; nextPutLine:'"'; |
91 "I seems that some tools requires the file attributes. So we supply one :-)" |
133 "It seems that some tools requires the file attributes. So we supply one :-)" |
92 tab; nextPutAll:'file="'; nextPutAll: testClassName , '.st'; nextPutLine:'">'. |
134 tab; nextPutAll:'file="'; nextPutAll: testClassName , '.st'; nextPutLine:'">'. |
93 |
135 |
94 testResult ~= #success ifTrue:[self reportXmlTraceback: test]. |
136 testResult ~= #success ifTrue:[self reportXmlTraceback: test]. |
95 |
137 |
96 stream nextPutLine:'</test>'. |
138 stream nextPutLine:'</test>'. |
|
139 |
|
140 "Modified: / 30-07-2011 / 10:10:02 / cg" |
97 ! |
141 ! |
98 |
142 |
99 reportXmlTraceback: test |
143 reportXmlTraceback: test |
100 |
144 |
101 " |
145 " |