Exposing Methods |
Top Previous Next |
There are cases where the linker does not include certain types of methods or duplicates them in each DLL that uses them causing to fake wrong methods. The following sections explain how to address these issues for each type.
For globals:
In C++, the linker may omit or duplicate global functions across different DLLs. To fix this, use the a.Testable.GlobalFunction API. Refer to the Faking Global Methods page for more information.
For members:
The linker may sometimes omit private and virtual members of a class. To fake them, either call them (can use a.CallTo) or use the a.Testable.Members API. Refer to the faking abstract classes pages for more information.
For private statics:
To expose private static methods, use the ISOLATOR_TESTABLE macro in your production code. An example definition is provided in the ExposeMacro.h header file, included with the Isolator++ installation (located in the examples directory within the Documents folder). You can copy this file into your production code and #include it to use the macro.
#include "ExposeMacro.h" // Include the header where ISOLATOR_TESTABLE is defined
class MyClass { private: // Mark the private static method as testable ISOLATOR_TESTABLE static int SecretCalculation(int x); };
The SecretCalculation method is now testable. |
Copyright Typemock Ltd. 2009-2025. All Rights Reserved.