Rocket.Surgery.Extensions.Testing.FakeItEasy
11.0.2
dotnet add package Rocket.Surgery.Extensions.Testing.FakeItEasy --version 11.0.2
NuGet\Install-Package Rocket.Surgery.Extensions.Testing.FakeItEasy -Version 11.0.2
<PackageReference Include="Rocket.Surgery.Extensions.Testing.FakeItEasy" Version="11.0.2" />
<PackageVersion Include="Rocket.Surgery.Extensions.Testing.FakeItEasy" Version="11.0.2" />
<PackageReference Include="Rocket.Surgery.Extensions.Testing.FakeItEasy" />
paket add Rocket.Surgery.Extensions.Testing.FakeItEasy --version 11.0.2
#r "nuget: Rocket.Surgery.Extensions.Testing.FakeItEasy, 11.0.2"
#:package Rocket.Surgery.Extensions.Testing.FakeItEasy@11.0.2
#addin nuget:?package=Rocket.Surgery.Extensions.Testing.FakeItEasy&version=11.0.2
#tool nuget:?package=Rocket.Surgery.Extensions.Testing.FakeItEasy&version=11.0.2
Rocket Surgery Testing
Test helpers for .NET: a test base class that sends Serilog output to your test framework and captures log events for assertions, auto-mocking containers for FakeItEasy and NSubstitute, test data builders, and a harness for testing Roslyn source generators, analyzers and code fixes. TUnit and xUnit v3 are supported.
Documentation: docs/src/content/docs
Getting started
Add the package for your test framework. It brings in Rocket.Surgery.Extensions.Testing:
# TUnit
dotnet add package Rocket.Surgery.Extensions.Testing.TUnit
# xUnit v3
dotnet add package Rocket.Surgery.Extensions.Testing.XUnit3
Derive the test class from LoggerTest<TContext>. Logger writes to the current test's output, and CaptureLogs
collects the events written until it is disposed:
using Serilog.Events;
using Rocket.Surgery.Extensions.Testing;
public class OrderServiceTests() : LoggerTest<TestRecord>(TestRecord.Create())
{
[Test]
public async Task Logs_a_warning_for_empty_orders()
{
using var capture = CaptureLogs(log => log.Level >= LogEventLevel.Warning, out var logs);
Logger.Information("not captured: below the filter");
Logger.Warning("order {OrderId} has no lines", 42);
await Assert.That(logs.Count()).IsEqualTo(1);
}
}
With Rocket.Surgery.Extensions.Testing.FakeItEasy, derive from AutoFakeTest<TContext> instead. AutoFake.Resolve<T>()
builds the class under test and fakes every dependency the container can't construct, returning the same fake each time
within a test:
using FakeItEasy;
using Rocket.Surgery.Extensions.Testing;
public class CheckoutTests() : AutoFakeTest<TestRecord>(TestRecord.Create())
{
[Test]
public async Task Charges_the_customer()
{
var payments = AutoFake.Resolve<IPaymentGateway>();
var checkout = AutoFake.Resolve<CheckoutService>();
await checkout.CompleteAsync(orderId: 42);
A.CallTo(() => payments.ChargeAsync(42, A<CancellationToken>._)).MustHaveHappenedOnceExactly();
}
}
See the quickstart, auto-mocking, fixtures and source generator testing pages.
Packages
| Package | NuGet | What it does |
|---|---|---|
| Rocket.Surgery.Extensions.Testing | LoggerTest<TContext>, which wires Serilog to the test output and captures log events, and the DryIoc helpers the mocking packages build on |
|
| Rocket.Surgery.Extensions.Testing.TUnit | TestRecord, the test context for TUnit |
|
| Rocket.Surgery.Extensions.Testing.XUnit3 | XUnitTestContext, the test context for xUnit v3 |
|
| Rocket.Surgery.Extensions.Testing.FakeItEasy | AutoFakeTest<TContext>: a DryIoc container that resolves the system under test and fakes missing dependencies with FakeItEasy |
|
| Rocket.Surgery.Extensions.Testing.NSubstitute | AutoSubstituteTest<TContext>: the same container with NSubstitute substitutes |
|
| Rocket.Surgery.Extensions.Testing.Fixtures | ITestFixtureBuilder and the With helpers for hand-written test data builders |
|
| Rocket.Surgery.Extensions.Testing.AutoFixtures | Source generator that writes a fixture builder from a constructor, marked with [AutoFixture] |
|
| Rocket.Surgery.Extensions.Testing.SourceGenerators | GeneratorTestContextBuilder: compiles sources, runs generators, analyzers, code fixes and refactorings, and snapshots the results with Verify |
Rocket.Surgery.Extensions.Testing.Analyzers comes in with Rocket.Surgery.Extensions.Testing, so you don't
reference it yourself. It ships no analyzer rules at present.
Contributing
Run mise install before building: it installs the .NET SDK and the extra .NET 10 runtime that the net10.0 tests run on (.config/mise.toml). global.json pins the same SDK, so a dotnet outside mise fails fast unless that SDK is installed.
On macOS, the first mise install of a new .NET SDK can overwrite the shared ~/.local/share/mise/dotnet-root/dotnet host in place, and macOS then kills every dotnet command (SIGKILL). Replace the host with a fresh copy to fix it:
cd ~/.local/share/mise/dotnet-root && cp -p dotnet dotnet.fresh && mv -f dotnet.fresh dotnet
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. net11.0 is compatible. |
-
net10.0
- FakeItEasy (>= 9.0.1)
- Rocket.Surgery.Extensions.Testing (>= 11.0.2)
- Verify.FakeItEasy (>= 2.1.0)
-
net11.0
- FakeItEasy (>= 9.0.1)
- Rocket.Surgery.Extensions.Testing (>= 11.0.2)
- Verify.FakeItEasy (>= 2.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.2 | 0 | 11/26/2026 |
| 11.0.1 | 1,785 | 10/28/2026 |
| 11.0.0 | 530 | 10/22/2026 |
| 11.0.0-beta.1 | 107 | 10/22/2026 |
| 10.0.6 | 2,870 | 7/4/2026 |
| 10.0.5 | 2,145 | 6/28/2026 |
| 10.0.4 | 165 | 6/28/2026 |
| 10.0.4-beta.1 | 95 | 6/28/2026 |
| 10.0.3 | 194 | 6/28/2026 |
| 10.0.3-beta.55 | 114 | 6/28/2026 |
| 10.0.3-beta.54 | 114 | 6/28/2026 |
| 10.0.3-beta.53 | 114 | 6/26/2026 |
| 10.0.3-beta.52 | 112 | 6/24/2026 |
| 10.0.2 | 13,796 | 5/16/2026 |
| 10.0.1 | 43,792 | 3/2/2026 |
| 10.0.0-beta.2 | 72,775 | 9/15/2025 |
| 10.0.0-beta.1 | 617 | 9/10/2025 |
| 9.0.5 | 243,143 | 2/25/2025 |
| 9.0.4 | 2,200 | 1/24/2025 |
| 9.0.3 | 4,005 | 12/17/2024 |