[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cmocka mocking capability in windows is missing


Can you provide a little more information about what you are trying to mock (example functions and the files)?

There are several choices for substituting a test-double for your production code, there are also limitations because of C and linker capabilities. Linker wrapping has its limitations as well (like not available except in gcc AFIK).

I recommend against giving your production code knowing that it is being tested, unless there is no other way. You could accomplish > #ifdef UNIT_TESTING
#define strdup test_strdup
#endif

with a command line definition in your test build.

James


On 28 Jul 2015, at 9:56, Andreas Schneider wrote:

On Tuesday 28 July 2015 14:44:45 Shai Peretz wrote:
2.
I notice that on windows I can't use the __wrap_ functionality which is
important feature for the mocking capability,
What do I do in Windows?
the '-Wl,--wrap=...' linker options exists only in GNU Linker.
Is this true?
If it is then this means that i can't really use cmocka mocking
capabilities in windows, is that correct? i can't mock some function being
called by another module which I interact with.

If you want to mock strdup e.g you need to use:

#ifdef UNIT_TESTING
#define strdup test_strdup
#endif

In your code ...

--------------------------------------------------------------------------
James Grenning - Author of TDD for Embedded C - wingman-sw.com/tddec
wingman-sw.com
wingman-sw.com/blog
twitter.com/jwgrenning
facebook.com/wingman.sw
[![wingman software](http://www.wingman-sw.com/images/wingman.png)](http://wingman-sw.com)


References:
cmocka mocking capability in windows is missingShai Peretz <ssperetz@xxxxxxxxx>
Re: cmocka mocking capability in windows is missingAndreas Schneider <asn@xxxxxxxxxxxxxx>