Skip to content
프로젝트

소개

성능과 직관적인 API의 완벽한 균형을 이루는 목 라이브러리

개발 도구

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
-1
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

Imposter logo

Mocking library with the perfect balance of Performance and Intuitive API

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.

관련 프로젝트 살펴보기

불러오는 중…