Failed unittest
Robik
szadows at gmail.com
Mon Aug 20 11:02:13 PDT 2012
On Monday, 20 August 2012 at 09:51:10 UTC, monarch_dodra wrote:
> I'm wondering if:
> 1) Would it be possible to compile "as many unittests as
> possible", and simply omit the tests that static assert? This
> would create a "unit test compilation failure", but not prevent
> the tests that *did* compile from moving on to the run-time
> testing.
> 2) Would it be possible to execute ALL unit tests, even after
> one fails?
Yes.
You can set assertHandler to your own function.
Something like:
import core.exception, std.stdio;
void handler(string file, ulong line, string msg)
{
if(msg == null) {
writefln("-- %s(%d)", file, line);
} else {
writefln("-- %s(%d): %s", file, line, msg);
}
}
void main(){}
unittest
{
setAssertHandler(&handler);
assert(1==2);
assert(1==3, "1 is not equal to 3");
}
More info can be found here:
http://dlang.org/phobos/core_exception.html
More information about the Digitalmars-d
mailing list