listing multiple unit test failures

Robert Fraser fraserofthenight at gmail.com
Tue Mar 11 22:48:27 PDT 2008


Spacen Jasset wrote:
>     I have started some unit tests:
> 
>     unittest
>     {
>         // Check row column indexing is correct
>         Matrix    m;
>         m[2,0] = 59;
>         assert(m.matrix_flat[2]==59, "opIndexAssign failed");
>         assert(m.matrix_flat[8]!=59, "opIndexAssign failed");
>        
>     }
> 
> If an assert fails the other assertions in a program do not fire. This 
> is inconvient since the "real bug" introduced may be caused by some 
> other assertion that has not been evaluated yet.
> 
> What I am looking for, therefore is more of a writefln of each failure, 
> together with a single assertion to abort the program if any test has 
> failed.
> 
> If there isn't such a feature then I suppose I need a "Global" class 
> which holds a bit flag to be set when an assertion is registered, and 
> then in main this class could be made to assert if the flag is set.

Not to knock on Mr. Wright's solution, which is probably excellent and 
more directly addressable to the problem at hand, but I'm working on a 
solution (designed to use IPC to be used from other applications, etc.) 
that does just this and a lot more. Check:
http://www.dsource.org/projects/descent/browser/trunk/descent.unittest/flute/src/org/dsource/descent/unittests/flute.d

And the docs at:
http://svn.dsource.org/projects/descent/trunk/descent.unittest/flute/doc/flute.html


More information about the Digitalmars-d-learn mailing list