X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Fmisc%2Ffake-jstestdriver.js;h=4397741af0a437a6b8c01a0e7ee61e5f40fdda45;hb=a307700238038a375a5fcc4ca2553685debb4e6f;hp=4849f99a4968e7a2d8599fece1f6716b71dec982;hpb=ca6c43aa36919d5787a973ad3d25efea6c289130;p=dygraphs.git diff --git a/auto_tests/misc/fake-jstestdriver.js b/auto_tests/misc/fake-jstestdriver.js index 4849f99..4397741 100644 --- a/auto_tests/misc/fake-jstestdriver.js +++ b/auto_tests/misc/fake-jstestdriver.js @@ -43,18 +43,35 @@ function TestCase(name) { return "Fake test case " + name; }; - var emptyFunction = function() { return this; }; - emptyFunction.prototype.setUp = function() { }; - emptyFunction.prototype.tearDown = function() { }; - emptyFunction.prototype.runTest = function(name) { + var testCase = function() { return this; }; + testCase.prototype.setUp = function() { }; + testCase.prototype.tearDown = function() { }; + testCase.prototype.runTest = function(name) { try { this.setUp(); var fn = this[name]; fn.apply(this, []); this.tearDown(); + return true; } catch (e) { - console.log(e.stack); + console.log(e); + if (e.stack) { + console.log(e.stack); + } + return false; } }; - return emptyFunction; + testCase.prototype.runAllTests = function() { + // what's better than for ... in for non-array objects? + var tests = {}; + for (var name in this) { + if (name.indexOf('test') == 0 && typeof(this[name]) == 'function') { + console.log("Running " + name); + var result = this.runTest(name); + tests[name] = result; + } + } + console.log(prettyPrintEntity_(tests)); + }; + return testCase; };