1
0
Fork 0

[#25] Tests with no assertions will be marked incomplete

closure/master
Mike Gerwitz 2011-11-03 22:25:00 -04:00
parent fdf630458a
commit 6fd7ae8953
1 changed files with 22 additions and 6 deletions

View File

@ -25,6 +25,7 @@
var assert = require( 'assert' ), var assert = require( 'assert' ),
assert_wrapped = {}, assert_wrapped = {},
acount = 0, acount = 0,
icount = 0,
// when set to true, final statistics will be buffered until suite ends // when set to true, final statistics will be buffered until suite ends
suite = false, suite = false,
@ -84,7 +85,10 @@ function incAssertCount()
module.exports = function( test_case ) module.exports = function( test_case )
{ {
var context = prepareCaseContext(), var context = prepareCaseContext(),
setUp = test_case.setUp; setUp = test_case.setUp,
acount_last = 0
;
// if we're not running a suite, clear out the failures // if we're not running a suite, clear out the failures
if ( !( suite ) ) if ( !( suite ) )
@ -108,12 +112,24 @@ module.exports = function( test_case )
setUp.call( context ); setUp.call( context );
} }
acount_last = acount;
try try
{ {
test_case[ test ].call( context ); test_case[ test ].call( context );
scount++; // if there were no assertions, then the test should be marked as
testPrint( '.' ); // incomplete
if ( acount_last === acount )
{
testPrint( 'I' );
icount++;
}
else
{
scount++;
testPrint( '.' );
}
} }
catch ( e ) catch ( e )
{ {
@ -137,8 +153,7 @@ module.exports = function( test_case )
function init() function init()
{ {
failures = []; failures = [];
scount = 0; scount = acount = icount = 0;
acount = 0;
} }
@ -158,7 +173,8 @@ function endStats()
testPrint( testPrint(
( ( failures.length ) ? "FAILED" : "OK" ) + " - " + ( ( failures.length ) ? "FAILED" : "OK" ) + " - " +
scount + " successful, " + failures.length + " failure(s), " + scount + " successful, " + failures.length + " failure(s), " +
( scount + failures.length ) + " total " + ( ( icount > 0 ) ? icount + ' incomplete, ' : '' ) +
( scount + icount + failures.length ) + " total " +
'(' + acount + " assertion" + ( ( acount !== 1 ) ? 's' : '' ) + ")\n" '(' + acount + " assertion" + ( ( acount !== 1 ) ? 's' : '' ) + ")\n"
); );