Named unittests
Idan Arye via Digitalmars-d
digitalmars-d at puremagic.com
Wed Apr 1 11:35:13 PDT 2015
On Wednesday, 1 April 2015 at 14:05:46 UTC, Jacob Carlborg wrote:
> 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
The problem is not with running the tests, it's with building
them. In heavily templated libraries(like, for example Phobos),
building without unittests takes seconds and building with
unitetests takes minutes - mainly because the tests need to to
many template instantiations. If we could tell the compiler to
only build a single, specific test the development cycle can
become orders of magnitude faster.
More information about the Digitalmars-d
mailing list