Tools__TestRunnerMini.st
changeset 14739 ec549f688c75
parent 14728 1c798d251860
child 14831 17e27adfbd3d
equal deleted inserted replaced
14738:2593d0a1f4e8 14739:ec549f688c75
   188                    name: 'RunnerInfoBox'
   188                    name: 'RunnerInfoBox'
   189                    backgroundChannel: resultBackgroundColorAspect
   189                    backgroundChannel: resultBackgroundColorAspect
   190                    component: 
   190                    component: 
   191                   (SpecCollection
   191                   (SpecCollection
   192                      collection: (
   192                      collection: (
   193                       (ViewSpec
       
   194                          name: 'ProgressPanel'
       
   195                          layout: (LayoutFrame 0 0 0 0 0 1 0 1)
       
   196                          initiallyInvisible: true
       
   197                          visibilityChannel: progressIndicatorShownHolder
       
   198                          backgroundChannel: resultBackgroundColorAspect
       
   199                          component: 
       
   200                         (SpecCollection
       
   201                            collection: (
       
   202                             (ProgressIndicatorSpec
       
   203                                name: 'RunningProgress'
       
   204                                layout: (LayoutFrame 5 0 -10 0.5 -5 1 10 0.5)
       
   205                                model: progressHolder
       
   206                                postBuildCallback: postBuildProgressIndicator:
       
   207                              )
       
   208                             )
       
   209                           
       
   210                          )
       
   211                        )
       
   212                       (LabelSpec
   193                       (LabelSpec
   213                          label: 'Run tests first!!'
   194                          label: 'Run tests first!!'
   214                          name: 'ResultName'
   195                          name: 'ResultName'
   215                          layout: (LayoutFrame 22 0 0 0 0 1 -10 1)
   196                          layout: (LayoutFrame 22 0 0 0 0 1 -10 1)
   216                          backgroundChannel: resultBackgroundColorAspect
   197                          backgroundChannel: resultBackgroundColorAspect
   238                          backgroundChannel: resultBackgroundColorAspect
   219                          backgroundChannel: resultBackgroundColorAspect
   239                          foregroundColor: (Color 100.0 100.0 100.0)
   220                          foregroundColor: (Color 100.0 100.0 100.0)
   240                          translateLabel: true
   221                          translateLabel: true
   241                          labelChannel: resultInfoAspect
   222                          labelChannel: resultInfoAspect
   242                          adjust: left
   223                          adjust: left
       
   224                        )
       
   225                       (ViewSpec
       
   226                          name: 'ProgressPanel'
       
   227                          layout: (LayoutFrame 0 0 0 0 0 1 0 1)
       
   228                          initiallyInvisible: true
       
   229                          visibilityChannel: progressIndicatorShownHolder
       
   230                          backgroundChannel: resultBackgroundColorAspect
       
   231                          component: 
       
   232                         (SpecCollection
       
   233                            collection: (
       
   234                             (ProgressIndicatorSpec
       
   235                                name: 'RunningProgress'
       
   236                                layout: (LayoutFrame 5 0 -10 0.5 -5 1 10 0.5)
       
   237                                model: progressHolder
       
   238                                postBuildCallback: postBuildProgressIndicator:
       
   239                              )
       
   240                             )
       
   241                           
       
   242                          )
   243                        )
   243                        )
   244                       )
   244                       )
   245                     
   245                     
   246                    )
   246                    )
   247                    extent: (Point 296 30)
   247                    extent: (Point 296 30)
   330         self updateTestCases
   330         self updateTestCases
   331     ].
   331     ].
   332     ^ allTestCases
   332     ^ allTestCases
   333 !
   333 !
   334 
   334 
       
   335 allTestCases:something
       
   336     allTestCases := something.
       
   337 !
       
   338 
   335 infoHolder:something
   339 infoHolder:something
   336     "to show something in the browsers info area (near the bottom"
   340     "to show something in the browsers info area (near the bottom"
   337 
   341 
   338     infoHolder := something.
   342     infoHolder := something.
   339 
   343 
   340     "Created: / 05-07-2011 / 16:22:24 / cg"
   344     "Created: / 05-07-2011 / 16:22:24 / cg"
   341 !
       
   342 
       
   343 invalidateAllTestCases
       
   344     allTestCases := nil
       
   345 !
   345 !
   346 
   346 
   347 selectedTestMethods
   347 selectedTestMethods
   348 
   348 
   349     | selectedClass |
   349     | selectedClass |
   499 
   499 
   500 pin
   500 pin
   501     | runner screen |
   501     | runner screen |
   502 
   502 
   503     runner := TestRunnerMini new.
   503     runner := TestRunnerMini new.
   504     runner selectedMethodsHolder: self selectedMethodsHolder copy asValue.
   504     runner resultHolder value: self resultHolder value copy.
   505     runner selectedProtocolsHolder: self selectedProtocolsHolder copy asValue.
       
   506     runner selectedClassesHolder: self selectedClassesHolder copy asValue.
       
   507 
   505 
   508     runner allButOpen.
   506     runner allButOpen.
   509 
   507 
   510     screen := Screen current.
   508     screen := Screen current.
   511     (screen notNil and:[ screen platformName == #X11 ]) ifTrue:[ 
   509     (screen notNil and:[ screen platformName == #X11 ]) ifTrue:[ 
   517         ].
   515         ].
   518         screen setWindowType:#'_NET_WM_WINDOW_TYPE_UTILITY' in:runner window id.      
   516         screen setWindowType:#'_NET_WM_WINDOW_TYPE_UTILITY' in:runner window id.      
   519     ].        
   517     ].        
   520     runner open.
   518     runner open.
   521 
   519 
   522     "Modified: / 23-09-2014 / 10:13:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   520     "Modified: / 23-09-2014 / 12:05:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   523 !
   521 !
   524 
   522 
   525 run
   523 run
   526     |suite|
   524     |suite|
   527 
   525 
   833 
   831 
   834 invalidateSuiteAndResult
   832 invalidateSuiteAndResult
   835     self resultHolder value:nil.
   833     self resultHolder value:nil.
   836 !
   834 !
   837 
   835 
   838 invalidateTestCases
       
   839     allTestCases := nil.
       
   840 !
       
   841 
       
   842 update:aspect with:param from:sender
   836 update:aspect with:param from:sender
   843 
   837 
   844     sender == Smalltalk ifTrue:[
   838     sender == Smalltalk ifTrue:[
   845             aspect == #lastTestRunResult ifTrue:[
   839             aspect == #lastTestRunResult ifTrue:[
   846                 allTestCases notNil ifTrue:[
   840                 allTestCases notNil ifTrue:[
   872     "Modified: / 15-03-2010 / 20:55:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   866     "Modified: / 15-03-2010 / 20:55:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   873     "Modified: / 04-06-2012 / 19:03:15 / cg"
   867     "Modified: / 04-06-2012 / 19:03:15 / cg"
   874 !
   868 !
   875 
   869 
   876 updateTestCases
   870 updateTestCases
   877     allTestCases := ((self selectedClassesHolder value ? #()) 
   871     "/ Nothing to do here
   878                 select:[:cls | self isTestCaseLike:cls ]).
   872 
   879     allTestCases := allTestCases asArray
   873     "Created: / 23-09-2014 / 12:02:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   880 
       
   881     "Created: / 11-03-2010 / 10:31:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   882     "Modified: / 24-01-2012 / 22:09:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   883     "Modified: / 04-06-2012 / 19:02:52 / cg"
       
   884 !
   874 !
   885 
   875 
   886 updateTestSuiteAndResult
   876 updateTestSuiteAndResult
   887 
   877 
   888     | suite suiteAndResult |
   878     | suite suiteAndResult |
   992     "Modified: / 02-08-2011 / 18:20:00 / cg"
   982     "Modified: / 02-08-2011 / 18:20:00 / cg"
   993     "Modified: / 20-08-2011 / 14:30:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   983     "Modified: / 20-08-2011 / 14:30:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   994 !
   984 !
   995 
   985 
   996 suiteForRun
   986 suiteForRun
   997     "if methods are selected, a suite for those methods is built and returned.
   987     ^ self resultHolder value suiteForRun
   998      If protocoly are selected, a suite for all methods in those protocols
   988 
   999      is built and returned.
   989     "Modified: / 23-09-2014 / 12:07:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  1000      Otherwise, a suite for all methods in the class is built and returned"
       
  1001     
       
  1002     | testMethods protocols suite selectedClass |
       
  1003 
       
  1004     selectedClass := self theSingleTestCase.
       
  1005     selectedMethodsHolder value notEmptyOrNil ifTrue:[
       
  1006         testMethods := self selectedTestMethods.
       
  1007         suite := TestSuite named:(self suiteNameFromMethods:testMethods).
       
  1008         testMethods do:[:mthd | 
       
  1009             | class  selector |
       
  1010 
       
  1011             class := selectedClass isNil ifTrue:[mthd mclass] ifFalse:[ selectedClass ].
       
  1012             suite addTest:(class asTestCase selector:mthd selector)
       
  1013         ].
       
  1014         ^ suite
       
  1015     ].
       
  1016     (protocols := selectedProtocolsHolder value) notEmptyOrNil ifTrue:[
       
  1017         suite := TestSuite named:(self suiteNameFromProtocols:protocols).
       
  1018         (self selectedTestMethodsFromProtocols:protocols inClass:selectedClass) do:[:mthd | 
       
  1019             | class  selector |
       
  1020 
       
  1021             class := selectedClass isNil ifTrue:[mthd mclass] ifFalse:[ selectedClass ].
       
  1022             suite addTest:(class asTestCase selector:mthd selector)
       
  1023         ].
       
  1024         ^ suite
       
  1025     ].
       
  1026     ^ self suiteForRunAll
       
  1027 
       
  1028     "Created: / 15-03-2010 / 13:13:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
  1029     "Modified: / 04-08-2011 / 19:06:42 / cg"
       
  1030     "Modified (format): / 23-09-2014 / 10:19:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
  1031 !
   990 !
  1032 
   991 
  1033 suiteForRunAll
   992 suiteForRunAll
  1034     |suite|
   993     "raise an error: must be redefined in concrete subclass(es)"
  1035 
   994 
  1036     allTestCases isNil ifTrue:[
   995     ^ self suiteForRun
  1037         self updateTestCases.
   996 
  1038     ].
   997     "Modified: / 23-09-2014 / 12:07:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  1039     suite := TestSuite named:(self suiteNameFromClasses: self allTestCases).
       
  1040 
       
  1041     allTestCases do:[:testCase | 
       
  1042         suite addTests:(self buildSuiteFromClass:testCase) tests
       
  1043     ].
       
  1044     ^suite
       
  1045 
       
  1046     "Modified: / 04-03-2011 / 06:57:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
  1047     "Modified: / 04-06-2012 / 19:01:48 / cg"
       
  1048 !
   998 !
  1049 
   999 
  1050 suiteForRunFailed
  1000 suiteForRunFailed
  1051     |suite numTests|
  1001     |suite numTests|
  1052 
  1002 
  1053     suite := TestSuite named:(self suiteNameFromClasses: self allTestCases).
  1003     suite := TestSuite named:(self suiteNameFromClasses: self allTestCases).
  1054     numTests := 0.
  1004     numTests := 0.
  1055 
  1005 
  1056     self allTestCases do:[:testCase |
  1006     self suiteForRunAll tests do:[:eachTest |
  1057         (self buildSuiteFromClass:testCase) tests do:[:eachTest |
  1007         | sel cls |
  1058             | sel cls |
  1008 
  1059 
  1009         sel := eachTest selector.
  1060             sel := eachTest selector.
  1010         cls := eachTest class.
  1061             cls := eachTest class.
  1011         (cls testSelectorPassed:sel) ifFalse:[
  1062             (cls testSelectorPassed:sel) ifFalse:[
  1012             suite addTest:eachTest.
  1063                 suite addTest:eachTest.
  1013             numTests := numTests + 1.
  1064                 numTests := numTests + 1.
       
  1065             ]
       
  1066         ]
  1014         ]
  1067     ].
  1015     ].
       
  1016 
  1068     numTests == 1 ifTrue:[
  1017     numTests == 1 ifTrue:[
  1069         suite name:(suite tests first selector)
  1018         suite name:(suite tests first selector)
  1070     ] ifFalse:[
  1019     ] ifFalse:[
  1071         suite name:(suite tests size printString,' tests')
  1020         suite name:(suite tests size printString,' tests')
  1072     ].
  1021     ].
  1073     ^suite
  1022     ^suite
  1074 
  1023 
  1075     "Modified: / 04-03-2011 / 06:57:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  1024     "Modified: / 23-09-2014 / 12:09:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  1076     "Created: / 04-06-2012 / 18:32:40 / cg"
       
  1077 ! !
  1025 ! !
  1078 
  1026 
  1079 !TestRunnerMini::SuiteAndResult class methodsFor:'instance creation'!
  1027 !TestRunnerMini::SuiteAndResult class methodsFor:'instance creation'!
  1080 
  1028 
  1081 suite: suite result: result
  1029 suite: suite result: result
  1214 ! !
  1162 ! !
  1215 
  1163 
  1216 !TestRunnerMini class methodsFor:'documentation'!
  1164 !TestRunnerMini class methodsFor:'documentation'!
  1217 
  1165 
  1218 version
  1166 version
  1219     ^ '$Header: /cvs/stx/stx/libtool/Tools__TestRunnerMini.st,v 1.1 2014-09-23 09:29:37 vrany Exp $'
  1167     ^ '$Header: /cvs/stx/stx/libtool/Tools__TestRunnerMini.st,v 1.2 2014-09-23 11:14:52 vrany Exp $'
  1220 !
  1168 !
  1221 
  1169 
  1222 version_CVS
  1170 version_CVS
  1223     ^ '$Header: /cvs/stx/stx/libtool/Tools__TestRunnerMini.st,v 1.1 2014-09-23 09:29:37 vrany Exp $'
  1171     ^ '$Header: /cvs/stx/stx/libtool/Tools__TestRunnerMini.st,v 1.2 2014-09-23 11:14:52 vrany Exp $'
  1224 !
  1172 !
  1225 
  1173 
  1226 version_SVN
  1174 version_SVN
  1227     ^ '$Id: Tools__TestRunnerMini.st,v 1.1 2014-09-23 09:29:37 vrany Exp $'
  1175     ^ '$Id: Tools__TestRunnerMini.st,v 1.2 2014-09-23 11:14:52 vrany Exp $'
  1228 ! !
  1176 ! !
  1229 
  1177