Options for unit testing in D?

XavierAP n3minis-git at yahoo.es
Sun Jun 23 07:19:16 UTC 2019


On Sunday, 23 June 2019 at 01:26:29 UTC, Mike Brockus wrote:
>
> I think we made a lot of progress, suddenly it's working and I 
> don't need to include main. Is there a way to indicate based on 
> console output that one executable is the tester and the other 
> is the application?

unittest blocks are skipped completely by the compiler when the 
-unittest command line option is not passed. So you can leave 
unittest code embedded in between the rest (specially for proper 
unit tests of functions and classes) and there is no need to 
worry about file separation. Even when you write a separate file 
with tests, all its code inside unittest blocks can be skipped 
for the compiler.

In the case of dub, it has a dedicated option, "dub test" instead 
of "dub build" or "dub run"

https://dub.pm/commandline.html#test


More information about the Digitalmars-d-learn mailing list