Moved setup method for XUnit style testing into tryTest() function to properly handle exceptions
- Most importantly in this case, skipsperfodd
parent
e67c14e8c3
commit
0d306b63c8
|
@ -108,12 +108,6 @@ module.exports = function( test_case )
|
||||||
// run each test in the case
|
// run each test in the case
|
||||||
for ( var test in test_case )
|
for ( var test in test_case )
|
||||||
{
|
{
|
||||||
// xUnit-style setup
|
|
||||||
if ( setUp )
|
|
||||||
{
|
|
||||||
setUp.call( context );
|
|
||||||
}
|
|
||||||
|
|
||||||
var data = test.match( /^(?:@(.*?)\((.*?)\))?(.*)$/ ),
|
var data = test.match( /^(?:@(.*?)\((.*?)\))?(.*)$/ ),
|
||||||
method = data[ 1 ],
|
method = data[ 1 ],
|
||||||
prop = data[ 2 ],
|
prop = data[ 2 ],
|
||||||
|
@ -144,6 +138,7 @@ module.exports = function( test_case )
|
||||||
tryTest(
|
tryTest(
|
||||||
test_case,
|
test_case,
|
||||||
test,
|
test,
|
||||||
|
( setUp || null ),
|
||||||
name + ( ( count > 1 )
|
name + ( ( count > 1 )
|
||||||
? ( ' (' + i + ')' )
|
? ( ' (' + i + ')' )
|
||||||
: ''
|
: ''
|
||||||
|
@ -171,18 +166,25 @@ module.exports = function( test_case )
|
||||||
*
|
*
|
||||||
* @param {Object} test_case object containing all test cases
|
* @param {Object} test_case object containing all test cases
|
||||||
* @param {string} test complete key of test to run
|
* @param {string} test complete key of test to run
|
||||||
|
* @param {Function} setUp test setup method, or null
|
||||||
* @param {string} test_str text to use on failure
|
* @param {string} test_str text to use on failure
|
||||||
* @param {Object} context context to bind to test function
|
* @param {Object} context context to bind to test function
|
||||||
* @param {Array} args arguments to pass to test function
|
* @param {Array} args arguments to pass to test function
|
||||||
*
|
*
|
||||||
* @return {undefined}
|
* @return {undefined}
|
||||||
*/
|
*/
|
||||||
function tryTest( test_case, test, test_str, context, args )
|
function tryTest( test_case, test, setUp, test_str, context, args )
|
||||||
{
|
{
|
||||||
var acount_last = acount;
|
var acount_last = acount;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// xUnit-style setup
|
||||||
|
if ( setUp )
|
||||||
|
{
|
||||||
|
setUp.call( context );
|
||||||
|
}
|
||||||
|
|
||||||
test_case[ test ].apply( context, args );
|
test_case[ test ].apply( context, args );
|
||||||
|
|
||||||
// if there were no assertions, then the test should be marked as
|
// if there were no assertions, then the test should be marked as
|
||||||
|
|
Loading…
Reference in New Issue