reports/Builder__TestReportFormat.st
author Claus Gittinger <cg@exept.de>
Thu, 28 Mar 2019 13:54:38 +0100
changeset 542 aa25a71be62a
parent 514 f50803f4bb59
permissions -rw-r--r--
#DOCUMENTATION by cg class: stx_goodies_builder_quickSelfTest class definition class: stx_goodies_builder_quickSelfTest class added:18 methods
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     1
"{ Package: 'stx:goodies/builder/reports' }"
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     3
"{ NameSpace: Builder }"
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
ReportFormat subclass:#TestReportFormat
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     6
	instanceVariableNames:''
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     7
	classVariableNames:''
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     8
	poolDictionaries:''
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     9
	category:'Builder-Reports-Formats'
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    12
TestReportFormat subclass:#JUnit
104
7b1b26108f1f Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
    13
	instanceVariableNames:'position failures errors skipped startTime stopTime'
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    14
	classVariableNames:''
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    15
	poolDictionaries:''
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    16
	privateIn:TestReportFormat
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
TestReportFormat subclass:#PerfPublisher
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
	instanceVariableNames:''
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
	classVariableNames:''
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
	poolDictionaries:''
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    23
	privateIn:TestReportFormat
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    24
!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    25
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
TestReportFormat subclass:#PythonUnittest
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
	instanceVariableNames:'index'
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    28
	classVariableNames:''
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    29
	poolDictionaries:''
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    30
	privateIn:TestReportFormat
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    31
!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    32
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    33
TestReportFormat subclass:#TAP
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
	instanceVariableNames:'index'
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    35
	classVariableNames:''
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    36
	poolDictionaries:''
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    37
	privateIn:TestReportFormat
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    38
!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    39
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    40
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    41
!TestReportFormat class methodsFor:'testing'!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    42
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    43
isAbstract
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    44
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    45
    ^self == TestReportFormat
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    46
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    47
    "Created: / 04-08-2011 / 11:44:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    48
! !
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    49
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    50
!TestReportFormat methodsFor:'accessing - defaults'!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    51
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    52
defaultFileSuffix
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    53
    "superclass HDReportFormat says that I am responsible to implement this method"
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    54
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    55
    ^ 'xml'
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    56
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    57
    "Modified: / 04-08-2011 / 12:48:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    58
! !
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    59
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    60
!TestReportFormat methodsFor:'writing'!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    61
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    62
writeTestCase: testcase outcome: outcome time: time exception: exception
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    63
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    64
    | stacktrace |
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    65
    exception isNil ifTrue:[
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
    66
        stacktrace := nil.
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    67
    ] ifFalse:[
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    68
        stacktrace :=
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    69
            (String streamContents:[:s|
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    70
                self writeStackTrace: exception of: testcase on: s
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    71
            ])
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    72
    ].
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    73
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
    74
    ^self writeTestCase: testcase outcome: outcome time: time exception: exception
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    75
             stacktrace: stacktrace
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    76
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    77
    "Created: / 03-08-2011 / 19:44:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    78
!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    79
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    80
writeTestCase: testcase outcome: outcome time: time exception: exception stacktrace: stacktrace
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    81
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    82
    "Write an outcome of a given test.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    83
     Argumments:
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
    84
        testcase....the testcase <TestCase>
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
    85
        outcome.....the testcase outcome <TestCaseOutcome>
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    86
        time........time taken to run the test in milliseconds
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
    87
        exception...exception that caused error/failure or nil if N/A < Exception | nil >
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
    88
        backtrace...stacktrace info or nil if N/A <String | nil >"
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    89
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    90
    self subclassResponsibility
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    91
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    92
    "Created: / 03-08-2011 / 19:43:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
    93
    "Modified (comment): / 06-06-2014 / 00:51:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    94
! !
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    95
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    96
!TestReportFormat methodsFor:'writing - utilities'!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    97
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    98
writeContext: context on: s
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    99
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   100
    |home mthd src|
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   101
    [
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   102
    context printOn: s.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   103
    s cr.
86
29a8a74674f5 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 67
diff changeset
   104
    s nextPutAll:'receiver: '. context receiver printOn: s. s cr.
29a8a74674f5 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 67
diff changeset
   105
    s nextPutAll:'selector: '. context selector printOn: s. s cr.
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   106
    s nextPutAll:'args: '; cr.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   107
    context args keysAndValuesDo:[:idx :eachArg |
86
29a8a74674f5 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 67
diff changeset
   108
        s nextPutAll:'  '. idx printOn: s. s nextPutAll:': '. eachArg printOn: s.s cr.
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   109
    ].
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   110
    s nextPutAll:'vars: '; cr.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   111
    context vars keysAndValuesDo:[:idx :eachVar |
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   112
        s nextPutAll:'  '. idx printOn: s. s nextPutAll:': '.
91
971a6aa7f424 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 88
diff changeset
   113
        eachVar isString ifTrue:[
971a6aa7f424 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 88
diff changeset
   114
            eachVar storeOn: s.
971a6aa7f424 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 88
diff changeset
   115
        ] ifFalse:[
971a6aa7f424 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 88
diff changeset
   116
            eachVar printOn: s.
971a6aa7f424 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 88
diff changeset
   117
        ].
971a6aa7f424 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 88
diff changeset
   118
        s cr.
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   119
    ].
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   120
    s nextPutAll:'source: '; cr.
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   121
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   122
    [
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   123
    home := context methodHome.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   124
    mthd := home method.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   125
    mthd isNil ifTrue:[
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   126
         s nextPutAll: '** no source **'. s cr. s cr.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   127
        ^ self.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   128
    ].
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   129
    src := mthd source.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   130
    src isNil ifTrue:[
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   131
        s nextPutAll: '** no source **'. s cr. s cr.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   132
        ^ self.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   133
    ].
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   134
    ] on: Error do:[:ex|
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   135
        s
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   136
            nextPutAll: '** error when getting source: ';
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   137
            nextPutAll:  ex description;
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   138
            nextPutAll: '**';
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   139
            cr; cr.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   140
        ^ self.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   141
    ].
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   142
    src := src asCollectionOfLines.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   143
    src keysAndValuesDo:[:lNr :line |
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   144
        lNr == context lineNumber ifTrue:[
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   145
            s nextPutAll:'>> '.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   146
        ] ifFalse:[
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   147
            s nextPutAll:'   '.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   148
        ].
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   149
        s nextPutAll: line; cr.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   150
    ].
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   151
    s cr.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   152
    ] on: Error do:[:ex|
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   153
        s   cr;
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   154
            nextPutAll:'!!!!!!ERROR WHEN GETTING STACK TRACE!!!!!!'; cr;
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   155
            nextPutAll: ex description; cr
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   156
    ]
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   157
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   158
    "Created: / 03-08-2011 / 14:53:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   159
!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   160
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   161
writeStackTrace:err of:aTestCase on: str
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   162
91
971a6aa7f424 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 88
diff changeset
   163
    | context stop |
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   164
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   165
    context := err signalerContext.
91
971a6aa7f424 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 88
diff changeset
   166
    stop := false.
971a6aa7f424 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 88
diff changeset
   167
971a6aa7f424 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 88
diff changeset
   168
    [ context notNil ] whileTrue:[
971a6aa7f424 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 88
diff changeset
   169
        self writeContext: context on: str.
971a6aa7f424 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 88
diff changeset
   170
        str cr; cr.
971a6aa7f424 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 88
diff changeset
   171
971a6aa7f424 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 88
diff changeset
   172
        context receiver == aTestCase ifTrue:[
971a6aa7f424 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 88
diff changeset
   173
            context selector == aTestCase selector ifTrue:[ ^ self ].
971a6aa7f424 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 88
diff changeset
   174
            context selector == #setUp ifTrue:[ ^ self ].
971a6aa7f424 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 88
diff changeset
   175
        ].
971a6aa7f424 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 88
diff changeset
   176
        context := context sender.
971a6aa7f424 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 88
diff changeset
   177
971a6aa7f424 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 88
diff changeset
   178
    ].
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   179
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   180
    "Created: / 03-08-2011 / 14:53:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   181
! !
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   182
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   183
!TestReportFormat::JUnit class methodsFor:'accessing'!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   184
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   185
symbolicNames
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   186
    ^ #( #junit #junit40 )
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   187
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   188
    "Created: / 04-08-2011 / 11:45:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   189
! !
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   190
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   191
!TestReportFormat::JUnit class methodsFor:'documentation'!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   192
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   193
version_SVN
191
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   194
    ^ '$Id$'
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   195
! !
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   196
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   197
!TestReportFormat::JUnit methodsFor:'initialization'!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   198
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   199
initialize
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   200
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   201
    super initialize.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   202
    errors := 0.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   203
    failures := 0.
104
7b1b26108f1f Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   204
    skipped := 0.
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   205
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   206
    "Created: / 03-08-2011 / 15:26:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
104
7b1b26108f1f Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   207
    "Modified: / 21-11-2012 / 15:33:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   208
! !
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   209
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   210
!TestReportFormat::JUnit methodsFor:'writing'!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   211
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   212
writeFooter
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   213
    stopTime := OperatingSystem getMillisecondTime.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   214
    stream
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   215
        tab;
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   216
        nextPutAll:'<system-out><!![CDATA[]]></system-out>';
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   217
        nextPut:Character lf.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   218
    stream
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   219
        tab;
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   220
        nextPutAll:'<system-err><!![CDATA[]]></system-err>';
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   221
        nextPut:Character lf.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   222
    stream nextPutAll:'</testsuite>'.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   223
    stream stream position:position.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   224
    stream
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   225
        nextPutAll:' failures="';
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   226
        print:failures;
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   227
        nextPutAll:'" errors="';
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   228
        print:errors;
104
7b1b26108f1f Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   229
        nextPutAll:'" skipped="';
7b1b26108f1f Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   230
        print:skipped;
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   231
        nextPutAll:'" time="';
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   232
        print:(Time milliseconds:stopTime since:startTime) / 1000.0;
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   233
        nextPutAll:'">'.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   234
    stream close.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   235
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   236
    "Created: / 03-08-2011 / 14:22:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
104
7b1b26108f1f Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   237
    "Modified: / 21-11-2012 / 15:34:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   238
!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   239
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   240
writeHeader
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   241
    stream
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   242
        nextPutAll:'<?xml version="1.0" encoding="UTF-8"?>';
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   243
        nextPut:Character lf.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   244
    stream
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   245
        nextPutAll:'<testsuite name="';
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   246
        nextPutAll:(Report encode:report name);
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   247
        nextPutAll:'" tests="';
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   248
        print:report suite countTests;
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   249
        nextPutAll:('" hostname="%1"' bindWith:OperatingSystem getHostName);
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   250
        nextPutAll:'>'.
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   251
     "Now this is ugly. We want to update the time and the number of failures and errors, but still at the same time stream a valid XML. So remember this position and add some whitespace, that we can fill later."
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   252
    position := stream stream position - 1.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   253
    stream
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   254
        nextPutAll:(String new:100 withAll:$ );
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   255
        nextPut:Character lf.
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   256
    stream
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   257
        nextPutLine: '  <properties>';
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   258
        nextPutLine: '    <property name="programmingLanguage" value="Smalltalk" />';
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   259
        nextPutLine: '    <property name="smalltalk.vendor" value="exept Software AG" />';
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   260
        nextPutLine: '    <property name="smalltalk.compiler" value="Smalltalk/X" />';
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   261
        nextPutLine:('    <property name="smalltalk.version" value="%1" />'bindWith:Smalltalk versionString);
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   262
        nextPutLine:('    <property name="os.name" value="%1" />' bindWith:OperatingSystem osName);
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   263
        nextPutLine:('    <property name="os.arch" value="%1" />' bindWith:OperatingSystem getCPUType);
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   264
        nextPutLine:('    <property name="user.name" value="%1" />' bindWith:OperatingSystem getLoginName);
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   265
        nextPutLine:('    <property name="user.language" value="%1" />' bindWith:Smalltalk language).
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   266
"/    stream
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   267
"/        nextPutLine:('    <property name="smalltalk.libbasic.version" value="%1" />'bindWith:stx_libbasic versionString).
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   268
    stream
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   269
        nextPutLine: '  </properties>'.
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   270
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   271
    startTime := OperatingSystem getMillisecondTime.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   272
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   273
    "Created: / 03-08-2011 / 19:14:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   274
    "Modified: / 06-06-2014 / 01:14:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   275
