GLib Testing Framwork

GLib provides a testing framework.

There are two parts: a set of functions in GLib that you can use when writing unit tests, and a test runner tool named gtester.

Do not confuse GLib's test framework with the Google Test framework. GLib's test runner is called gtester while Google Test is often called 'gtest', so it's easy to get them mixed up.

GTester XML format

GTester can generate a machine-readable summary of the test results (with the -o option). The report uses a GTester-specific XML format.

Here is an example of the output:

<?xml version="1.0"?>
  <testbinary path="binding">
    <binary file="/home/shared/gnome/src/glib/gobject/tests/.libs/lt-binding"/>
    <testcase path="/binding/transform-closure">
      <status exit-status="0" n-forks="0" result="success"/>
    <testcase path="/binding/chain">
Bug Reference:
      <status exit-status="0" n-forks="0" result="success"/>
    <testcase path="/binding/unbind">
GLib-GObject-MESSAGE: Random message on stdout
      <status exit-status="0" n-forks="0" result="success"/>
    <testcase path="/binding/fail">
      <error>GLib-GObject-FATAL-WARNING: gbinding.c:273: Unable to convert a value of type gdouble to a value of type gboolean</error>
      <status exit-status="-256" n-forks="0" result="failed"/>
  <testbinary path="binding">
    <binary file="/home/shared/gnome/src/glib/gobject/tests/.libs/lt-binding"/>
    <testcase path="/binding/default" skipped="1"/>
    <testcase path="/binding/bidirectional" skipped="1"/>
    <testcase path="/binding/transform" skipped="1"/>
    <testcase path="/binding/transform-default" skipped="1"/>
    <testcase path="/binding/transform-closure" skipped="1"/>
    <testcase path="/binding/chain" skipped="1"/>
    <testcase path="/binding/sync-create" skipped="1"/>
    <testcase path="/binding/invert-boolean" skipped="1"/>
    <testcase path="/binding/same-object" skipped="1"/>
    <testcase path="/binding/unbind" skipped="1"/>
    <testcase path="/binding/fail" skipped="1"/>

Other report formats

Once you have a results report in the XML format, you can convert it to HTML using the gtester-report tool.

Tyler Croy has written an XSLT transformation to convert GLib's XML reports into the more common JUnit test results format.

Projects/GLib/GTester (last edited 2015-12-11 16:19:41 by SamThursfield)