- var emptyFunction = function() { return this; };
- emptyFunction.prototype.setUp = function() { };
- emptyFunction.prototype.tearDown = function() { };
- emptyFunction.prototype.runTest = function(name) {
+ testCase.prototype.setUp = function() { };
+ testCase.prototype.tearDown = function() { };
+ testCase.prototype.name = name;
+ /**
+ * name can be a string, which is looked up in this object, or it can be a
+ * function, in which case it's run.
+ *
+ * Examples:
+ * var tc = new MyTestCase();
+ * tc.runTest("testThis");
+ * tc.runTest(tc.testThis);
+ *
+ * The duplication tc in runTest is irritating, but it plays well with
+ * Chrome's console completion.
+ */
+ testCase.prototype.runTest = function(func) {
+ var result = false;
+ var ex = null;
+ var name = typeof(func) == "string" ? func : "(anonymous function)";
+ jstestdriver.announce_("start", [this, name]);
+ try {
+ result = this.runTest_(func);
+ } catch (e) {
+ ex = e;
+ }
+ jstestdriver.announce_("finish", [this, name, result, ex]);
+ return result; // TODO(konigsberg): Remove this, and return value from runAllTests.
+ }
+
+ testCase.prototype.runTest_ = function(func) {