Named unittests

Jacob Carlborg via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 1 07:05:45 PDT 2015


On 2015-03-31 23:14, Idan Arye wrote:

> Building by unittest name! Imagine - instead of placing temporary code
> in `main` to develop a new feature or fix a bug, you put in a named
> unittest and tell your IDE/build-system to only build that unittest(and
> whatever code needed for it to run). You `writeln` stuff to the console,
> and when you get some changes to output what you want you change the
> `writeln`s to `assert`s and proceed to work on the next step. When you
> are done, all you have to do is tidy it up a bit and BAM - without any
> special effort you get a unittest that tests that feature/bug you just
> worked on.

You just reinvented test driven development ;). It's perfectly possible 
to do this with a UDA an a text string as well. UDA's also allows you to 
tag the tests. Basically a short name you put on multiple tests, then 
tell the test runner to run only those tests, or ignore those.

@tag("foo") @name("this is my test name") unittest {}

$ run-tests -t foo

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list