|
1 "{ Encoding: utf8 }" |
|
2 |
|
3 "{ Package: 'stx:goodies/builder/reports' }" |
|
4 |
|
5 "{ NameSpace: Builder }" |
|
6 |
|
7 XML::SAXDriver subclass:#JUnitReportReader |
|
8 instanceVariableNames:'currentTestResult currentOutcome' |
|
9 classVariableNames:'' |
|
10 poolDictionaries:'' |
|
11 category:'Builder-Reports-Readers' |
|
12 ! |
|
13 |
|
14 |
|
15 !JUnitReportReader class methodsFor:'reading'! |
|
16 |
|
17 readFromFile: aStringOrFilename |
|
18 ^ self readFromStream: aStringOrFilename asFilename readStream |
|
19 |
|
20 "Created: / 12-03-2015 / 17:27:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
21 ! |
|
22 |
|
23 readFromStream: aStream |
|
24 ^ (self on: aStream beforeScanDo:[:parse| parse validate:false]) testResult |
|
25 |
|
26 "Created: / 12-03-2015 / 17:27:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
27 ! ! |
|
28 |
|
29 !JUnitReportReader methodsFor:'accessing'! |
|
30 |
|
31 testResult |
|
32 ^ currentTestResult |
|
33 |
|
34 "Created: / 12-03-2015 / 17:41:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
35 ! ! |
|
36 |
|
37 !JUnitReportReader methodsFor:'content handler'! |
|
38 |
|
39 endElement: localName namespace: nameSpace prefix: nameSpacePrefix |
|
40 localName = 'testcase' ifTrue:[ |
|
41 currentOutcome result == TestResult statePass ifTrue:[ |
|
42 currentTestResult passedOutcomes add: currentOutcome |
|
43 ] ifFalse:[ |
|
44 currentOutcome result == TestResult stateFail ifTrue:[ |
|
45 currentTestResult failureOutcomes add: currentOutcome |
|
46 ] ifFalse:[ |
|
47 currentOutcome result == TestResult stateError ifTrue:[ |
|
48 currentTestResult errorOutcomes add: currentOutcome |
|
49 ] ifFalse:[ |
|
50 self error: 'No result for current outcome!!' |
|
51 ]]]. |
|
52 ]. |
|
53 |
|
54 "Created: / 12-03-2015 / 17:24:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
55 "Modified: / 12-03-2015 / 18:25:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
56 ! |
|
57 |
|
58 startDocument |
|
59 currentTestResult :=TestResult new. |
|
60 |
|
61 "Created: / 12-03-2015 / 17:24:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
62 ! |
|
63 |
|
64 startElement: localName namespace: namespace prefix: nameSpacePrefix attributes: attributes |
|
65 localName = 'testcase' ifTrue:[ |
|
66 | classname name | |
|
67 |
|
68 classname := (attributes detect:[:e | e tag type = 'classname' ]) value. |
|
69 name := (attributes detect:[:e | e tag type = 'name' ]) value. |
|
70 |
|
71 currentOutcome := TestCaseOutcome forCase: (self testCaseForClassName: classname selector: name). |
|
72 currentOutcome result: TestResult statePass. |
|
73 ]. |
|
74 localName = 'error' ifTrue:[ |
|
75 currentOutcome result: TestResult stateError |
|
76 ]. |
|
77 localName = 'failure' ifTrue:[ |
|
78 currentOutcome result: TestResult stateFail |
|
79 ] |
|
80 |
|
81 "Created: / 12-03-2015 / 17:23:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
82 ! ! |
|
83 |
|
84 !JUnitReportReader methodsFor:'private'! |
|
85 |
|
86 testCaseForClassName:className selector:selector |
|
87 "/ Fake for now... |
|
88 ^ MessageSend receiver: className selector: selector |
|
89 |
|
90 "Created: / 12-03-2015 / 17:43:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
91 ! ! |
|
92 |
|
93 !JUnitReportReader class methodsFor:'documentation'! |
|
94 |
|
95 version |
|
96 ^ '$Header$' |
|
97 ! |
|
98 |
|
99 version_CVS |
|
100 ^ '$Header$' |
|
101 ! ! |
|
102 |