Unit Testing for Exceptions
Posted: Tue Jul 03, 2012 6:35 pm
In order for unit tests to really provide full coverage you need to make sure you are testing that your function throws exceptions when it's supposed to (lack of arguments, bad arguments, etc).
Currently we're rolled our own solution for this with the following function
But would be nice if our jsunit natively provided this kind of functionality. In other unit testing packages I've seen things like assertFail or assertThrows.
Official Request: https://support.servoy.com/browse/SVY-2596
Currently we're rolled our own solution for this with the following function
- Code: Select all
function assertException(fMethod, aArg, sMessage)
{
var bCaught = false;
try
{
fMethod.apply(null, aArg);
}
catch (e)
{
bCaught = true;
}
if (!bCaught)
{
jsunit.fail(sMessage);
}
}
But would be nice if our jsunit natively provided this kind of functionality. In other unit testing packages I've seen things like assertFail or assertThrows.
Official Request: https://support.servoy.com/browse/SVY-2596