!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   276
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   277
writeTestCase:testcase outcome:outcome time:time exception: exception stacktrace:stacktrace
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   278
    | result |
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   279
319
f525a38861f1 #OTHER by mawalch
mawalch
parents: 248
diff changeset
   280
    outcome result == TestResult statePass ifTrue:[
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   281
        result := #pass.
319
f525a38861f1 #OTHER by mawalch
mawalch
parents: 248
diff changeset
   282
    ] ifFalse:[
f525a38861f1 #OTHER by mawalch
mawalch
parents: 248
diff changeset
   283
        outcome result == TestResult stateFail ifTrue:[
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   284
            result := #failure.
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   285
            failures := failures + 1
319
f525a38861f1 #OTHER by mawalch
mawalch
parents: 248
diff changeset
   286
        ] ifFalse:[
f525a38861f1 #OTHER by mawalch
mawalch
parents: 248
diff changeset
   287
            outcome result == TestResult stateError ifTrue:[
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   288
                result := #error.
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   289
                errors := errors + 1.
319
f525a38861f1 #OTHER by mawalch
mawalch
parents: 248
diff changeset
   290
            ] ifFalse:[
f525a38861f1 #OTHER by mawalch
mawalch
parents: 248
diff changeset
   291
                outcome result == TestResult stateSkip ifTrue:[
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   292
                    result := #skip.
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   293
                    skipped := skipped + 1
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   294
                ] ifFalse:[
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   295
                    self error: 'Invalid test result'.
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   296
                ]
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   297
            ].
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   298
        ].
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   299
    ].
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   300
319
f525a38861f1 #OTHER by mawalch
mawalch
parents: 248
diff changeset
   301
    stream tab;
f525a38861f1 #OTHER by mawalch
mawalch
parents: 248
diff changeset
   302
            nextPutAll: '<testcase classname="';
f525a38861f1 #OTHER by mawalch
mawalch
parents: 248
diff changeset
   303
            nextPutAll: (self encode: testcase nameForHDTestReport);
f525a38861f1 #OTHER by mawalch
mawalch
parents: 248
diff changeset
   304
            nextPutAll: '" name="';
f525a38861f1 #OTHER by mawalch
mawalch
parents: 248
diff changeset
   305
            nextPutAll: (self encode: testcase selectorForHDTestReport);
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   306
            nextPutAll: '" time="'; print: (time ? 0) / 1000.0; nextPutAll: '">'; cr.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   307
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   308
    result == #skip ifTrue:[
104
7b1b26108f1f Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   309
        stream tab; tab; nextPutAll: '<skipped/>'.
7b1b26108f1f Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   310
    ] ifFalse:[
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   311
        result ~~ #pass ifTrue:[
104
7b1b26108f1f Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   312
            | type message |
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   313
104
7b1b26108f1f Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   314
            exception isNil ifTrue:[
7b1b26108f1f Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   315
                type := 'unknown exception'.
319
f525a38861f1 #OTHER by mawalch
mawalch
parents: 248
diff changeset
   316
                message := 'unknown exception occurred (no exception details available)'
104
7b1b26108f1f Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   317
            ] ifFalse:[
7b1b26108f1f Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   318
                type := exception class name.
7b1b26108f1f Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   319
                message := exception messageText ifNil:[ exception description ].
7b1b26108f1f Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   320
            ].
319
f525a38861f1 #OTHER by mawalch
mawalch
parents: 248
diff changeset
   321
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   322
104
7b1b26108f1f Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   323
            stream tab; tab;
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   324
                nextPut:$<; nextPutAll: result;
104
7b1b26108f1f Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   325
                nextPutAll:' type="';
7b1b26108f1f Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   326
                nextPutAll:(self encode:type);
7b1b26108f1f Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   327
                nextPutAll:'" message="';
7b1b26108f1f Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   328
                nextPutAll:(self encode: message);
7b1b26108f1f Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   329
                nextPutAll:'"><!![CDATA['; cr.
191
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   330
            self writeCDATA: (stacktrace ? 'stacktrace not available').
104
7b1b26108f1f Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   331
            stream
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   332
                nextPutAll:']]></'; nextPutAll: result; nextPutAll:'>';
104
7b1b26108f1f Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   333
                nextPut:Character lf
7b1b26108f1f Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   334
        ].
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   335
    ].
