unittests, dub and libraries

Jonathan M Davis newsgroup.d at jmdavisprog.com
Wed Mar 28 23:20:40 UTC 2018


On Wednesday, March 28, 2018 21:29:22 Jesse Phillips via Digitalmars-d-learn 
wrote:
> On Wednesday, 28 March 2018 at 03:07:23 UTC, Jonathan M Davis
>
> wrote:
> > Run
> >
> >     dub test
> >
> > The problem is that an executable needs a main, and a library
> > doesn't have one, whereas when you're testing a library, you
> > need an executable. So, a main must be inserted - e.g. with the
> > -main flag to dmd. Just building the unittest build doesn't
> > insert one. However, dub test _does_ deal with that for you.
> >
> > - Jonathan M Davis
>
> And a note on the reverse, if you have an executable project $
> dub test won't build in the app.d file since it contains main and
> dub test wants to avoid running your main function.

Yeah. That's really annoying behavior. I keep forgetting that it does that
until I realize that I have tests that should be failing that aren't.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list