--- a/Tools__TestRunnerMini.st Thu Jan 29 20:21:42 2015 +0100
+++ b/Tools__TestRunnerMini.st Thu Jan 29 20:21:53 2015 +0100
@@ -99,10 +99,10 @@
^ super flyByHelpSpec addPairsFrom:#(
#debugSelected
-'Run the selected test(s) with debugging enabled'
+'Run the selected test(s) with debugging enabled.\A debugger is opened on error or assertion failure'
#runAll
-'Run all tests'
+'Run all tests.\No debugger is opened on error or assertion failure, but the test remembered as failing'
#runFailed
'Only rerun failed tests'
@@ -113,30 +113,15 @@
#stopRun
'Stop the test-run'
+#pin
+'Pin the runner for the selected testcase as floating window.'
+
+#runAllWithCoverage
+'Run all tests with coverage'
+
)
"Created: / 04-06-2012 / 19:27:47 / cg"
-!
-
-helpSpec
- "This resource specification was automatically generated
- by the UIHelpTool of ST/X."
-
- "Do not manually edit this!! If it is corrupted,
- the UIHelpTool may not be able to read the specification."
-
- "
- UIHelpTool openOnClass:Tools::TestRunnerMini
- "
-
- <resource: #help>
-
- ^ super helpSpec addPairsFrom:#(
-
-#pin
-'Pin runner for selected testcase in screen.'
-
-)
! !
!TestRunnerMini class methodsFor:'image specs'!
@@ -199,7 +184,7 @@
layout: (LayoutFrame 0 0 0 0 0 1 0 1)
backgroundChannel: resultBackgroundColorAspect
horizontalLayout: rightSpaceFit
- verticalLayout: center
+ verticalLayout: topSpace
horizontalSpace: 0
elementsChangeSize: true
component:
@@ -228,9 +213,9 @@
level: 0
visibilityChannel: pinButtonVisibleHolder
backgroundChannel: resultBackgroundColorAspect
+ foregroundChannel: resultBackgroundColorAspect
hasCharacterOrientedLabel: false
translateLabel: true
- foregroundChannel: resultBackgroundColorAspect
labelChannel: pinIcon
model: pin
)
@@ -266,7 +251,7 @@
)
)
- extent: (Point 296 30)
+ extent: (Point 221 40)
)
(ActionButtonSpec
label: 'Debug'
@@ -297,7 +282,7 @@
extent: (Point 60 25)
)
(ActionButtonSpec
- label: ' Failed'
+ label: 'Failed'
name: 'Button1'
activeHelpKey: runFailed
visibilityChannel: runFailedButtonVisibleHolder
@@ -307,7 +292,7 @@
extent: (Point 60 25)
)
(ActionButtonSpec
- label: 'Run all'
+ label: 'Run All'
name: 'RunAll'
activeHelpKey: runAll
visibilityChannel: runAllButtonVisibleHolder
@@ -316,10 +301,15 @@
enableChannel: runAllEnabledHolder
extent: (Point 60 25)
)
- (ViewSpec
- name: 'Spacer'
- backgroundChannel: resultBackgroundColorAspect
- extent: (Point 5 50)
+ (ActionButtonSpec
+ label: 'Coverage'
+ name: 'Button4'
+ activeHelpKey: runAllWithCoverage
+ visibilityChannel: runAllButtonVisibleHolder
+ translateLabel: true
+ model: runAllWithCoverage
+ enableChannel: runAllEnabledHolder
+ extent: (Point 80 25)
)
)
@@ -469,6 +459,22 @@
!TestRunnerMini methodsFor:'actions'!
+allCoveredClasses
+ "return a collection of classes which are covered by the selected
+ tests. Requires that the testcase returns a non-empty collection
+ from the coveredClasses query"
+
+ |testedClasses suite|
+
+ testedClasses := Set new.
+
+ suite := self suiteForRunAll.
+ suite tests do:[:eachTest |
+ testedClasses addAll:(eachTest class coveredClasses).
+ ].
+ ^ testedClasses
+!
+
debug
| suiteAndResult suite result |
@@ -566,7 +572,11 @@
!
run:suite debug: debug
- |suiteAndResult numTests|
+ self run:suite debug: debug coverageContext: nil
+!
+
+run:suite debug: debug coverageContext: coverageContextOrNil
+ |suiteAndResult numTests testRunAction|
numTests := suite tests size.
numTests == 0 ifTrue:[
@@ -575,41 +585,50 @@
self stop.
- testProcess := [
- |result incr run|
+ testRunAction :=
+ [
+ |result incr run|
- result := debug ifFalse:[TestResult new] ifTrue:[TestResultForRunWithDebug].
- [
- self runningHolder value:true.
- self progressIndicatorShownHolder value:(numTests > 1).
- self progressHolder value:0.
- incr := 100 / numTests.
- run := 0.
- result := suite
- run: result
- beforeEachDo:[:test :result |
- infoHolder notNil ifTrue:[
- infoHolder value:('Running "%1-%2"...'
- bindWith:test name
- with:test getTestName allBold)
- ]
+ result := debug ifFalse:[TestResult new] ifTrue:[TestResultForRunWithDebug].
+ [
+ self runningHolder value:true.
+ self progressIndicatorShownHolder value:(numTests > 1).
+ self progressHolder value:0.
+ incr := 100 / numTests.
+ run := 0.
+ result := suite
+ run: result
+ beforeEachDo:[:test :result |
+ infoHolder notNil ifTrue:[
+ infoHolder value:('Running "%1-%2"...'
+ bindWith:test name
+ with:test getTestName allBold)
]
- afterEachDo:[:test :result |
- run := run + 1.
- self progressHolder value:(incr * run) truncated "rounded".
- infoHolder notNil ifTrue:[
- infoHolder value:('Done.')
- ]
+ ]
+ afterEachDo:[:test :result |
+ run := run + 1.
+ self progressHolder value:(incr * run) truncated "rounded".
+ infoHolder notNil ifTrue:[
+ infoHolder value:('Done.')
]
- debug: debug.
- suiteAndResult := SuiteAndResult suite:suite result:result.
- ] ensure:[
- self progressIndicatorShownHolder value:false.
- self resultHolder setValue:nil; value:suiteAndResult; changed.
- self runningHolder value:false.
- ]
- ] newProcess.
+ ]
+ debug: debug.
+ suiteAndResult := SuiteAndResult suite:suite result:result.
+ ] ensure:[
+ self progressIndicatorShownHolder value:false.
+ self resultHolder setValue:nil; value:suiteAndResult; changed.
+ self runningHolder value:false.
+ ]
+ ].
+ coverageContextOrNil notNil ifTrue:[
+ |realAction|
+
+ realAction := testRunAction.
+ testRunAction := [ coverageContextOrNil run:realAction ]
+ ].
+
+ testProcess := testRunAction newProcess.
testProcess priority:(Processor userBackgroundPriority).
testProcess resume.
@@ -625,6 +644,40 @@
"Modified: / 04-06-2012 / 19:00:14 / cg"
!
+runAllWithCoverage
+ "return a collection of classes which are covered by the selected
+ tests. Requires that the testcase returns a non-empty collection
+ from the coveredClasses query"
+
+ |testedClasses suite|
+
+ testedClasses := self allCoveredClasses.
+ testedClasses isEmpty ifTrue:[
+ Dialog information:(resources stringWithCRs:'The test cases do not define any covered class.\(missing #coveredClassNames method)\\Running without coverage').
+ ] ifFalse:[
+ self withWaitCursorDo:[
+ testedClasses do:[:eachClass |
+ infoHolder notNil ifTrue:[
+ infoHolder value:('Instrumenting "%1"...'
+ bindWith:eachClass name)
+ ].
+ masterApplication recompileClassWithInstrumentation:eachClass.
+ InstrumentationInfo cleanAllInfoFor:eachClass withChange:true.
+ ].
+ ].
+ infoHolder notNil ifTrue:[
+ infoHolder value:('Running test...')
+ ].
+ ].
+
+ suite := self suiteForRunAll.
+
+ self
+ run:suite
+ debug:false
+ coverageContext:(InstrumentationContext new coverageOnly:true)
+!
+
runFailed
self run: self suiteForRunFailed.
@@ -1006,6 +1059,8 @@
!
suiteForRun
+ self resultHolder value isNil ifTrue:[^ nil].
+
^ self resultHolder value suiteForRun
"Modified: / 23-09-2014 / 12:07:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -1186,14 +1241,14 @@
!TestRunnerMini class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/Tools__TestRunnerMini.st,v 1.4 2014-12-11 15:42:10 vrany Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/Tools__TestRunnerMini.st,v 1.5 2015-01-29 19:21:53 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libtool/Tools__TestRunnerMini.st,v 1.4 2014-12-11 15:42:10 vrany Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/Tools__TestRunnerMini.st,v 1.5 2015-01-29 19:21:53 cg Exp $'
!
version_SVN
- ^ '$Id: Tools__TestRunnerMini.st,v 1.4 2014-12-11 15:42:10 vrany Exp $'
+ ^ '$Id: Tools__TestRunnerMini.st,v 1.5 2015-01-29 19:21:53 cg Exp $'
! !