unittest vs exceptions?

Jonathan M Davis jmdavisProg at gmx.com
Sat Aug 4 15:25:34 PDT 2012


On Sunday, August 05, 2012 00:15:49 David Nadlinger wrote:
> A failed unit test really just means that a unit test block is
> left via an exception. Currently, it just bubbles up to the
> druntime main(), where it is printed to console and causes a
> non-zero exit code, but future unit test frameworks could handle
> this in a more advanced way.

They could, but I think that it's pretty normal to just treat any thrown 
exception as a test failure. The only difference here and what I've seen in 
other test frameworks, is that most test frameworks would actually tell you 
what test failed, which really doesn't work in D, since unittest blocks are 
unnamed (whereas most unit test frameworks used named tests). That's one of 
the reasons why I'd love it if we could start naming unittest blocks, but in 
spite of some interest in such a feature, no one has implemented it yet.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list