Skip to content

Commit

Permalink
Format console runners summary line differently
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Thomas committed Oct 30, 2010
1 parent 2295251 commit 9b6378f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 35 deletions.
61 changes: 37 additions & 24 deletions lib/console-runner.js
@@ -1,8 +1,3 @@
/* Console runner
*
* this is a mess right now, but it gets the job done!
*/

var assert = require('assert') var assert = require('assert')
, path = require('path') , path = require('path')
; ;
Expand Down Expand Up @@ -266,21 +261,21 @@ exports.run = function(list, options, callback) {
if (suiteResults.numFailures > 0) { if (suiteResults.numFailures > 0) {
console.log(''); console.log('');
last += ' '; last += ' ';
if (suiteResults.numFailures > 0) { if (suites.length > 1) {
last += ' FAILURES: '+suiteResults.numFailures+'/'+total+' tests failed.'; last += ' FAILURES: '+suiteResults.numFailures+'/'+total+' tests failed.';
} }
} }
else if (options.verbosity > 0 && suites.length > 1) { else if (suites.length > 1) {
last += ' '+green('OK: ')+total+' test'+(total == 1 ? '' : 's')+'. '+totalAssertions+' assertion'+(totalAssertions == 1 ? '' : 's')+'.'; last += ' '+green('OK: ')+total+' test'+(total == 1 ? '' : 's')+'. '+totalAssertions+' assertion'+(totalAssertions == 1 ? '' : 's')+'.';
} }
} }


