selective tests

Jonathan M Davis newsgroup.d at jmdavisprog.com
Sat Oct 12 09:52:59 UTC 2019


On Saturday, October 12, 2019 2:18:02 AM MDT Martin Brezeln via Digitalmars-
d-learn wrote:
> Is it possible to execute only certain modules or tests which are
> defined in certain directories?
>
> For example, in go one can run "go test ./XYZ" to execute ony
> tests in ./XYZ or "go test ./..." to execute all the tests in and
> under the current directory.
>
> Please don't get me wrong, i do not wish to start a discussion
> about doing things the "go way". I am asking if there is a way to
> achieve a similar result with dub (or maybe without dub?
> 🤔)

The default test runner does not support running only some of the tests. It
simply runs all of the unittest blocks in the binary prior to running main,
and tests only get skipped when they're either not compiled in or when a
previous unittest block in that module failed.

You could set up your build so that you had targets which only compiled
specific directories so that the only unit tests that were run were the ones
in those directories, but I don't think that it's possible to do anything
like that with dub. Certainly, if it is, it would be a royal pain to set up.

Really, if you want to control which tests get run instead of simply always
running them all, then you'll need to use an alternate test runner which
supports that. There are a few test runners available on code.dlang.org, and
I expect that at least one of them supports that (probably multiple do).

- Jonathan M Davis






More information about the Digitalmars-d-learn mailing list