Writing a unit test with cmocka
Andreas Schneider
asn at samba.org
Thu May 4 14:54:55 UTC 2017
Hello Samba-Developers,
if possible and practical please write unit tests to test code. If you're
looking for an example you can find it at:
testsuite/unittests/test_krb5_samba.c
The API of cmocka is documented here: http://api.cmocka.org/
Some best practices:
* Unit test executable should be small (the opposite of smbtorture)
* If you write tests for a specific code include the .c file so you can write
tests for static functions too!
cmocka has support for mock objects. There is an LWN article explaining cmocka
and mocking here:
https://lwn.net/Articles/558106/
I will plan to write another example soon which can be compiled and played
around.
If you have questions please contact me.
Andreas
More information about the samba-technical
mailing list