digitalmars.D.learn - Unittest
- bioinfornatics (21/21) Dec 16 2012 Dear,
- Dan (15/38) Dec 16 2012 A simpler way is to use rdmd. Suppose you have a file called
- Jacob Carlborg (6/26) Dec 16 2012 You don't necessarily need to import the other files. As long as all
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
Dec 16 2012
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 thanksA 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
Dec 16 2012
On 2012-12-16 19:39, 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 unittestYou don't necessarily need to import the other files. As long as all files are compiled it should run the unit tests for all files. You do need a main function. -- /Jacob Carlborg
Dec 16 2012