About JSON-GLib: things have gone quiet on that front, but lately I’ve resumed working on it ((In a couple of separate branches, for the time being, but when those are ready, they will be merged back into master and will be released as 0.6.0)).

I decided to try the new GLib test framework that has landed in the 2.15 cycle; GLib and GTK+ are both already using it, and now a branch of JSON-GLib is GTest-powered. Setting it up is not hard – but it requires some changes in the build environment. The API is quite straightforward — just call:

  g_test_init (&argc, &argv, NULL);

inside your main, then add the test functions with:

  g_test_add_func ("/test-section/foo", test_function_foo);
  g_test_add_func ("/test-section/bar", test_function_bar);

and finally run the test using:

  return g_test_run ();

which will return the exit code used by the gtester program to determined whether the successfully test passed or not.

The test suite is built along with your library or application, but run only with make check and make distcheck. There’s also an automatic report generator which will dump an XML file with the results, which you can then parse to create HTML pages or other forms of report. The rest of the work is putting a set of pre-cooked declarations for the Makefile templates into the root of your project; including it in every file; create some tests directories; and dump there the test units. I bet that Anjuta or other IDEs with autotools support can be tweaked to do this stuff for you.

JSON-GLib is now using GTest to test the data types API (for the time being, Array and part of the Node) and the Parser behaviour; nothing very complicated, at first, but it’s good to have it all automated and a simple make away. Adding new test cases to exercise the whole API will be the priority in the next weeks.