Running unittests in a D library

Chris Molozian chris at cmoz.me
Wed Sep 19 12:16:50 PDT 2012


Actually after more digging it seems that unit testing libraries 
in D doesn't work.

It seems pretty bad that in 2012 with unit testing a huge part of 
the software development process and D describing itself as a 
language with unit testing built in, this bug report / feature 
request hasn't been addressed:

http://d.puremagic.com/issues/show_bug.cgi?id=4669

Is there any update on the status of this enhancement? Is there a 
recommended workaround to unit test a D library?

Cheers,

Chris


On Wednesday, 19 September 2012 at 18:49:12 UTC, Chris Molozian 
wrote:
> Hey all,
>
> I'm sure that this is a rather daft question but I've tried to 
> search the d.learn mailing list and must have missed a question 
> about it.
>
> I've read the unit testing documentation on dlang.org and I 
> know that `unittest { /* some code */ }` blocks are compiled 
> into the executable and executed after static initialization 
> and before the main() function is called. This makes sense in 
> an application but how does this apply to a library?
>
> For example, writing a D library using DMD's `-lib` compiler 
> flag, how do I run the unit tests in the generated library?
>
> Cheers,
>
> Chris




More information about the Digitalmars-d-learn mailing list