Unit tests in libraries?

Steven Schveighoffer schveiguy at yahoo.com
Mon Aug 16 05:37:35 PDT 2010


On Sat, 14 Aug 2010 23:35:54 -0400, Mike Linford  
<mike.linford.reg at gmail.com> wrote:

> Is this a bug? Unit tests do not seem to work in libraries. I'm using dmd
> 1.062 for linux.
>
> mylib.d :
> module mylib;
>
> void blah()
> {
> }
> unittest
> {
> 	assert(false);
> }
>
> main.d :
> module main;
>
> import mylib;
>
> void main()
> {
> 	blah();
> }
>
> The unit test does not get run when compiled as:
> dmd -lib mylib.d
> dmd main.d mylib.a
>
> But does get run when compiled as
> dmd main.d mylib.d
>
> Is this the intended behavior for unit tests in libraries?

Did you pass -unittest to dmd?  It needs to be there when compiling the  
file that contains unit tests.

I'm surprised unittests run at all with those compile lines.

-Steve


More information about the Digitalmars-d-learn mailing list