- Timestamp:
- 04/13/09 12:22:23 (3 years ago)
- Location:
- trunk/mgunit
- Files:
-
- 9 modified
-
RELEASE (modified) (1 diff)
-
src/mgunit.pro (modified) (2 diffs)
-
src/mgutclirunner__define.pro (modified) (2 diffs)
-
src/mgutcompoundrunner__define.pro (modified) (2 diffs)
-
src/mgutguirunner__define.pro (modified) (14 diffs)
-
src/mguthtmlrunner__define.pro (modified) (1 diff)
-
src/mguttestcase__define.pro (modified) (2 diffs)
-
src/mguttestrunner__define.pro (modified) (3 diffs)
-
src/mguttestsuite__define.pro (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/mgunit/RELEASE
r49 r54 19 19 20 20 * Several test runners for outputting test results to various formats are 21 available; output can be sent to stdout, log files, or html files. 21 available; output can be sent to stdout, log files, or html files. In 22 addition, there is a GUI test runner that will show results and re-run tests 23 with the push of a button (also recompiling tests before running them). 22 24 23 25 * If there is common setup required for each test method in a test case, a -
trunk/mgunit/src/mgunit.pro
r52 r54 16 16 ; html : in, optional, type=boolean 17 17 ; set to indicate HTML output instead of plain text 18 ; gui : in, optional, type=boolean 19 ; set to bring up an interactive GUI to run the tests 18 20 ; npass : out, optional, type=long 19 21 ; number of tests that passed … … 23 25 ; number of tests 24 26 ;- 25 pro mgunit, tests, filename=filename, html=html, $27 pro mgunit, tests, filename=filename, html=html, gui=gui, $ 26 28 color=color, $ 27 29 npass=npass, nfail=nfail, ntests=ntests 28 30 compile_opt strictarr 29 31 30 testRunner = obj_new('MGutCompoundRunner') 31 32 runnerName = keyword_set(html) ? 'MGutHTMLRunner' : 'MGutCliRunner' 33 testRunner->add, obj_new(runnerName, filename=filename, color=color) 34 35 npass = 0L 36 nfail = 0L 37 32 case 1 of 33 keyword_set(gui): runnerName = 'MGutGuiRunner' 34 keyword_set(html): runnerName = 'MGutHtmlRunner' 35 else: runnerName = 'MgutCliRunner' 36 endcase 37 38 38 if (n_elements(tests) gt 0) then begin 39 testRunner = obj_new('MGutCompoundRunner') 40 41 npass = 0L 42 nfail = 0L 43 39 44 testsuite = obj_new('MGutTestSuite', $ 40 45 test_runner=testRunner, $ 41 46 name='All tests') 47 48 testRunner->add, obj_new(runnerName, parent=testRunner, $ 49 filename=filename, color=color, $ 50 test_suite=testsuite) 51 42 52 testsuite->add, tests 43 53 testsuite->run 44 54 testsuite->getProperty, npass=npass, nfail=nfail, ntests=ntests 45 obj_destroy, testsuite 55 56 if (~keyword_set(gui)) then obj_destroy, testRunner 46 57 endif 47 48 obj_destroy, testRunner49 58 end -
trunk/mgunit/src/mgutclirunner__define.pro
r53 r54 72 72 ; 73 73 ; :Params: 74 ; testcase {in}{required}{type=string} name of test case 74 ; testcase : in, required, type=string 75 ; name of test case 75 76 ; 76 77 ; :Keywords: … … 228 229 ; set to print color output 229 230 ;- 230 function mgutclirunner::init, filename=filename, color=color 231 compile_opt strictarr 232 233 if (~self->mguttestrunner::init( )) then return, 0B231 function mgutclirunner::init, filename=filename, color=color, _extra=e 232 compile_opt strictarr 233 234 if (~self->mguttestrunner::init(_extra=e)) then return, 0B 234 235 235 236 if (n_elements(filename) gt 0) then begin -
trunk/mgunit/src/mgutcompoundrunner__define.pro
r53 r54 168 168 ; stdout 169 169 ;- 170 function mgutcompoundrunner::init, filename=filename 170 function mgutcompoundrunner::init, filename=filename, _extra=e 171 171 compile_opt strictarr 172 172 173 if (~self->mguttestrunner::init( )) then return, 0B173 if (~self->mguttestrunner::init(_extra=e)) then return, 0B 174 174 if (~self->idl_container::init()) then return, 0B 175 175 176 176 return, 1B 177 177 end … … 184 184 compile_opt strictarr 185 185 186 define = { MGutCompoundRunner, inherits MGutTestRunner, inherits IDL_Container } 186 define = { MGutCompoundRunner, $ 187 inherits MGutTestRunner, $ 188 inherits IDL_Container $ 189 } 187 190 end -
trunk/mgunit/src/mgutguirunner__define.pro
r53 r54 11 11 compile_opt strictarr 12 12 13 widget_control, event. id, get_uvalue=widget13 widget_control, event.top, get_uvalue=widget 14 14 widget->_eventHandler, event 15 15 end … … 45 45 compile_opt strictarr 46 46 47 ;indent = level eq 0 ? '' : string(bytarr(level * self.indent) + self.space) 48 ;self->_print, self.logLun, $ 49 ; indent + '"' + testsuite $ 50 ; + '" test suite starting (' $ 51 ; + strtrim(ntestcases, 2) + ' test suite' $ 52 ; + (ntestcases eq 1 ? '' : 's') $ 53 ; + '/case' $ 54 ; + (ntestcases eq 1 ? '' : 's') $ 55 ; + ', ' $ 56 ; + strtrim(ntests, 2) + ' test' + (ntests eq 1 ? '' : 's') $ 57 ; + ')', $ 58 ; /magenta 47 indent = level eq 0 ? '' : string(bytarr(level * self.indent) + self.space) 48 self->_print, indent + '"' + testsuite $ 49 + '" test suite starting (' $ 50 + strtrim(ntestcases, 2) + ' test suite' $ 51 + (ntestcases eq 1 ? '' : 's') $ 52 + '/case' $ 53 + (ntestcases eq 1 ? '' : 's') $ 54 + ', ' $ 55 + strtrim(ntests, 2) + ' test' + (ntests eq 1 ? '' : 's') $ 56 + ')' 59 57 end 60 58 … … 76 74 compile_opt strictarr 77 75 78 ;indent = level eq 0 ? '' : string(bytarr(level * self.indent) + self.space) 79 ;self->_print, self.logLun, $ 80 ; indent + 'Results: ' $ 81 ; + strtrim(npass, 2) + ' / ' + strtrim(npass + nfail, 2) $ 82 ; + ' tests passed', $ 83 ; /magenta 76 indent = level eq 0 ? '' : string(bytarr(level * self.indent) + self.space) 77 self->_print, indent + 'Results: ' $ 78 + strtrim(npass, 2) + ' / ' + strtrim(npass + nfail, 2) $ 79 + ' tests passed' 84 80 end 85 81 … … 89 85 ; 90 86 ; :Params: 91 ; testcase {in}{required}{type=string} name of test case 87 ; testcase : in, required, type=string 88 ; name of test case 92 89 ; 93 90 ; :Keywords: … … 100 97 compile_opt strictarr 101 98 102 ;indent = string(bytarr(level * self.indent) + self.space) 103 ;self->_print, self.logLun, $ 104 ; indent + '"' + testcase + '" test case starting' $ 105 ; + ' (' + strtrim(ntests, 2) $ 106 ; + ' test' + (ntests eq 1 ? '' : 's') + ')', $ 107 ; /blue 99 indent = string(bytarr(level * self.indent) + self.space) 100 self->_print, indent + '"' + testcase + '" test case starting' $ 101 + ' (' + strtrim(ntests, 2) $ 102 + ' test' + (ntests eq 1 ? '' : 's') + ')' 108 103 end 109 104 … … 123 118 compile_opt strictarr 124 119 125 ;indent = string(bytarr(level * self.indent) + self.space) 126 ;self->_print, self.logLun, $ 127 ; indent + 'Results: ' $ 128 ; + strtrim(npass, 2) + ' / ' + strtrim(npass + nfail, 2) $ 129 ; + ' tests passed', $ 130 ; /blue 120 indent = string(bytarr(level * self.indent) + self.space) 121 self->_print, indent + 'Results: ' $ 122 + strtrim(npass, 2) + ' / ' + strtrim(npass + nfail, 2) $ 123 + ' tests passed' 131 124 end 132 125 … … 146 139 compile_opt strictarr 147 140 148 ;indent = string(bytarr((level + 1L) * self.indent) + self.space)149 ;self->_print, self.logLun, indent + testname + ': ', format='(A, $)'141 indent = string(bytarr((level + 1L) * self.indent) + self.space) 142 self->_print, indent + testname + ': ', /continued 150 143 end 151 144 … … 167 160 compile_opt strictarr 168 161 169 ;if (passed) then begin 170 ; self->_print, self.logLun, 'passed', /green 171 ;endif else begin 172 ; self->_print, self.logLun, 'failed' + (msg eq '' ? '' : ' "' + msg + '"'), /red 173 ;endelse 162 if (passed) then begin 163 self->_print, 'passed', /continued 164 endif else begin 165 self->_print, 'failed' + (msg eq '' ? '' : ' "' + msg + '"'), /continued 166 endelse 167 168 self->_print, string(time, format='(%" (%f seconds)")') 169 end 170 171 172 pro mgutguirunner::_print, text, continued=continued, _extra=e 173 compile_opt strictarr 174 175 if (self.continued) then begin 176 widget_control, self.text, get_value=fullText 177 fullText[n_elements(fullText) - 1L] += text 178 widget_control, self.text, set_value=fullText 179 endif else begin 180 widget_control, self.text, set_value=text, append=~self.cleared 181 self.cleared = 0B 182 endelse 183 184 self.continued = keyword_set(continued) 174 185 end 175 186 … … 181 192 compile_opt strictarr 182 193 194 obj_destroy, [self.suite, self.parent] 183 195 self->mguttestrunner::cleanup 184 196 end 185 197 186 198 199 ;+ 200 ; Creates the user-interface for the GUI test runner. 201 ;- 187 202 pro mgutguirunner::_createWidgets 188 203 compile_opt strictarr 189 204 190 self.tlb = widget_base(title='mgunit', /column) 191 end 192 193 205 self.tlb = widget_base(title='mgunit', /column, uvalue=self, uname='tlb', $ 206 /tlb_size_events) 207 208 self.toolbar = widget_base(self.tlb, /toolbar, space=0) 209 210 resourcedir = ['resource', 'bitmaps'] 211 rerun = widget_button(self.toolbar, uname='rerun', $ 212 value=filepath('redo.bmp', subdir=resourcedir), $ 213 /bitmap) 214 215 self.text = widget_text(self.tlb, xsize=100, ysize=20, /scroll) 216 end 217 218 219 ;+ 220 ; Realizes the user-interface for the GUI test runner. 221 ;- 194 222 pro mgutguirunner::_realizeWidgets 195 223 compile_opt strictarr 196 224 197 end 198 199 225 widget_control, self.tlb, /realize 226 end 227 228 229 ;+ 230 ; Starts up XMANAGER. 231 ;- 200 232 pro mgutguirunner::_startXManager 201 233 compile_opt strictarr … … 207 239 208 240 241 ;+ 242 ; Handles all events from the GUI test runner. 243 ; 244 ; :Params: 245 ; event : in, required, type=structure 246 ; event structure from any widget generating events in the GUI test 247 ; runner 248 ;- 209 249 pro mgutguirunner::_eventHandler, event 210 250 compile_opt strictarr 211 251 252 uname = widget_info(event.id, /uname) 253 254 case uname of 255 'tlb': begin 256 tlbG = widget_info(event.top, /geometry) 257 toolbarG = widget_info(self.toolbar, /geometry) 258 259 xsize = event.x - 2 * tlbG.xpad 260 ysize = event.y - 2 * tlbG.ypad - tlbG.space - toolbarG.scr_ysize 261 262 widget_control, self.text, scr_xsize=xsize, scr_ysize=ysize 263 end 264 'rerun': begin 265 ; clear text widget 266 widget_control, self.text, set_value='' 267 self.cleared = 1B 268 269 ; rerun tests 270 self.suite->recompileTestCases 271 self.suite->run 272 end 273 else: 274 endcase 212 275 end 213 276 … … 216 279 compile_opt strictarr 217 280 281 obj_destroy, self 218 282 end 219 283 … … 225 289 ; 1 for success, 0 for failure 226 290 ;- 227 function mgutguirunner::init 228 compile_opt strictarr 229 230 if (~self->mguttestrunner::init( )) then return, 0B291 function mgutguirunner::init, filename=filename, color=color, _extra=e 292 compile_opt strictarr 293 294 if (~self->mguttestrunner::init(_extra=e)) then return, 0B 231 295 232 296 self->_createWidgets 233 297 self->_realizeWidgets 234 298 self->_startXManager 299 300 self.cleared = 0B 301 self.indent = 3L 302 self.space = (byte(' '))[0] 235 303 236 304 return, 1B … … 244 312 ; tlb 245 313 ; top-level base of GUI 314 ; text 315 ; continued 246 316 ;- 247 317 pro mgutguirunner__define … … 249 319 250 320 define = { mgutguirunner, inherits MGutTestRunner, $ 251 tlb : 0L $ 321 tlb: 0L, $ 322 toolbar: 0L, $ 323 text: 0L, $ 324 continued: 0B, $ 325 cleared: 0B, $ 326 indent: 0L, $ 327 space: '' $ 252 328 } 253 329 end -
trunk/mgunit/src/mguthtmlrunner__define.pro
r53 r54 184 184 ; stdout 185 185 ; color : in, optional, type=boolean 186 ; unused for MGutHTMLRunner 187 ;- 188 function mguthtmlrunner::init, filename=filename, color=color 189 compile_opt strictarr 190 191 if (~self->mguttestrunner::init()) then return, 0B 186 ; unused for MGutHtmlRunner 187 ; _extra : in, optional, type=keywords 188 ; keywords to MGutTestRunner::init 189 ;- 190 function mguthtmlrunner::init, filename=filename, color=color, _extra=e 191 compile_opt strictarr 192 193 if (~self->mguttestrunner::init(_extra=e)) then return, 0B 192 194 193 195 ; make the directory the output file is in if it doesn't exist -
trunk/mgunit/src/mguttestcase__define.pro
r53 r54 133 133 compile_opt strictarr, logical_predicate 134 134 135 self.npass = 0L 136 self.nfail = 0L 137 135 138 self.testRunner->reportTestCaseStart, strlowcase(obj_class(self)), $ 136 139 ntests=self.ntests, $ … … 288 291 289 292 self.level = 0L 290 self.npass = 0L291 self.nfail = 0L292 293 293 294 return, 1B -
trunk/mgunit/src/mguttestrunner__define.pro
r53 r54 127 127 compile_opt strictarr 128 128 129 if (obj_valid(self.parent)) then obj_destroy, self.parent 129 130 end 130 131 … … 136 137 ; 1 for success, 0 for failure 137 138 ;- 138 function mguttestrunner::init 139 function mguttestrunner::init, parent=parent, test_suite=testSuite 139 140 compile_opt strictarr 141 142 self.suite = obj_valid(testsuite) ? testsuite : obj_new() 143 self.parent = obj_valid(parent) ? parent : obj_new() 140 144 141 145 return, 1B … … 147 151 ; 148 152 ; :Fields: 149 ; dummy 150 ; needed because IDL requires at least one field 153 ; suite 154 ; suite of tests the runner will run 155 ; parent 156 ; parent compound test, if present 151 157 ;- 152 158 pro mguttestrunner__define 153 159 compile_opt strictarr 154 160 155 define = { MGutTestRunner, dummy : 0L } 161 define = { MGutTestRunner, $ 162 suite: obj_new(), $ 163 parent: obj_new() $ 164 } 156 165 end -
trunk/mgunit/src/mguttestsuite__define.pro
r27 r54 6 6 ; use the add method to add test suites/cases. 7 7 ;- 8 8 9 9 10 ;+ … … 59 60 60 61 ;+ 62 ; Recompiles all test cases contained by the suite or contained by child 63 ; suites. 64 ;- 65 pro mguttestsuite::recompileTestCases 66 compile_opt strictarr 67 68 for i = 0L, self.testcases->count() - 1L do begin 69 testcase = self.testcases->get(position=i) 70 if (obj_isa(testcase, 'MGutTestSuite')) then begin 71 testcase->recompileTestCases 72 endif else begin 73 self->_recompile, obj_class(testcase) 74 endelse 75 endfor 76 end 77 78 79 ;+ 61 80 ; Run the contained test suites or test cases. 62 81 ;- … … 64 83 compile_opt strictarr 65 84 85 self.npass = 0L 86 self.nfail = 0L 87 66 88 self->getProperty, name=name, ntestcases=ntestcases, ntests=ntests 67 89 self.testRunner->reportTestSuiteStart, name, $ … … 270 292 self.testcases = obj_new('IDL_Container') 271 293 272 self.npass = 0L273 self.nfail = 0L274 275 294 return, 1B 276 295 end … … 283 302 ; name 284 303 ; name of the object 304 ; home 305 ; directory (with trailing slash) containing the source code for this 306 ; test suite 285 307 ; level 286 308 ; number of layers below the top-most containing test suite … … 300 322 301 323 define = { MGutTestSuite, $ 302 name : '', $303 home : '', $304 level : 0L, $305 testcases : obj_new(), $306 testRunner : obj_new(), $307 npass : 0L, $308 nfail : 0L $324 name: '', $ 325 home: '', $ 326 level: 0L, $ 327 testcases: obj_new(), $ 328 testRunner: obj_new(), $ 329 npass: 0L, $ 330 nfail: 0L $ 309 331 } 310 332 end