242
d9479f1e61fa Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 235
diff changeset
   336
    report keepStdout ifTrue:[
d9479f1e61fa Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 235
diff changeset
   337
        outcome collectedOutput notEmptyOrNil ifTrue:[
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   338
            stream nextPutAll:'    <system-out><!![CDATA['; cr.
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   339
            self writeCDATA: outcome collectedOutput.
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   340
            stream nextPutAll:']]> </system-out>'; cr.
319
f525a38861f1 #OTHER by mawalch
mawalch
parents: 248
diff changeset
   341
        ].
242
d9479f1e61fa Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 235
diff changeset
   342
    ].
104
7b1b26108f1f Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   343
319
f525a38861f1 #OTHER by mawalch
mawalch
parents: 248
diff changeset
   344
    stream tab;
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   345
            nextPutAll: '</testcase>'; cr.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   346
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   347
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   348
    stream flush
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   349
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   350
    "Created: / 03-08-2011 / 19:42:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
248
82f1ff8c96a6 Correctly capture and report stdout.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 242
diff changeset
   351
    "Modified: / 16-09-2014 / 18:55:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
191
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   352
! !
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   353
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   354
!TestReportFormat::JUnit methodsFor:'writing - utilities'!
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   355
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   356
writeCDATA: string
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   357
    | start stop |
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   358
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   359
    start := 1.
191
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   360
    stop := start.
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   361
    [ (stop := (string indexOf: $] startingAt: stop)) ~~ 0 ] whileTrue:[
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   362
        ((stop < (string size - 1))
191
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   363
            and:[(string at: stop + 1) == $]
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   364
                and:[(string at: stop + 2) == $>]]) ifTrue:[
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   365
                    " Okay, found CDATA end token "
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   366
                    stream nextPutAll: string startingAt: start to: stop + 1.
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   367
                    stream nextPutAll: ']]><!![CDATA[>'.
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   368
                    start := stop := stop + 3.
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   369
                ] ifFalse:[
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   370
                    stop := stop + 1.
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   371
                ].
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   372
    ].
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   373
    start < string size ifTrue:[
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   374
        stream nextPutAll: string startingAt: start to: string size.
191
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   375
    ].
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   376
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   377
    "
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   378
    String streamContents:[:s | Builder::TestReportFormat::JUnit new report: nil stream: s; writeCDATA:'ABCD']
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   379
    String streamContents:[:s | Builder::TestReportFormat::JUnit new report: nil stream: s; writeCDATA:']]]]']
191
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   380
    String streamContents:[:s | Builder::TestReportFormat::JUnit new report: nil stream: s; writeCDATA:'Some <[CDATA[ CDATA ]]> Some Text and stray terminator ]]> here']
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   381
    "
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   382
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   383
    "Created: / 05-07-2013 / 16:54:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   384
! !
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   385
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   386
!TestReportFormat::PerfPublisher class methodsFor:'accessing'!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   387
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   388
symbolicNames
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   389
    "Returns a collection of symbolic names for this format"
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   390
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   391
    ^ #(perfPublisher)
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   392
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   393
    "Modified: / 04-08-2011 / 11:52:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   394
! !
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   395
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   396
!TestReportFormat::PerfPublisher class methodsFor:'documentation'!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   397
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   398
version_SVN
191
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   399
    ^ '$Id$'
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   400
! !
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   401
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   402
!TestReportFormat::PerfPublisher methodsFor:'writing'!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   403
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   404
writeFooter
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   405
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   406
    stream nextPutLine: '</report>'
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   407
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   408
    "Modified: / 03-08-2011 / 20:12:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   409
