reports/Builder__JUnitReportReader.st
author Claus Gittinger <cg@exept.de>
Thu, 28 Mar 2019 13:54:38 +0100
changeset 542 aa25a71be62a
parent 275 d5c88fece400
child 534 1bed627ec135
permissions -rw-r--r--
#DOCUMENTATION by cg
class: stx_goodies_builder_quickSelfTest
class definition

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