Mocks and coverage with gtk/glib test frameworks?

2009-10-26 Thread Michael Libby
Forgive me if I'm on the wrong list with these questions, but gtk-devel
seems to be the place where most gtk/glib test discussion has occurred. If
there's a more appropriate place to bring this up, please let me know.

I am using the gtk/glib test frameworks to do test driven development in C.

Two things that I'm wondering:

1. Is there a way to build mocks to use with the gtk or glib test
frameworks?

I can code a mock_whatever.c file that implements the "interface" defined by
whatever.h and link the resulting whatever.o in my test fixture... and maybe
that's the easiest/best way? But I am curious if there is already a way to
do mocking that I should be aware of.

2. Is there any way to measure code coverage?

I'm sure the debugger must instrument the code somehow. And I'm sure I could
measure coverage with macros or a preprocessor that finds all the
checkpoints to measure and puts calls to a few functions that record
coverage data. But I wonder if there is already a way to do this with
existing tools or methods?

Thanks!

-- 
Michael C. Libby
www.mikelibby.com
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: Mocks and coverage with gtk/glib test frameworks?

2009-10-26 Thread Simon McVittie
On Mon, 26 Oct 2009 at 06:58:35 -0500, Michael Libby wrote:
> 2. Is there any way to measure code coverage?

In Telepathy we use the standard gcov framework that comes with gcc, together
with lcov (apt-get install lcov) to produce a nice HTML report. For instance,
have a look at /m4/compiler.m4 and /tools/lcov.am in telepathy-glib (which
are glued in to the build via /configure.ac and /Makefile.am respectively).

Regards,
Simon


signature.asc
Description: Digital signature
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list