# nsubstitute/NSubstitute

A friendly substitute for .NET mocking libraries.

Repository: https://github.com/nsubstitute/NSubstitute
Canonical: https://ross.abutalabs.com/products/nsubstitute
Homepage: https://nsubstitute.github.io
Language: C#
License: NOASSERTION
License Family: other
Topics: c-sharp, dotnet, dot-net, testing, testing-tools, test, mocking, mock, dotnet-core, dotnetcore, mocks, stubs
Last push: 2026-08-24T20:30:19+00:00

## Health v2 (maintenance only)
Score: 98/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 99, release rhythm 97, longevity 100
- inputs: {"age_days": 6158, "days_push": 9, "days_rel": 22, "gap_med": 27, "n_releases_24m": 4}
- flags: no_license
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 2972, forks 282 (observed 2026-08-28T04:07:32.815643+00:00)

## What it is
NSubstitute is a mocking library for .NET that generates substitute instances for interfaces and virtual members with a succinct, natural syntax. It focuses on Arrange-Act-Assert testing, letting developers set return values, check received calls, and raise events with minimal configuration noise.

## Use cases
- mock dependencies in .NET unit tests
- create stubs for interfaces in C# tests
- verify a method was called with specific arguments
- set return values for test doubles
- raise events on mocked objects in tests
- learn test-driven development with an easy mocking library

## When to choose
- you want a simple, readable mocking API with less boilerplate than Moq or Rhino Mocks
- your tests follow the Arrange-Act-Assert pattern
- you are new to unit testing and want a low-friction mocking library
- you only need to mock interfaces or virtual members

## When to avoid
- you need to mock non-virtual members or static methods
- you require advanced features like partial mocking of complex class internals
- your project is not on the .NET platform

## Facets
- artifact type: library
- maturity: stable
- function: testing, mocking
- domain: testing, developer-tools
- platform: dotnet
- tags: test-doubles, stubs, fakes, arrange-act-assert, c-sharp, nuget

## Member repositories
- nsubstitute/NSubstitute (main) score 98

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:07:32.815643+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T07:31:38.310948+00:00, confidence not recorded.
  - readme: https://github.com/nsubstitute/NSubstitute (fetched 2026-08-28T04:07:32.815643+00:00, sha d9edae7643c3)
  - homepage: https://nsubstitute.github.io (fetched 2026-08-29T09:46:52.755657+00:00, sha 7f9c77b95f1b)
- Data as of 2026-08-30T08:39:29.467469+00:00.
