Unit testing D module

John Colvin john.loughran.colvin at gmail.com
Thu Dec 26 02:16:31 PST 2013


On Thursday, 26 December 2013 at 09:25:14 UTC, Dfr wrote:
> If i do not want to unit test whole codebase, because it big 
> enough and all tests take noticeable time to run.
>
> So i trying this:
>
> dmd -unittest mymodule.d
>
> And getting error: "undefined reference to `main'"
> But i don't want to run 'main' here, just unit test please.
> Any idea how to test single module without putting 'main' in 
> every module ?

the -main flag will do the trick, e.g.
dmd -unittest -main mymodule.d

Also, if you find you need more control then check out some of 
the testing frameworks/helpers here: http://code.dlang.org/ 
(ctrl+f test)


More information about the Digitalmars-d-learn mailing list