Imposter 1.0.3

dotnet add package Imposter --version 1.0.3
                    
NuGet\Install-Package Imposter -Version 1.0.3
                    
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="Imposter" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Imposter" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="Imposter" />
                    
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 Imposter --version 1.0.3
                    
#r "nuget: Imposter, 1.0.3"
                    
#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 Imposter@1.0.3
                    
#: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=Imposter&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=Imposter&version=1.0.3
                    
Install as a Cake Tool

<p align="center"> <img src="docs/imposter_logo.png" alt="Imposter logo" width="140" /> </p>

<p align="center"> Mocking library with the perfect balance of Performance and Intuitive API </p>

Build, Test, and Format verification CodeQL OpenSSF Scorecard Nuget

🧘Balanced Performance and Developer Experience

Imposter delivers top-tier performance without sacrificing a natural, intuitive API. While being ~10Γ— faster than NSubstitute and up to ~50Γ— faster than Moq in common mocking scenarios, Imposter is not the fastest mocking library available. Instead, it focuses on achieving a balance between performance and API ease of use.

πŸš€ Quick Start

Add nuget package reference:

dotnet add package Imposter

Pick a target


namespace Application.Domain;

public interface ICalculator
{
    int Add(int a, int b);
}

Use [GenerateImposter] attribute in your tests project, this will generate an imposter

[assembly: GenerateImposter(typeof(Application.Domain.ICalculator))]

Use the generated imposter

using System.Threading.Tasks;
using Imposter.Abstractions;

// c# 14
var imposter = ICalculator.Imposter();

// c# 9 - 13
// var imposter = new ICalculatorImposter();

imposter.Add(Arg<int>.Any(), Arg<int>.Any())
    .Returns(1)
    .Then()
    .Returns(2);

var calculator = imposter.Instance();

calculator.Add(1, 2); // 1
calculator.Add(1, 2); // 2

πŸ›‘οΈ Strongly typed all the way

Loosely typed callbacks can easily cause runtime exceptions. Imposter enforces strong typing across the entire mocking pipeline, eliminating type mismatch errors for good. See more here

🎭 Interfaces and classes

Not limited to interfaces β€” Imposter can impersonate non-sealed classes and their protected members. See more here

🧬 Full generic support

Generics are fully supported. see more here

🧩 Mock any member

Imposter supports not only methods, but also properties, events and indexers.

πŸ”€ Implicit and Explicit Modes

Choose how unmocked members behave. Implicit mode returns defaults silently β€” great for prototyping. Explicit mode throws on any call without a setup β€” ideal for unit tests that must be precise. See more here

🧡 Thread-safe by design

Imposter is built to work reliably in multi-threaded and parallel test environments.

⏱️ Benchmark

Each library sets up Square to return input * input and calls it, for 1, 10, 100 and 1,000 iterations. See benchmarks for the code.

public interface ICalculator
{
    int Square(int input);
}

Benchmark results for Moq, NSubstitute, FakeItEasy, Rocks and Imposter

The Benchmarks workflow reruns this comparison on a GitHub-hosted runner after every change to the code on master, so the table always shows the latest build. Shared runners are slower and noisier than a desktop machine: compare the libraries within the table rather than the absolute timings. The same results are available as Markdown.

✨ Feature-Rich

Docs

πŸ“œ MIT License

Free to use, modify, and distribute under the MIT License.

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 was computed.  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 was computed.  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

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Imposter:

Repository Stars
thomhurst/TUnit
A modern, fast and flexible .NET testing framework
Version Downloads Last Updated
1.0.3 312 10/20/2026
1.0.2 1,916 10/18/2026
1.0.1 1,863 10/15/2026
1.0.0 420 10/14/2026
0.2.27 208 10/14/2026
0.2.26 297 10/14/2026
0.2.25 181 10/14/2026
0.2.24 722 10/13/2026
0.2.23 982 10/12/2026
0.2.22 109 10/12/2026
0.2.21 234 10/12/2026
0.2.20 186 10/12/2026
0.2.19 216 10/12/2026
0.2.18 157 10/12/2026
0.2.17 201 10/11/2026
0.2.16 151 10/11/2026
0.2.15 142 10/11/2026
0.2.14 380 10/10/2026
0.2.13 101 10/10/2026
0.2.12 144 10/10/2026
Loading failed

Fixes

- An indexer getter setup is registered once under contention (#411, closes #398). Configuring the same getter builder from several threads at once could register a second, unconfigured setup alongside the configured one, and calls could reach it. Each getter builder now has exactly one setup.

Performance

- Count.Never(), Once(), Twice(), AtLeastOnce() and AtMostOnce() no longer allocate (#412, closes #400). Each returns one cached instance. Count is immutable and compares by value, so only reference equality between two calls changes.

Maintenance

- Tests that blocked thread-pool threads now run their workers on dedicated threads, so CI no longer fails intermittently on 2-core runners (#415, closes #414).
- GitHub Actions dependencies updated (#410).