Writing cmocka Tests: Difference between revisions

From SambaWiki
(Big bang!)
 
m (Abartlet moved page Writing cmocka tests to Writing cmocka Tests: follow pattern of other writing tests articles (capitalisation))
 
(No difference)

Latest revision as of 21:12, 2 August 2017

Unit Testing

Samba started to also implement unit tests. This gives an overview about cmocka the unit testing framework we use. As a start we suggest to read the following LWN article:

Unit testing with mock objects in C

cmocka its API is very well documented, you can find it here.

Best practice

Normally you can take it as a rule of thumb to write one text executable for one .c file! In the test you do #include "foo.c". This way you can also write tests for functions which are declared static.

If you have a huge file or complex functions, create one test binary for a bunch of similar functions or just one.

Writing a cmocka test for Samba

What a wurst!