Better unittest failure output

anonymous via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Sep 7 05:06:08 PDT 2015


On Monday 07 September 2015 13:57, Bahman Movaqar wrote:

> I am working on a simple project created with DUB[1].
> When unit tests the output reads really cryptic to me; for 
> example:
> 
>      $ dub test
[...]
>      core.exception.AssertError at source/e002.d(111): unittest 
> failure
[...]
> 
> It is almost impossible for me to comprehend anything useful out 
> of this, except that, well, the tests have failed :-)

>From that one line I left intact above, you should also be able to figure 
out that it's the test in source/e002.d, line 111 that failed.

> Is there any compiler switch, argument to `assert` or trick to 
> make `unittest` output more helpful messages when failing?

You can pass a custom message as a second argument to assert:
assert(condition, "message goes here");

I think there are testing libraries/frameworks around that mean to provide 
more than the basic built-in things. But I haven't tried any, so I can't 
recommend anything. Try searching for "test" here: http://code.dlang.org/


More information about the Digitalmars-d-learn mailing list