Mockolate 3.2.0

Prefix Reserved
dotnet add package Mockolate --version 3.2.0
                    
NuGet\Install-Package Mockolate -Version 3.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Mockolate" Version="3.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Mockolate" Version="3.2.0" />
                    
Directory.Packages.props
<PackageReference Include="Mockolate" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Mockolate --version 3.2.0
                    
#r "nuget: Mockolate, 3.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Mockolate@3.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Mockolate&version=3.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Mockolate&version=3.2.0
                    
Install as a Cake Tool

Mockolate

Changelog Nuget Coverage Mutation testing badge

Mockolate logo

Mockolate is a modern, strongly-typed, AOT-compatible mocking library for .NET, powered by source generators. It enables fast, compile-time validated mocking with .NET Standard 2.0, .NET 8, .NET 10 and .NET Framework 4.8.

  • Source generator-based: No runtime proxy generation.
  • Fast: Direct dispatch with no reflection or dynamic proxies.
  • Strongly-typed: Compile-time safety and IntelliSense support.
  • AOT compatible: Works with Native AOT and trimming.
  • Modern C#: First-class support for ref structs, static interface members, and current language features.

Why Mockolate

Reflection-based mocks (Moq, NSubstitute, …) Mockolate
AOT / trimming not supported supported
Validation runtime exceptions analyzers + compile errors
Setup API Expression<Func<…>> trees regular method calls
Hot path dynamic-proxy dispatch direct dispatch

For side-by-side setup, usage, and verification syntax against Moq, NSubstitute, and FakeItEasy, see the full code comparison; for performance, see the benchmarks.

Already on Moq or NSubstitute? The companion package Mockolate.Migration ships analyzers and code fixers that translate common Moq and NSubstitute patterns to Mockolate syntax in-place: point it at an existing test project and apply the suggested fixes.

Installation

Install the .NET 10 SDK. Mockolate leverages C# 14 extension members (the projects can still target any supported framework). Then add the package:

dotnet add package Mockolate

Quick Start

using Mockolate;

public interface IChocolateDispenser
{
    bool Dispense(string type, int amount);
}

// Create a mock
IChocolateDispenser sut = IChocolateDispenser.CreateMock();

// Setup: Dispense returns true for any Dark chocolate request
sut.Mock.Setup.Dispense("Dark", It.IsAny<int>()).Returns(true);

// Act
bool success = sut.Dispense("Dark", 4);

// Verify
sut.Mock.Verify.Dispense("Dark", It.IsAny<int>()).Once();

Documentation

Full reference docs at docs.testably.org/Mockolate:

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Mockolate:

Package Downloads
aweXpect.Mockolate

Expectations to verify interactions with mocks from Mockolate.

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on Mockolate:

Repository Stars
thomhurst/TUnit
A modern, fast and flexible .NET testing framework
TestableIO/System.IO.Abstractions
Just like System.Web.Abstractions, but for System.IO. Yay for testable IO access!
Version Downloads Last Updated
3.2.0 60 5/11/2026
3.1.0 1,120 5/2/2026
3.1.0-pre.1 43 5/1/2026
3.0.0 1,087 4/30/2026
3.0.0-pre.6 47 4/30/2026
3.0.0-pre.5 47 4/29/2026
3.0.0-pre.4 57 4/27/2026
3.0.0-pre.3 68 4/26/2026
3.0.0-pre.2 517 4/26/2026
3.0.0-pre.1 70 4/22/2026
2.5.0-pre.5 56 4/20/2026
2.5.0-pre.4 54 4/19/2026
2.5.0-pre.3 54 4/19/2026
2.5.0-pre.2 48 4/18/2026
2.5.0-pre.1 44 4/18/2026
2.4.0 4,286 4/7/2026
2.3.0 860 4/4/2026
2.2.0 496 4/3/2026
2.2.0-pre.2 92 4/3/2026
2.2.0-pre.1 82 4/2/2026
Loading failed