Tools__AbstractTestRunner.st
author Jan Vrany <jan.vrany@labware.com>
Wed, 05 Oct 2022 11:57:26 +0100
branchjv
changeset 19637 28f5bfaa093d
parent 19612 9f2e3136aa4d
permissions -rw-r--r--
`NewSystemBrowser`: avoid updating package info when changed class is not selected This speeds up loading of packages when browser is open as it does not (needlessly) update package info which may involve scm round-trip.

"
 Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague
 Copyright (c) 2009-2010 eXept Software AG
 Copyright (c) 2021 LabWare

 Permission is hereby granted, free of charge, to any person
 obtaining a copy of this software and associated documentation
 files (the 'Software'), to deal in the Software without
 restriction, including without limitation the rights to use,
 copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the
 Software is furnished to do so, subject to the following
 conditions:

 The above copyright notice and this permission notice shall be
 included in all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
"
"{ Package: 'stx:libtool' }"

"{ NameSpace: Tools }"

ApplicationModel subclass:#AbstractTestRunner
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'SUnit-UI'
!

!AbstractTestRunner class methodsFor:'documentation'!

copyright
"
 Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague
 Copyright (c) 2009-2010 eXept Software AG
 Copyright (c) 2021 LabWare

 Permission is hereby granted, free of charge, to any person
 obtaining a copy of this software and associated documentation
 files (the 'Software'), to deal in the Software without
 restriction, including without limitation the rights to use,
 copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the
 Software is furnished to do so, subject to the following
 conditions:

 The above copyright notice and this permission notice shall be
 included in all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
"
! !

!AbstractTestRunner methodsFor:'accessing-look'!

errorBackgroundColor
    <resource: #style (#'testRunner.error.backgroundColor')>

    ^ self styleSheet
        colorAt:#'testRunner.error.backgroundColor'
        default:[ Color redByte:194 greenByte:110 blueByte:110 ]

    "Created: / 17-09-2021 / 22:20:02 / Jan Vrany <jan.vrany@labware.com>"
!

failedBackgroundColor
    <resource: #style (#'testRunner.failed.backgroundColor')>

    ^ self styleSheet
        colorAt:#'testRunner.failed.backgroundColor'
        default:[ Color redByte:194 greenByte:110 blueByte:110 ]

    "Created: / 17-09-2021 / 22:19:25 / Jan Vrany <jan.vrany@labware.com>"
!

notRunBackgroundColor
    <resource: #style (#'testRunner.notrun.backgroundColor')>

    ^ self styleSheet
        colorAt:#'testRunner.notrun.backgroundColor'
        default:[ Color redByte:145 greenByte:145 blueByte:145 ]

    "Created: / 17-09-2021 / 22:20:58 / Jan Vrany <jan.vrany@labware.com>"
!

passedBackgroundColor
    <resource: #style (#'testRunner.passed.backgroundColor')>

    ^ self styleSheet
        colorAt:#'testRunner.passed.backgroundColor'
        default:[ Color redByte:92 greenByte:166 blueByte:92 ]

    "Created: / 17-09-2021 / 22:18:56 / Jan Vrany <jan.vrany@labware.com>"
!

runningBackgroundColor
    <resource: #style (#'testRunner.running.backgroundColor')>

    ^ self styleSheet
        colorAt:#'testRunner.running.backgroundColor'
        default:[ self styleSheet
                    colorAt: #'progressIndicator.foregroundColor' 
                    default: [ Color blue ] ]

    "Created: / 17-09-2021 / 22:22:32 / Jan Vrany <jan.vrany@labware.com>"
! !

!AbstractTestRunner methodsFor:'private'!

buildSuiteFromClass:testCaseCls

    ^testCaseCls asTestCase buildSuite

    "Modified: / 04-03-2011 / 08:22:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

isTestCaseLike:cls 

    ^cls isTestCaseLike

    "Modified: / 28-02-2011 / 21:31:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!AbstractTestRunner methodsFor:'utilities'!

suiteNameFromClasses: classes
    |numClasses|

    (numClasses := classes size) == 1 ifTrue:
        [^classes anyOne nameWithoutPrefix].
    numClasses == 2 ifTrue:
        [^String streamContents:
            [:s|classes 
                do:[:cls|s nextPutAll: cls nameWithoutPrefix]
                separatedBy:[s nextPutAll:' & ']]].

    ^numClasses printString , ' test cases'.

    "Created: / 15-03-2010 / 13:23:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

suiteNameFromMethods: methods
    |numMethods|

    (numMethods := methods size) == 1 ifTrue:[^ methods anyOne selector].

    ^numMethods printString , ' tests from ' ,
        (self suiteNameFromClasses: 
            (methods 
                collect:[:m|m mclass] 
                thenSelect:[:c | c notNil]) asSet)

    "Created: / 15-03-2010 / 13:22:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

suiteNameFromProtocols: protocols
    |numProtocols|

    (numProtocols := protocols size) == 0 ifTrue:[
        ^'tests'
    ].
    numProtocols == 1 ifTrue:[
        protocols anyOne notNil ifTrue:[
            ^'category "', protocols anyOne , '"'
        ] ifFalse:[
            ^'tests'
        ]
    ].    
    ^numProtocols printString , ' categories'

    "Created: / 15-03-2010 / 13:22:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 18-10-2011 / 22:59:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!AbstractTestRunner class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libtool/Tools__AbstractTestRunner.st,v 1.12 2013-05-21 20:21:26 cg Exp $'
!

version_CVS
    ^ '$Header: /cvs/stx/stx/libtool/Tools__AbstractTestRunner.st,v 1.12 2013-05-21 20:21:26 cg Exp $'
!

version_HG

    ^ '$Changeset: <not expanded> $'
!

version_SVN
    ^ '$Id: Tools__AbstractTestRunner.st,v 1.12 2013-05-21 20:21:26 cg Exp $'
! !