Skip to content

Commit

Permalink
In webdriver.testing.jsunit, throw if the test suite is empty.
Browse files Browse the repository at this point in the history
Previously, empty test suites would result in silent passes, meaning
incorrectly named tests or tests with syntax errors (which don't get
counted) would cause a false positive.

Signed-off-by: Jason Juang <juangj@google.com>
  • Loading branch information
Russ Amos authored and juangj committed Feb 10, 2016
1 parent 241add4 commit 8425b59
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions javascript/webdriver/testing/jsunit.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ webdriver.testing.jsunit.TestRunner.prototype.execute = function() {
}
this.screenshotCacheEl_.innerHTML = '';
this.client_.sendInitEvent();

// This check adapted from goog.testing.TestRunner.prototype.execute.
if (this.isStrict() && this.testCase.getCount() == 0) {
this.client_.sendErrorEvent(
'No tests found in given test case: ' + this.testCase.getName() + ' ' +
'By default, the test runner fails if a test case has no tests. ' +
'To modify this behavior, see goog.testing.TestRunner\'s ' +
'setStrict() method.');
}

this.testCase.setCompletedCallback(goog.bind(this.onComplete_, this));
this.testCase.runTests();
};
Expand Down

0 comments on commit 8425b59

Please sign in to comment.