!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   410
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   411
writeHeader
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   412
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   413
    |reportName reportCategory testClass|
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   414
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   415
    reportName := report suite name.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   416
    reportCategory := 'uncategorized'.  "/ it is a required attribute; so what should we use ?
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   417
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   418
    (testClass := Smalltalk at:reportName asSymbol) isBehavior ifTrue:[
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   419
        reportCategory := testClass category.  "/ at least, something to show
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   420
    ].
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   421
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   422
    stream
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   423
        nextPutLine: '<?xml version="1.0"?>';
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   424
        nextPutLine:('<report name="%1" categ="%2">' bindWith:reportName with:reportCategory);
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   425
        nextPutLine:('  <start>');
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   426
        nextPutLine:('    <date format="YYYYMMDD" val="%1" />' bindWith:(Date today printStringFormat:'%y%m%d'));
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   427
        nextPutLine:('    <time format="HHMMSS" val="%1" />' bindWith:(Time now printStringFormat:'%h%m%s'));
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   428
        nextPutLine:('  </start>').
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   429
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   430
    "Modified: / 03-08-2011 / 20:12:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   431
!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   432
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   433
writeTestCase:testcase outcome:outcome time:time exception:exception stacktrace:stacktrace
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   434
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   435
    "
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   436
    Example:
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   437
    <test
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   438
        name='test_format_link_not_in_repos_with_line'
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   439
        executed='exec-status'
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   440
      <result>
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   441
        <success passed='result-status' state='result-state'/>
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   442
        <errorlog><!![CDATA[EXEMPLE OF ERROR LOG]]></errorlog>
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   443
      </result>
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   444
    </test>
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   445
    "
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   446
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   447
    |testClassName executionTime testName testDescription
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   448
     successPassed successState exceptionInfo
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   449
     compilerName compilerVersion compilerConfiguration compilerVersionDate
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   450
     timeUnit timeMeasure
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   451
     sysInfo osType osVersion cpuType|
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   452
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   453
    testClassName := testcase printString.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   454
    testName := testcase selector.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   455
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   456
    "most tests do not know, and return nil here!!"
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   457
    executionTime := time.    "/ millis
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   458
    testDescription := '%1-%2' bindWith:testClassName with:testName.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   459
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   460
    successPassed := (outcome result == TestResult statePass) ifTrue:['yes'] ifFalse:['no'].
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   461
    (outcome result ~~ TestResult statePass) ifTrue:[
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   462
        exceptionInfo := stacktrace ? 'No stacktrace available'.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   463
    ].
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   464
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   465
    successState := 'foo'.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   466
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   467
    "/ caveat: the following needs to be made dialect-specific
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   468
    compilerName := 'Smalltalk/X'.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   469
    compilerVersion := Smalltalk versionString.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   470
    compilerConfiguration := Smalltalk configuration.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   471
    compilerVersionDate := Smalltalk versionDate.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   472
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   473
    sysInfo := OperatingSystem getSystemInfo.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   474
    osType := (sysInfo at:#osType ifAbsent:'?').
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   475
    osVersion := (sysInfo at:#release ifAbsent:'?').
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   476
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   477
    cpuType := (sysInfo at:#cpuType ifAbsent:'?').
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   478
    "/ cpuSpeed := (sysInfo at:#cpuSpeed ifAbsent:'?').
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   479
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   480
    timeUnit := 'ms'.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   481
    timeMeasure := executionTime.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   482
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   483
    stream
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   484
        nextPutLine:('<test name="%1" executed="yes">' bindWith: testName);
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   485
        nextPutLine:('  <description><!![CDATA[%1]]></description>' bindWith: testDescription);
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   486
        nextPutLine:'  <platform>';
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   487
        nextPutLine:'    <os>';
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   488
        nextPutLine:('      <type><!![CDATA[%1]]></type>' bindWith:osType);
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   489
        nextPutLine:('      <version><!![CDATA[%1]]></version>' bindWith:osVersion);
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   490
        nextPutLine:'    </os>';
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   491
        nextPutLine:('    <processor arch="%1">' bindWith:cpuType);
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   492
        "/ nextPutLine:('      <frequency> unit="Mhz" cpufreq="%1" />' bindWith:cpuSpeed);
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   493
        nextPutLine:'    </processor>';
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   494
        nextPutLine:('    <compiler name="%1" version="%2" versiondate="%3" configuration="%4" />'
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   495
                            bindWith:compilerName with:compilerVersion
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   496
                            with:compilerVersionDate with:compilerConfiguration);
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   497
        "/ nextPutLine:'    <environment />';
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   498
        nextPutLine:'  </platform>';
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   499
        nextPutLine:'  <result>';
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   500
        nextPutLine:('    <success passed="%1" state="100" />'
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   501
                            bindWith:successPassed with:successState);
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   502
        "/ cg: in the perfPublisher documentation, I found "mesure".
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   503
        "/ I am not sure, if that was a typo, or is actually what is expected...
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   504
        "/ to be on the save side, I generate both a mesure and a measure attribute,
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   505
        "/ so it will work, even if they ever fix perfPublisher's xml parser.
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   506
        nextPutLine:('    <executiontime unit="%1" mesure="%2" measure="%2" isRelevant="yes" />'
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   507
                            bindWith:timeUnit with:timeMeasure).
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   508
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   509
    exceptionInfo notNil ifTrue:[
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   510
        stream
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   511
            nextPutLine:'    <errorlog><!![CDATA[';
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   512
            nextPutAll:exceptionInfo;
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   513
            nextPutLine:']]></errorlog>'.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   514
        ].
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   515
    stream
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   516
        nextPutLine:'  </result>'.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   517
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   518
    stream nextPutLine:'</test>'.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   519
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   520
    "Modified: / 06-06-2014 / 00:47:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   521
! !
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   522
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   523
!TestReportFormat::PythonUnittest class methodsFor:'accessing'!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   524
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   525
symbolicNames
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   526
    "Returns a collection of symbolic names for this format"
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   527
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   528
    ^ #(python python-unittest)
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   529
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   530
    "Modified: / 04-08-2011 / 11:52:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   531
! !
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   532
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   533
!TestReportFormat::PythonUnittest class methodsFor:'documentation'!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   534
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   535
version_SVN
191
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   536
    ^ '$Id$'
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   537
! !
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   538
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   539
!TestReportFormat::PythonUnittest methodsFor:'writing'!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   540
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   541
writeFooter
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   542
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   543
    stream
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   544
        nextPutLine: '</unittest-results>'
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   545
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   546
    "Modified: / 03-08-2011 / 20:19:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   547
!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   548
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   549
writeHeader
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   550
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   551
    stream
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   552
        nextPutLine: '<?xml version="1.0"?>';
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   553
        nextPutLine: '<unittest-results>'.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   554
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   555
    "Modified: / 03-08-2011 / 20:19:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   556
!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   557
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   558
writeTestCase:testcase outcome:outcome time:time exception:exception stacktrace:stacktrace
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   559
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   560
    "
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   561
    Example:
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   562
    <test
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   563
        duration='0.0188629627228'
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   564
        status='error'
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   565
        fixture='bitten.tests.web_ui.SourceFileLinkFormatterTestCase'
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   566
        name='test_format_link_not_in_repos_with_line'
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   567
        file='/usr/src/trac-bitten-0.6b2.dfsg/bitten/tests/web_ui.py'>
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   568
    "
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   569
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   570
    | testClassName result |
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   571
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   572
    testClassName := testcase class printString.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   573
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   574
    outcome result == TestResult statePass ifTrue:[
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   575
        result := #success.
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   576
    ] ifFalse:[
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   577
        outcome result == TestResult stateFail ifTrue:[
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   578
            result := #failure.
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   579
        ] ifFalse:[
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   580
            outcome result == TestResult stateError ifTrue:[
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   581
                result := #error.
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   582
            ] ifFalse:[
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   583
                outcome result == TestResult stateSkip ifTrue:[
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   584
                    result := #skip.
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   585
                ] ifFalse:[
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   586
                    self error: 'Invalid test result'.
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   587
                ]
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   588
            ].
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   589
        ].
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   590
    ].
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   591
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   592
    stream
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   593
        nextPutAll:'<test duration="'; nextPutAll:time; nextPutLine:'"';
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   594
        tab; nextPutAll:'status="'; nextPutAll: result; nextPutLine:'"';
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   595
        tab; nextPutAll:'ficture="'; nextPutAll: testClassName; nextPutLine:'"';
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   596
        tab; nextPutAll:'name="'; nextPutAll: testcase selector; nextPutLine:'"';
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   597
        "It seems that some tools requires the file attributes. So we supply one :-)"
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   598
        tab; nextPutAll:'file="'; nextPutAll: testClassName , '.st'; nextPutLine:'">'.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   599
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   600
    outcome == #pass ifFalse:[
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   601
        stream nextPutLine:'<traceback><!![CDATA['.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   602
        stream nextPutAll: stacktrace ? 'No stacktrace available'.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   603
        stream nextPutLine:']]></traceback>'.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   604
    ].
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   605
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   606
    stream nextPutLine:'</test>'.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   607
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   608
    "Modified: / 06-06-2014 / 00:50:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   609
! !
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   610
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   611
!TestReportFormat::TAP class methodsFor:'accessing'!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   612
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   613
symbolicNames
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   614
    "Returns a collection of symbolic names for this format"
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   615
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   616
    ^ #(tap TAP)
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   617
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   618
    "Modified: / 04-08-2011 / 11:52:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   619
! !
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   620
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   621
!TestReportFormat::TAP class methodsFor:'documentation'!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   622
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   623
version_SVN
191
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   624
    ^ '$Id$'
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   625
! !
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   626
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   627
!TestReportFormat::TAP methodsFor:'accessing - defaults'!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   628
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   629
defaultFileSuffix
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   630
    "superclass HDReportFormat says that I am responsible to implement this method"
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   631
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   632
    ^ 'tap'
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   633
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   634
    "Modified: / 04-08-2011 / 12:47:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   635
! !
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   636
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   637
!TestReportFormat::TAP methodsFor:'writing'!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   638
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   639
writeFooter
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   640
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   641
    "nothing to do"
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   642
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   643
    "Modified: / 03-08-2011 / 20:05:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   644
!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   645
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   646
writeHeader
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   647
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   648
    stream nextPutAll: '1..'; nextPutAll: report suite countTests printString; cr.
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   649
    index := 0
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   650
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   651
    "Modified: / 04-08-2011 / 13:49:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   652
!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   653
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   654
writeTestCase:testcase outcome:outcome time:time exception:exception stacktrace:stacktrace
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   655
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   656
    | result testDescription statusString |
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   657
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   658
    index := index + 1.
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   659
    outcome result == TestResult statePass ifTrue:[
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   660
        result := #pass.
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   661
    ] ifFalse:[
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   662
        outcome result == TestResult stateFail ifTrue:[
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   663
            result := #failure.
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   664
        ] ifFalse:[
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   665
            outcome result == TestResult stateError ifTrue:[
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   666
                result := #error.
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   667
            ] ifFalse:[
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   668
                outcome result == TestResult stateSkip ifTrue:[
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   669
                    result := #skip.
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   670
                ] ifFalse:[
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   671
                    self error: 'Invalid test result'.
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   672
                ]
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   673
            ].
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   674
        ].
514
f50803f4bb59 Send #countTests instead of #testCount
mawalch
parents: 319
diff changeset
   675
    ].
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   676
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   677
    testDescription := '%1-%2 (%3ms)'
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   678
                            bindWith:testcase printString
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   679
                            with:testcase selector
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   680
                            with:time.
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   681
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   682
    statusString := (result == #pass)
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   683
                        ifTrue:['ok']
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   684
                        ifFalse:['not ok'].
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   685
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   686
    stream nextPutLine:('%1 %2 - %3'
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   687
                            bindWith:statusString
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   688
                            with:index
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   689
                            with:testDescription).
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   690
235
3769ae14139a When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 191
diff changeset
   691
    "Modified: / 06-06-2014 / 00:46:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   692
! !
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   693
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   694
!TestReportFormat class methodsFor:'documentation'!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   695
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   696
version
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   697
    ^ '$Header$'
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   698
!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   699
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   700
version_CVS
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   701
    ^ '$Header$'
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   702
!
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   703
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   704
version_SVN
191
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   705
    ^ '$Id$'
67
73732acacfc1 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   706
! !
191
cc00c3e2019c Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 104
diff changeset
   707