Strategy for unit testing GTK+ applications in C
- From: John Tall <mjtallx gmail com>
- To: gtk-list gnome org
- Subject: Strategy for unit testing GTK+ applications in C
- Date: Sat, 16 May 2015 11:45:15 +0200
Hello.
I'm about to start working on a new GTK+ application that will be
written in C. I want to use unit tests, probably the GTest APIs from
GLib.
I've used the GTest APIs before when building a library. What I did
then was that I put all the source code for the library in one
directory, all unit tests in another directory. Using Automake I built
each unit test as a standalone program that linked to the library, and
could just run each unit test to test the library.
This time however I'm building an application, so it will already have
its own main routine. I can't link my unit tests to the application
because that would give me two main routines, the main entry point of
the application and the main entry point of the unit test. So my
question is how to construct the application so that I can test it
with unit tests?
My first thought was to just build the entire application as a library
and link the unit tests with it, then all I would need for the actual
application would be a separate program that just creates an instance
of my GtkApplication subclass and runs it. It would be small enough
that it doesn't need any unit tests, and I could even link it
statically when installing the program.
This sounds to me like the perfect solution, but I haven't found other
applications that follows the same approach. I would therefore like to
ask if this is a good idea or if there are better ways to do this?
Especially if there are good examples from existing applications that
I could look at that would be very useful.
John
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]