digitalmars.D.learn - How to run only one chosen unittest
- madwebness (26/26) Dec 16 2025 Been banging my head with ChaptGPT on this one, it just couldn't
- Mike Parker (9/12) Dec 16 2025 There's no way to run individual tests with the vanilla framework
- madwebness (3/6) Dec 18 2025 Thanks for recommending unit-threaded, it's actually pretty great
- monkyyy (4/6) Dec 16 2025 opend has a single module unittest flag, but if you thought
Been banging my head with ChaptGPT on this one, it just couldn't
figure it out how to run only a particular unittest with `dub
test`, so I have to ask.
I only use standard `unittest {}`, no libraries. It's quite often
that I just want to run one single unit test - or, at the very
least, only tests in one particular module (if one test isn't
possible).
To give you an idea from other languages, Iin Go + Ginkgo this
would be:
```
It("should run this one", Label("onlythis"), func() { ...
```
in Ruby / rspec it'd be something like:
```
rspec path/to/test.rb:25
```
where 25 is the line number of unit test starts.
I understand that even in Go or Ruby - those are the testing
libraries in my examples, not something native to the language,
but I was still wondering if something like that is possible in
D. I wouldn't even mind writing some short Bash script that would
temporarily manipulate `dub.json` or something like that - to
achieve what I want. The number of unittests in my codebase is
getting larger and I feel it might be the right time to address
this problem.
Would appreciate some any ideas here.
Dec 16 2025
On Tuesday, 16 December 2025 at 10:40:34 UTC, madwebness wrote:Been banging my head with ChaptGPT on this one, it just couldn't figure it out how to run only a particular unittest with `dub test`, so I have to ask.There's no way to run individual tests with the vanilla framework that I'm aware of. You can run the tests in individual modules by invoking the compiler directly with the given source file, e.g., `dmd -c -unittest foo.d`. unit-threaded gives you the ability to name tests and run them individually: https://code.dlang.org/packages/unit-threaded Other third-party packages may do the same.
Dec 16 2025
On Tuesday, 16 December 2025 at 10:57:30 UTC, Mike Parker wrote:unit-threaded gives you the ability to name tests and run them individually: https://code.dlang.org/packages/unit-threadedThanks for recommending unit-threaded, it's actually pretty great and does exactly what I need and also runs tests faster too.
Dec 18 2025
On Tuesday, 16 December 2025 at 10:40:34 UTC, madwebness wrote:or, at the very least, only tests in one particular module (if one test isn't possible).opend has a single module unittest flag, but if you thought modifying dub was the answer look at the dub unittest things, I think theres 3.
Dec 16 2025









madwebness <madwebness noreply.noreply> 