Welcome to the official example repository for Typemock Isolator++, the most advanced mocking framework for C/C++.
This repository contains real-world and minimal examples that demonstrate how to write unit tests for hard-to-test C++ code, including global functions, constructors, legacy code, and inline and virtual methods, using Typemockβs native C++ engine.
Typemock Isolator++ is a powerful mocking framework for C++ that enables complete isolation and mocking of any function, including those traditionally considered unmockable.
It allows you to:
- Mock global and static functions
- Control constructor behavior
- Intercept inline and virtual methods
- Test legacy code without modifying it
- Mock code in static libraries and external binaries
π Learn more in the online documentation
π Folder Structure
βββ Isolator++.Examples.VS2022/ # Visual Studio and MSVC-based examples
βββ Isolator++.Examples.GCC/ # GCC-based examples for WSL or native Linux
βββ Common/ # Source files
βββ ClassesUnderTest/ # Classes Under Test
βββ GoogleTest/ # GTest Testing Framework Test Files
βββ MSTest/ # MsTest Testing Framework Test Files
βββ gtest_files/ # Pre Compiled GTest Libs & Headers
π§ͺ Running Tests
πͺ Windows (Visual Studio / MSVC)
β Step 1: Install Typemock Isolator++
Download the installer:
π Download Isolator++
π Installation Guide
β Step 2: Clone the Repository
git clone https://github.com/typemock/Typemock-IsolatorPP-Examples.git
cd Typemock-IsolatorPP-Examples
β Step 3: Open and Run Tests in Visual Studio
Open Isolator++.Examples.VS2022\Isolator++.Examples.VS2022.sln
Build the solution.
Run the tests using Test Explorer:
β Step 1: Install Typemock Isolator++ for Linux
π Download Isolator++
π Installation Guide
Install the .deb or .rpm package, depending on your system.
β Step 2: Clone the Repository
git clone https://github.com/typemock/Typemock-IsolatorPP-Examples.git
cd Typemock-IsolatorPP-Examples/Examples/Linux/filesystem_example
β Step 3: Build and Run Tests Go to Isolator++.Examples.GCC.
Build the project: Run
make
π Running on Linux
Go to LinuxBuild/Debug64 (by default): Run
export LD_BIND_NOW=1
./IsolatorExamplesGCC_UsingDynamicLib