Skip to content

A collection of practical examples demonstrating how to use Typemock Isolator++ for C++ to isolate and test hard-to-mock code like global functions, constructors, inline methods, and legacy code without refactoring.

Notifications You must be signed in to change notification settings

Typemock/Typemock-IsolatorPP-Examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Typemock Isolator++ For C/C++ Examples

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.

πŸš€ About Typemock Isolator++

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:

image

🐧 Linux (GCC / WSL / Ubuntu / Centos)

βœ… 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

image

About

A collection of practical examples demonstrating how to use Typemock Isolator++ for C++ to isolate and test hard-to-mock code like global functions, constructors, inline methods, and legacy code without refactoring.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages