Improving unit tests

Gide Nwawudu gide at btinternet.com
Fri Nov 7 15:56:26 PST 2008


On Fri, 07 Nov 2008 16:55:14 -0500, Jason House
<jason.james.house at gmail.com> wrote:

>Janderson Wrote:
>
>>  > Someone who's a big unittesting fan should write up a proposal on
>>  > this.  I think unittests are neat and all -- I probably don't use them
>>  > as much as I should -- but I don't really know what's so great about
>>  > named unittests or other things people mention that D's unittests
>>  > lack.  I suspect Walter may be in the same boat.  You can't address a
>>  > problem if you don't really understand it.
>>  > --bb
>> 
>> Its funny, I was just thinking last night of starting a new thread about 
>> exactly that.  For me I only ever use unit tests in a simple way however 
>> I'd like to learn about move advanced features that D is missing.
>> 
>> I was originally thinking, maybe unit tests shouldn't be part of D to 
>> allow for innovation. However then I though, what about if D's unit 
>> tests where extensible though some language syntax?
>> 
>> Questions:
>> 1) What features are missing from D's unit tests that you miss?
>
>Named unit tests
>Reporting individual failures and continuing. Note that you can recover from module testing failures, but not from individual tests.
>Compile-time unit tests, especially when making release builds.
>

Nestable named unittest would be nice. If one group fails, report the
error and move onto the next.

unittest ("XML") {
	unittest("elements") {
	    assert(isValidXml("<aaa />"));
	    assert(isValidXml("<aaa/>"));
	    assert(isValidXml("<aaa></aaa>"));
            ...
	}
	unittest("attributes") {
	    assert(isValidXml("<aaa abc="\x\"/>"));
	    assert(isValidXml("<aaa abc=\"x\" def=\"y\"/>"));
            ...
	}
	unittest("encoding") {
	    assert(encode("hello") is "hello");
	    assert(encode("a > b") == "a &gt; b");
	    ...
	}		
}

> 
>> 2) Should D decouple unittests from the language or should there be 
>> language changes to allow for for more extensible unit tests?
>
>I like having them built in.

Agreed

> 
>> 3) If you chose "more extensible unit tests" what language features 
>> would be needed to make this happen.
>
>I hope an author of one of the DUnit libraries answers this part.
>> 
>> -Joel

Gide



More information about the Digitalmars-d mailing list