| | 502 | dojo.require("dojox.testing.DocTest"); |
| | 503 | doh.registerDocTests = function(module) { |
| | 504 | // summary: |
| | 505 | // Get all the doctests from the given module and register each of them |
| | 506 | // as a single test case here. |
| | 507 | // |
| | 508 | |
| | 509 | var docTest = new dojox.testing.DocTest(); |
| | 510 | var docTests = docTest.getTests(module); |
| | 511 | var len = docTests.length; |
| | 512 | var tests = []; |
| | 513 | for (var i=0; i<len; i++) { |
| | 514 | var test = docTests[i]; |
| | 515 | tests.push({ |
| | 516 | runTest:function(t) { |
| | 517 | var r = docTest.runTest(test.commands, test.expectedResult); |
| | 518 | t.assertTrue(r.success); |
| | 519 | }, |
| | 520 | name:"test"+(i+1)+", Line "+test.line |
| | 521 | } |
| | 522 | ); |
| | 523 | } |
| | 524 | console.log(tests); |
| | 525 | this.register("DocTests: "+module, tests); |
| | 526 | } |
| | 527 | |