Hack to name unit tests?

Robert Fraser fraserofthenight at gmail.com
Fri Nov 30 11:02:43 PST 2007


Christopher Wright wrote:
> Daniel Keep wrote:
>>
>> Christopher Wright wrote:
>>> ...
>>> There are advantages to throwing an exception when registering the name:
>>>
>>> unittest {
>>>    testName("this is the test that doesn't end");
>>>    while (true) {}
>>> }
>>>
>>> I was thinking that AssertionErrors couldn't be caught, but that was an
>>> error on my part.
>>
>> How is an exception an advantage in that case?  When you run the test,
>> it's still going to spinlock, no matter how you've obtained the name.
>>
>> If what you're trying to get at is that you can build a list of all the
>> names without having to run the actual test itself, then yes, I can see
>> that being an advantage.
> 
> Exactly, exactly! Precisely what I told Miss Chow. Tissue augmentation, 
> it's not a matter of twiddling bits.
> 
> On a more serious note, tools like the XUnit test runners display a list 
> of names without running the tests. That's convenient, I think. The 
> NUnit gui takes about twenty seconds to find all the unit tests we have 
> at work, and it takes two or three minutes to run the tests. If I want 
> to check a single test, two or three minutes is a long time.
> 
>>     -- Daniel

Check Don's post in this topic for a way to get test names w/o runnning 
them at all (and depending on them throwing the exception; that is, 
unnamed tests will still work correctly). I'm going to be implementing 
that... assuming I can get the free time & sleep required for that.



More information about the Digitalmars-d mailing list