Catching Errors

Adam D. Ruppe via Digitalmars-d digitalmars-d at puremagic.com
Fri Jan 20 06:22:23 PST 2017


On Friday, 20 January 2017 at 07:50:23 UTC, Jacob Carlborg wrote:
> That doesn't work well with a unit test framework that want to 
> catch assertions to be able to continue with other tests.

I'd suggest writing a new assert handler for your framework that 
does something different, then you can get a bit more control 
over it.

Though, the built in assert is underpowered regardless... oh, how 
I wish it even had the convenience of C's assert, but I really 
want it to go a step further and show the values as well as the 
code that is failing.

int a = 0;
int b = 1;
assert(a == b);

Assertion `a == b` failed: test.d(3)
  a = 0
  b = 1


I know unit test frameworks tend to offer their own functions to 
get closer to this but it'd be compelling to me if it just worked 
with the built in too.



Oh well, that's not today, but doing your own assert handler that 
just prints and continues, or prints and aborts the current test 
while continuing with the next or something like that is doable 
and perhaps useful.


More information about the Digitalmars-d mailing list