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"?>
<gtester>
  <testbinary path="binding">
    <binary file="/home/shared/gnome/src/glib/gobject/tests/.libs/lt-binding"/>
    <random-seed>R02S74e68fd98de232755beacd96cfe4f7af</random-seed>
    <testcase path="/binding/transform-closure">
      <duration>0.000163</duration>
      <status exit-status="0" n-forks="0" result="success"/>
    </testcase>
    <testcase path="/binding/chain">
      <message>
Bug Reference: http://bugzilla.gnome.org/621782
      </message>
      <duration>0.000213</duration>
      <status exit-status="0" n-forks="0" result="success"/>
    </testcase>
    <testcase path="/binding/unbind">
      <message>
GLib-GObject-MESSAGE: Random message on stdout
      </message>
      <duration>0.000314</duration>
      <status exit-status="0" n-forks="0" result="success"/>
    </testcase>
    <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>
      <duration>0.000000</duration>
      <status exit-status="-256" n-forks="0" result="failed"/>
    </testcase>
    <duration>0.104294</duration>
  </testbinary>
  <testbinary path="binding">
    <binary file="/home/shared/gnome/src/glib/gobject/tests/.libs/lt-binding"/>
    <random-seed>R02S9d7da7d56b7a76471f2972b1df73a109</random-seed>
    <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"/>
    <duration>0.016317</duration>
  </testbinary>
</gtester>

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)