Thread overview | |||||
---|---|---|---|---|---|
|
November 06, 2015 Unittest in a library | ||||
---|---|---|---|---|
| ||||
Is it possible to have unittest blocks if I'm compiling a library? I've tried having this: test.d: class Classy { unittest { assert(0, "failed test"); } } and then build it with `dmd test.d -lib -unittest` and it doesn't fail the unittest. |
November 06, 2015 Re: Unittest in a library | ||||
---|---|---|---|---|
| ||||
Posted in reply to Charles | On Friday, 6 November 2015 at 03:59:07 UTC, Charles wrote: > Is it possible to have unittest blocks if I'm compiling a library? > > I've tried having this: > > test.d: > > class Classy { > unittest { assert(0, "failed test"); } > } > > > and then build it with `dmd test.d -lib -unittest` and it doesn't fail the unittest. You can test the unittests by using the -main switch. http://dlang.org/dmd-linux.html#switch-main |
November 06, 2015 Re: Unittest in a library | ||||
---|---|---|---|---|
| ||||
Posted in reply to TheFlyingFiddle | On Friday, 6 November 2015 at 04:34:28 UTC, TheFlyingFiddle wrote:
> On Friday, 6 November 2015 at 03:59:07 UTC, Charles wrote:
>> Is it possible to have unittest blocks if I'm compiling a library?
>>
>> I've tried having this:
>>
>> test.d:
>>
>> class Classy {
>> unittest { assert(0, "failed test"); }
>> }
>>
>>
>> and then build it with `dmd test.d -lib -unittest` and it doesn't fail the unittest.
>
> You can test the unittests by using the -main switch.
> http://dlang.org/dmd-linux.html#switch-main
That's exactly what I was missing. Thanks!
|
Copyright © 1999-2021 by the D Language Foundation