curl-library
Re: documenting unit tests for functions
Date: Sun, 15 May 2011 15:32:04 +0300
On Wed, May 11, 2011 at 7:46 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:
> On Wed, 11 May 2011, Amr Shahin wrote:
>
> I'm back to adding unit tests for curl, and i think there should be an
>> easy way for contributors to know whether a test is implemented for a
>> certain function, what i have in mind is to add a comment looking pretty
>> much like this:
>>
>> /* unit-tested
>>
>> * @file unit1300.c
>>
>> * @line 147
>>
>> * */
>>
>
> I think this is a good idea. I would however prefer it to be a more compact
> more easily machine-parsed format, like perhaps:
>
> /*
> * @unit-test: 1300
> */
>
> ... without reference to exact line number since that is doomed to change
> over time, and unit-tests should preferably be focused on a single function
> in each test anyway.
>
>
> I was wondering if it's best to add this to the .h file or the .c file
>>
>
> I say the .c file since we might end up with tests even for static
> functions that have no prototypes in .h files.
>
> --
>
> / daniel.haxx.se
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html
>
I agree with no mentioning the line number, however we could use a more
formal way by assigning a test-case-id to each function we test, it will
look something like this:
unit1300.c:
/**
* @startTestCase: 1300-1
**/
...
/**
* @endTestCase 1300-1
**/
llist.c:
/**
* @unit-test(ed?)
* @testCase: 1300-1
**/
this will make tests easy to find, especially if the developer only wants to
take a look at the test to see what assumptions are made or how to call a
certain API.
*Amr*
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-05-15