MOCK

Generates a default mock.

Syntax:
MOCK(name)
Parameters:
name
The name of the function that is mocked
Returns:
-

The MOCK macro will generate a mock function called name. The mock function replaces and simulates functions, that are called by the unit but not available during the test. It reports to the framework, whenever a function call to name is detected. This allows the framework to validate, that the parameters are correct, and that the function call occurs at the right time.

The prototype for a mock function can be a function prototype of any kind. The MOCK macro will generate functions taking no parameters and returning nothing, e.g. void name(void). The function it replaces will most likely have another prototype, but the differences are not important to the test.

The instrumenter will normally generate default mock functions for you, but this macro is available, if you are not using the instrumenter.

This macro cannot be used together with earlier prototype declarations of name. If you experience compilation problems due to this, there are two solutions - either use the correct prototype (for the test it does not matter), or use the MOCK macro from within a file, that does not include the real function declaration.

testape

News

The latest headlines from Testape.com

TestApe Release 880 available, Dec 3rd 2011

New is this release are support for floating point validations and function mocking. Also, MinGW has been added to the list of supported platforms.

more

Forum change, Mar 27th 2011

TestApe forum is now hosted on Proboards. Support questions can be posted here or send directly on email. Due to ...

more

TestApe beta release available, Sep 27th 2011

TestApe can now be used with MinGW GCC on windows. Also supported in this beta are floating point types in validations or when mocking functions

more

IPad update for WebTTY, May 15th 2011

A small fix for webtty scripts, to allow the usage from Apple IPads. Tab on textarea to bring up IPad keyboard - you may have to scroll webpage beneath keyboard, in order to actually see what you're typing.

TestApe Release 791 available, Apr 2nd 2010

This release contains a new flexible mocking system with default mocks automatically generated for unresolved functions. Installation packages are available for GCC/Linux, GCC/CygWin as well Visual Studio 2009/Windows XP or Vista.

more

TestApe beta version available, Jan 26th 2010

New beta version is now available for download. This is the last beta before official release. The release supports an extensive mocking system.

more

Forum change, Mar 10th 2009

There is a change for the forum hosted on this site. The previous phpBB forum is closed for now. All forum threads will be migrated to a new simple blog. ...

more