On Sunday, 16 December 2012 at 18:39:30 UTC, bioinfornatics wrote:
Dear,
I would like to understand if to have an empty main file ils
need to use
unittest.
I explain i have a library with some unittest section
-- foo.d--
void doFoo(){ ... }
unittest{
scope(success) writeln( "ok" );
scope(failure) writeln( "no" );
doFoo();
}
------
to use unittest i need to have main file which import each
library
module as
--- main.d- --
import foo1, foo2, foo3;
void main(){}
-------
why they are not a dflag to do this?
Maybe that is me where is use badly d unittest
thanks
A simpler way is to use rdmd. Suppose you have a file called
history.d with a one or more unittest sections. You could just
run:
rdmd --force -g -w --main -unittest history.d
This would provide a simple main and run the unittests in one go.
The --force is not needed, but if you have added an import
statement anywhere it will ensure everything is rebuilt. If you
have just recently run this command, you can run again without
--force.
One thing to be aware of, I think when using unittest sections,
not only are your unittests run, but unittests of all your
imports.
Thanks
Dan