X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Fmisc%2Ffake-jstestdriver.js;h=9ca10cd19464f1d40805f2ca45556e703aad35d7;hb=004b5c90b03ee12be0ac0e653ec4006970ee6740;hp=db535459efa3bc3ad4713074d2482f11692c7256;hpb=e07e165f49ac7a53a54b5eeeaa184a5fe6febfd4;p=dygraphs.git diff --git a/auto_tests/misc/fake-jstestdriver.js b/auto_tests/misc/fake-jstestdriver.js index db53545..9ca10cd 100644 --- a/auto_tests/misc/fake-jstestdriver.js +++ b/auto_tests/misc/fake-jstestdriver.js @@ -43,14 +43,32 @@ 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) { - this.setUp(); - var fn = this[name]; - fn.apply(this, []); - this.tearDown(); + 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); + 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; };