[#29] Added test skipping support to test case
parent
cb6c4af763
commit
1332da78a2
|
@ -26,11 +26,15 @@ var assert = require( 'assert' ),
|
||||||
assert_wrapped = {},
|
assert_wrapped = {},
|
||||||
acount = 0,
|
acount = 0,
|
||||||
icount = 0,
|
icount = 0,
|
||||||
|
skpcount = 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,
|
||||||
failures = [],
|
failures = [],
|
||||||
|
|
||||||
|
// dummy object to be thrown for test skipping
|
||||||
|
SkipTest = { skip: true },
|
||||||
|
|
||||||
common_require = require( __dirname + '/common' ).require
|
common_require = require( __dirname + '/common' ).require
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -132,11 +136,19 @@ module.exports = function( test_case )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( e )
|
catch ( e )
|
||||||
|
{
|
||||||
|
if ( e === SkipTest )
|
||||||
|
{
|
||||||
|
testPrint( 'S' );
|
||||||
|
skpcount++;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
testPrint( 'F' );
|
testPrint( 'F' );
|
||||||
failures.push( [ test, e ] );
|
failures.push( [ test, e ] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// only output statistics if we're not running a suite (otherwise they'll be
|
// only output statistics if we're not running a suite (otherwise they'll be
|
||||||
// output at the end of the suite)
|
// output at the end of the suite)
|
||||||
|
@ -153,7 +165,7 @@ module.exports = function( test_case )
|
||||||
function init()
|
function init()
|
||||||
{
|
{
|
||||||
failures = [];
|
failures = [];
|
||||||
scount = acount = icount = 0;
|
scount = acount = icount = skpcount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -174,7 +186,8 @@ function endStats()
|
||||||
( ( failures.length ) ? "FAILED" : "OK" ) + " - " +
|
( ( failures.length ) ? "FAILED" : "OK" ) + " - " +
|
||||||
scount + " successful, " + failures.length + " failure(s), " +
|
scount + " successful, " + failures.length + " failure(s), " +
|
||||||
( ( icount > 0 ) ? icount + ' incomplete, ' : '' ) +
|
( ( icount > 0 ) ? icount + ' incomplete, ' : '' ) +
|
||||||
( scount + icount + failures.length ) + " total " +
|
( ( skpcount > 0 ) ? skpcount + ' skipped, ' : '' ) +
|
||||||
|
( scount + icount + skpcount + failures.length ) + " total " +
|
||||||
'(' + acount + " assertion" + ( ( acount !== 1 ) ? 's' : '' ) + ")\n"
|
'(' + acount + " assertion" + ( ( acount !== 1 ) ? 's' : '' ) + ")\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -229,6 +242,12 @@ function getMock( proto )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function skipTest()
|
||||||
|
{
|
||||||
|
throw SkipTest;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare assertion methods on context
|
* Prepare assertion methods on context
|
||||||
*
|
*
|
||||||
|
@ -252,6 +271,7 @@ function prepareCaseContext()
|
||||||
incAssertCount: incAssertCount,
|
incAssertCount: incAssertCount,
|
||||||
|
|
||||||
getMock: getMock,
|
getMock: getMock,
|
||||||
|
skip: skipTest,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue