Skip to content

Commit

Permalink
Merge pull request #15887 from rwjblue/emit-test-counts
Browse files Browse the repository at this point in the history
Emit valid test counts after each test run.
  • Loading branch information
rwjblue authored Nov 29, 2017
2 parents b19c4f7 + a0245da commit 2b79739
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
10 changes: 9 additions & 1 deletion bin/run-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ function runInBrowser(url, retries, resolve, reject) {

var addLogging = function() {
window.document.addEventListener('DOMContentLoaded', function() {
var testsTotal = 0;
var testsPassed = 0;
var testsFailed = 0;
var currentTestAssertions = [];

QUnit.log(function (details) {
Expand Down Expand Up @@ -96,19 +99,24 @@ function runInBrowser(url, retries, resolve, reject) {
}
name += result.name;

testsTotal++;

if (result.failed) {
testsFailed++;
console.log('\n' + 'Test failed: ' + name);

for (i = 0, len = currentTestAssertions.length; i < len; i++) {
console.log(' ' + currentTestAssertions[i]);
}
} else {
testsPassed++;
}

currentTestAssertions.length = 0;
});

QUnit.done(function (result) {
console.log('\n' + 'Took ' + result.runtime + 'ms to run ' + result.total + ' tests. ' + result.passed + ' passed, ' + result.failed + ' failed.');
console.log('\n' + 'Took ' + result.runtime + 'ms to run ' + testsTotal + ' tests. ' + testsPassed + ' passed, ' + testsFailed + ' failed.');

if (typeof window.callPhantom === 'function') {
window.callPhantom({
Expand Down
18 changes: 18 additions & 0 deletions tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,29 @@
QUnit.config.reorder = false;
}

var testsTotal, testsPassed, testsFailed;

QUnit.begin(function() {
testsTotal = testsPassed = testsFailed = 0;

if (QUnit.urlParams.hideskipped) {
$('#qunit-tests').addClass('hideskipped');
}
});

QUnit.testDone(function(results) {
testsTotal++;

if (results.failed) {
testsFailed++;
} else {
testsPassed++;
}
});

QUnit.done(function(result) {
console.log('\n' + 'Took ' + result.runtime + 'ms to run ' + testsTotal + ' tests. ' + testsPassed + ' passed, ' + testsFailed + ' failed.');
});
})();
</script>

Expand Down

0 comments on commit 2b79739

Please sign in to comment.