Skip to content

Commit 8425b59

Browse files
Russ Amosjuangj
authored andcommitted
In webdriver.testing.jsunit, throw if the test suite is empty.
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 <[email protected]>
1 parent 241add4 commit 8425b59

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

javascript/webdriver/testing/jsunit.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,16 @@ webdriver.testing.jsunit.TestRunner.prototype.execute = function() {
7777
}
7878
this.screenshotCacheEl_.innerHTML = '';
7979
this.client_.sendInitEvent();
80+
81+
// This check adapted from goog.testing.TestRunner.prototype.execute.
82+
if (this.isStrict() && this.testCase.getCount() == 0) {
83+
this.client_.sendErrorEvent(
84+
'No tests found in given test case: ' + this.testCase.getName() + ' ' +
85+
'By default, the test runner fails if a test case has no tests. ' +
86+
'To modify this behavior, see goog.testing.TestRunner\'s ' +
87+
'setStrict() method.');
88+
}
89+
8090
this.testCase.setCompletedCallback(goog.bind(this.onComplete_, this));
8191
this.testCase.runTests();
8292
};

0 commit comments

Comments
 (0)