GTestDBus – test your DBus app

Recently, I’ve been working on making GDBus’ unit test helpers as public API on libgio (see bug #672985). Thanks to the help from David Zeuthen, it landed in gio master as GTestDBus object.

The basic idea is simple: g_test_dbus_up() starts a dbus-daemon and sets DBUS_SESSION_BUS_ADDRESS env variable. That means that your tests will then be using that private session bus instead of messing with user’s. When the unit test is done, call g_test_dbus_down() which will kill the dbus-daemon. Of course in the case you unit test fails and crash, it still make sure the dbus-daemon will be cleaned.

And finally, thanks to Alexander Larsson, it even works on win32.

Enjoy :D

Comments are closed.