initial checkin
authorJan Vrany <jan.vrany@fit.cvut.cz>
Thu, 12 Mar 2015 19:22:45 +0100
changeset 275d5c88fece400
parent 274 b13db8438e4a
child 276 b710d5471770
initial checkin
reports/Builder__JUnitReportReader.st
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/reports/Builder__JUnitReportReader.st	Thu Mar 12 19:22:45 2015 +0100
     1.3 @@ -0,0 +1,102 @@
     1.4 +"{ Encoding: utf8 }"
     1.5 +
     1.6 +"{ Package: 'stx:goodies/builder/reports' }"
     1.7 +
     1.8 +"{ NameSpace: Builder }"
     1.9 +
    1.10 +XML::SAXDriver subclass:#JUnitReportReader
    1.11 +	instanceVariableNames:'currentTestResult currentOutcome'
    1.12 +	classVariableNames:''
    1.13 +	poolDictionaries:''
    1.14 +	category:'Builder-Reports-Readers'
    1.15 +!
    1.16 +
    1.17 +
    1.18 +!JUnitReportReader class methodsFor:'reading'!
    1.19 +
    1.20 +readFromFile: aStringOrFilename
    1.21 +    ^ self readFromStream: aStringOrFilename asFilename readStream
    1.22 +
    1.23 +    "Created: / 12-03-2015 / 17:27:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    1.24 +!
    1.25 +
    1.26 +readFromStream: aStream
    1.27 +    ^ (self on: aStream beforeScanDo:[:parse| parse validate:false]) testResult
    1.28 +
    1.29 +    "Created: / 12-03-2015 / 17:27:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    1.30 +! !
    1.31 +
    1.32 +!JUnitReportReader methodsFor:'accessing'!
    1.33 +
    1.34 +testResult
    1.35 +    ^ currentTestResult
    1.36 +
    1.37 +    "Created: / 12-03-2015 / 17:41:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    1.38 +! !
    1.39 +
    1.40 +!JUnitReportReader methodsFor:'content handler'!
    1.41 +
    1.42 +endElement: localName namespace: nameSpace prefix: nameSpacePrefix
    1.43 +    localName = 'testcase' ifTrue:[ 
    1.44 +        currentOutcome result == TestResult statePass ifTrue:[ 
    1.45 +            currentTestResult passedOutcomes add: currentOutcome
    1.46 +        ] ifFalse:[ 
    1.47 +        currentOutcome result == TestResult stateFail ifTrue:[ 
    1.48 +            currentTestResult failureOutcomes add: currentOutcome
    1.49 +        ] ifFalse:[  
    1.50 +        currentOutcome result == TestResult stateError ifTrue:[ 
    1.51 +            currentTestResult errorOutcomes add: currentOutcome
    1.52 +        ] ifFalse:[ 
    1.53 +            self error: 'No result for current outcome!!'
    1.54 +        ]]].
    1.55 +    ].
    1.56 +
    1.57 +    "Created: / 12-03-2015 / 17:24:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    1.58 +    "Modified: / 12-03-2015 / 18:25:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    1.59 +!
    1.60 +
    1.61 +startDocument
    1.62 +    currentTestResult :=TestResult new.
    1.63 +
    1.64 +    "Created: / 12-03-2015 / 17:24:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    1.65 +!
    1.66 +
    1.67 +startElement: localName namespace: namespace prefix: nameSpacePrefix attributes: attributes
    1.68 +    localName = 'testcase' ifTrue:[ 
    1.69 +        | classname name |
    1.70 +
    1.71 +        classname := (attributes detect:[:e | e tag type = 'classname' ]) value.
    1.72 +             name := (attributes detect:[:e | e tag type = 'name' ]) value.
    1.73 +
    1.74 +        currentOutcome := TestCaseOutcome forCase: (self testCaseForClassName: classname selector: name).
    1.75 +        currentOutcome result: TestResult statePass.
    1.76 +    ].
    1.77 +    localName = 'error' ifTrue:[ 
    1.78 +        currentOutcome result: TestResult stateError
    1.79 +    ].
    1.80 +    localName = 'failure' ifTrue:[ 
    1.81 +        currentOutcome result: TestResult stateFail
    1.82 +    ]
    1.83 +
    1.84 +    "Created: / 12-03-2015 / 17:23:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    1.85 +! !
    1.86 +
    1.87 +!JUnitReportReader methodsFor:'private'!
    1.88 +
    1.89 +testCaseForClassName:className selector:selector
    1.90 +    "/ Fake for now...
    1.91 +    ^ MessageSend receiver: className selector: selector
    1.92 +
    1.93 +    "Created: / 12-03-2015 / 17:43:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    1.94 +! !
    1.95 +
    1.96 +!JUnitReportReader class methodsFor:'documentation'!
    1.97 +
    1.98 +version
    1.99 +    ^ '$Header$'
   1.100 +!
   1.101 +
   1.102 +version_CVS
   1.103 +    ^ '$Header$'
   1.104 +! !
   1.105 +