Re: Unit Testing With Function Mocking
- From: Ian Collins <ian-news@xxxxxxxxxxx>
- Date: Sat, 17 Mar 2007 18:53:02 +1300
Jack Klein wrote:
On Sat, 17 Mar 2007 11:30:59 +1300, Ian Collins <ian-news@xxxxxxxxxxx>Good point, printf was a bad example.
wrote in comp.lang.c:
gamename wrote:
Hi,
Currently, I'm using CUnit as a unit test tool. But there is one
thing it really lacks: function mocking. In other words, changing
what really gets called in subordinate routines so that a function
being tested has predictable behavior.
I know that CGreen has this ability, but it doesn't seem to work on
Cygwin. Also, its yet-another-tool to invest time on .
Is there any way to get this functionality in CUnit? Or, is there a
another tool that does a better job than CUnit or CGreen?
Any constructive ideas welcome.
You should be able to get away with something like this:
#include <stdio.h>
static int printf( const char* fmat, ...) { return 0; }
No guarantees, the behavior is specifically undefined.
I was just illustrating that a function declared in a header can be
substituted with (overloaded by?) a static function.
--
Ian Collins.
.
- Follow-Ups:
- Re: Unit Testing With Function Mocking
- From: goose
- Re: Unit Testing With Function Mocking
- References:
- Unit Testing With Function Mocking
- From: gamename
- Re: Unit Testing With Function Mocking
- From: Ian Collins
- Re: Unit Testing With Function Mocking
- From: Jack Klein
- Unit Testing With Function Mocking
- Prev by Date: Re: C89, size_t, and long
- Next by Date: Steve Summit C notes , exercise
- Previous by thread: Re: Unit Testing With Function Mocking
- Next by thread: Re: Unit Testing With Function Mocking
- Index(es):
Relevant Pages
|