if (options.verbosity == 0) { if (options.verbosity == 0) {
if (options.printSuccesses || suiteResults.numFailures >0) { if (options.printSuccesses || suiteResults.numFailures > 0) {
console.log(''); console.log('');
} }
} }
else if(suiteResults.numFailures > 0 || suites.length > 1) { else if(suiteResults.numFailures > 0 && suites.length > 1) {
console.log(last + ' ' + (suite.duration/1000) + ' seconds.'); console.log(last + ' ' + (suite.duration/1000) + ' seconds.');
console.log(''); console.log('');
} }
Expand Down Expand Up @@ -344,33 +339,51 @@ exports.run = function(list, options, callback) {
console.log('Did you forget to call test.finish()?'); console.log('Did you forget to call test.finish()?');
} }
, allDone: function() { , allDone: function() {
var successes = 0; var passingSuites = 0
var total = 0; , totalSuites = 0

, totalTests = 0
var allResults = suites.map(function(el) { , passingTests = 0
return el.results; ;
});


for(var i = 0; i < suites.length; i++) { for(var i = 0; i < suites.length; i++) {
total++; totalSuites++;
if (suites[i].status == 'suiteCompleted' && suites[i].results[0].numFailures == 0) { if (suites[i].status == 'suiteCompleted' && suites[i].results[0].numFailures == 0) {
successes++; passingSuites++;
}

if (typeof suites[i].results[0] == 'object' && 'numSuccesses' in suites[i].results[0]) {
totalTests += suites[i].results[0].numSuccesses + suites[i].results[0].numFailures;
passingTests += suites[i].results[0].numSuccesses;
}
else {
totalTests += NaN;
} }
} }


var last = ''; var last = '';
if (successes != total) { if (passingSuites != totalSuites) {
last += bold(red('PROBLEMS:')); last += red('PROBLEMS:');
last += bold(' '+(total-successes)+'/'+total+' suites had problems.'); last += ' '+(totalSuites-passingSuites)+'/'+totalSuites+' suites had problems.';
} }
else { else {
last += bold(green('SUCCESS:')); last += green('SUCCESS:');
last += bold(' '+total+'/'+total+' suites passed successfully.'); last += ' '+totalSuites+' suite' + (totalSuites == 1 ? '' : 's') + '.';
}

if (isNaN(totalTests)) {
last += ' Could not count tests.';
}
else if (passingTests != totalTests) {
last += ' ' + (totalTests-passingTests)+'/'+totalTests+' tests' + ' failed.';
} }
console.log(last + ' ' + bold(((new Date() - startTime)/1000)+' seconds.')); else {
last += ' ' + totalTests + ' test' + (totalTests == 1 ? '' : 's') + '.';
}

console.log(bold(last + ' ' + ((new Date() - startTime)/1000) + ' seconds.'));


if (callback) { if (callback) {
callback(total - successes); callback(totalSuites - passingSuites);
} }
} }
} }
Expand Down
22 changes: 11 additions & 11 deletions todo.txt
Expand Up @@ -2,34 +2,35 @@ Featueres (not sorted in order of importance
-------------------------------------------- --------------------------------------------
async_testing.run: async_testing.run:
+ better error handling when parsing arguments, and by better I mean, some + better error handling when parsing arguments, and by better I mean, some
+ rethink args to run's callback (make them more useful) <---- ? stop using home grown options parser and add one as a sub module?
+ help message summarizing async_testing in generateHelp + help message summarizing async_testing in generateHelp

+ rethink args to run's callback (make them more useful) <----

? allow a config file (at say ~/.node-async-testing.json) or something for ? allow a config file (at say ~/.node-async-testing.json) or something for
setting default run options, so say if you want the default to have tests and setting default run options, so say if you want the default to have tests and
suites be parallel you can do that. suites be parallel you can do that.
? make the default to be to run test and suites in parallel? ? make the default to be to run test and suites in parallel?
? Add new flag, which says to run everything in parallel, but if a suite fails ? Add new flag, which says to run everything in parallel, but if a suite fails
in some way, don't output it's results, instead re-run the suite serially in some way, don't output it's results, instead re-run the suite serially
+ stop using home grown options parser and add one as a sub module

Console Runner:
+ readd number of completed tests back to summary in console runner <----
? are we being too redundant when we have errors?


Web Runner: Web Runner:
+ only show suites that have tests we are running and only show those tests (in <----
the case of the --test-name flag)
+ checkbox for web runner to automatically run suites on window or tab focus + checkbox for web runner to automatically run suites on window or tab focus
+ keep track of which suites have been opened and are parallel across refreshes + keep track of which suites have been opened and are parallel across refreshes
(in a cookie) (in a cookie)
+ checkbox to run suites in parallel or not (right now you have to specify this <---- + checkbox to run suites in parallel or not (right now you have to specify this <----
via the command line) via the command line)
? Instead of just show test as blank when a file changes, mention something? ? Instead of just show test as blank when a file changes, mention something?
? Show number of failures when the test is closed? ? Show number of failures when the test is closed?
+ only show suites that have tests we are running and only show those tests (in <----
the case of the --test-name flag)


Running tests (async_testing.runSuite, async_testing.runFile): Running tests (async_testing.runSuite, async_testing.runFile):
? consider combining suiteCompleted, suiteError, suiteExit and suiteLoadError ? consider combining suiteCompleted, suiteError, suiteExit and suiteLoadError
all into one callback, (suiteDone) all into one callback, (suiteDone)
+ readd support for catching and reporting on errors that I ripped earlier this
month. They screw up suiteSetup and suiteTeardown and setup and teardown, but
we still might be able to make it work (v0.5)
? test.finish can take error? so you could say do: ? test.finish can take error? so you could say do:
`fs.readFile(test.finish)` `fs.readFile(test.finish)`
to make sure that readFile doesn't error without having to write your to make sure that readFile doesn't error without having to write your
Expand All @@ -45,10 +46,9 @@ Running tests (async_testing.runSuite, async_testing.runFile):
+ improve stack traces for assertion failures (remove first line, which is just + improve stack traces for assertion failures (remove first line, which is just
the wrapped assertion being called) the wrapped assertion being called)
+ code coverage + code coverage
+ readd support for catching and reporting on errors that I ripped earlier this ? add a script for running tests? (like we used to have...)
month. They screw up suiteSetup and suiteTeardown and setup and teardown, but
we still might be able to make it work


Docs Docs
---- ----
+ update docs and add list of command line arguments for run and what they do + update docs and add list of command line arguments for run and what they do
+ add note about contributing/contacting

0 comments on commit 9b6378f

Please sign in to comment.