Unit Testing Exceptions

How is this done? I know mxunit has something but I am not getting it to work, how are you guys doing this?

Regards,

Andrew Scott

http://www.andyscott.id.au/

local.errorThrown = false;

try {
doMyTest();
fail(‘No error was thrown’);
} catch (any e) {
local.errorThrown = true;
assertEquals(“I expect this message”, e.message);
}
assert(local.errorThrown);

No that is not what I refer too, let’s say I have a method that expects certain exceptions being thrown. In mxUnit there is an exception annotation that you can use, which I have done before.

I need to test that the exception being thrown is indeed the exception that I expect. I was wondering as ColdBox uses mxunit for its tests, whether it also used this annotation, it is cleaner in my eyes.

I did think of what you wrote, but I wanted to check if the other methods that I have described are still valid.

Regards,

Andrew Scott

http://www.andyscott.id.au/