Mini / Embedded test runner: refactored the suite result into text
...to show only number of tests in each result category only
if nonzero. For example. if no tests failed and there are no
errors, only display:
5 run, 5 passed
and *not*
5 run, 5 passed, 0 failed, 0 errors
I (JV) hope this is easier to read.
--- a/Tools__TestRunnerMini.st Fri Nov 17 11:54:38 2017 -0300
+++ b/Tools__TestRunnerMini.st Fri Nov 17 12:22:55 2017 -0300
@@ -1249,34 +1249,46 @@
!
info
- |numTests numRun|
+ |numTests numPassed numFailed numRun resources numError |
- result ifNil:[^''].
+ result isNil ifTrue:[^''].
numTests := suite tests size.
- numRun := result passedCount + result failureCount + result errorCount.
+ numPassed := result passedCount.
+ numFailed := result failureCount.
+ numError := result errorCount.
+ numRun := numPassed + numFailed + numError.
"/ (result passedCount + result failureCount + result errorCount) = 1 ifTrue:[^''].
+ resources := TestRunnerMini resources.
numRun == 0 ifTrue:[
numTests == 1 ifTrue:[
- ^'not run'
+ ^(resources string: 'not run')
].
- ^'%1 tests, 0 run' bindWith: numTests
+ ^(resources string: '%1 tests, 0 run') bindWith: numTests
].
- numRun < numTests ifTrue:[
- ^'%1 tests, %2 run, %3 passed, %4 fail or error'
- bindWith: numTests
- with: numRun
- with: result passedCount
- with: (result failureCount+result errorCount)
+ ^ String streamContents:[ :s |
+ "/ 'X tests'...
+ numTests printOn: s. s space; nextPutAll: (resources string: 'tests').
+ numRun < numTests ifTrue:[
+ "/ ', %2 run'...
+ s nextPut: $,. numRun printOn: s. s space; nextPutAll: (resources string: 'run').
+ ].
+ numPassed > 0 ifTrue:[
+ "/ ', %3 passed'...
+ s nextPut: $,. numPassed printOn: s. s space; nextPutAll: (resources string: 'passed').
+ ].
+ numFailed > 0 ifTrue:[
+ "/ ', %4 failed'...
+ s nextPut: $,. numFailed printOn: s. s space; nextPutAll: (resources string: 'failed').
+ ].
+ numError > 0 ifTrue:[
+ "/ ', %5 errors'...
+ s nextPut: $,. numError printOn: s. s space; nextPutAll: (resources string: (numError > 1 ifTrue:[ 'errors' ] ifFalse:[ 'error' ])).
+ ].
].
- ^'%1 tests, %2 passed, %3 failed, %4 errors'
- bindWith: numTests
- with: result passedCount
- with: result failureCount
- with: result errorCount
-
"Created: / 15-03-2010 / 20:23:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 17-11-2017 / 12:23:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
name