Unit testing with mock objects in C


The article Jakub Hrozek and I wrote for Linux Weekly News (LWN.net) about CMocka and using mock objects is available to the public now. You can find it here: Unit testing with mock objects in C cmocka is a unit testing framework for C with support for mock objects. It is used by several Free Software projects like libssh, csync, SSSD or Elasto Cloud. If you don't have a LWN.net subscription you should consider getting one ;)

cmocka – a unit testing framework for C


I'm a big fan of unit testing frameworks. When I developed csync, a bidirectional file synchronizer, I used check to write unit tests from the start. check was ok, but it were running valgrind on your testcases to find memleaks in your code the mode reports were about check. So I needed to add valgrind suppressions to get rid of them. When I started to work on libssh, a library implementing the SSH protocol, I wrote unit tests with check too. libssh is multi platform and also works on Windows and with Visual Studio. So we needed a new unit testing framework which is platform independent and has better code quality. I stumbled upon cmockery, a unit testing framework from…