Soenneker.Fixtures.Unit 11.0.829

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

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

Soenneker.Fixtures.Unit

An extensible xUnit fixture that creates a dependency-injection container, configures injectable Serilog test output, and provides shared Bogus generators.

Install

dotnet add package Soenneker.Fixtures.Unit

Usage

Create a fixture and register its services in the constructor. xUnit calls InitializeAsync after construction, which builds the provider from those registrations.

using Microsoft.Extensions.DependencyInjection;
using Soenneker.Fixtures.Unit;

public sealed class TestFixture : UnitFixture
{
    public TestFixture()
    {
        Services.AddSingleton<IClock, TestClock>();
        Services.AddTransient<OrderService>();
    }
}

Share the fixture through an xUnit collection:

using Microsoft.Extensions.DependencyInjection;
using Xunit;

[CollectionDefinition("unit")]
public sealed class UnitCollection : ICollectionFixture<TestFixture>;

[Collection("unit")]
public sealed class OrderServiceTests
{
    private readonly TestFixture _fixture;

    public OrderServiceTests(TestFixture fixture) => _fixture = fixture;

    [Fact]
    public void Creates_an_order()
    {
        OrderService service = _fixture.ServiceProvider!
                                               .GetRequiredService<OrderService>();

        string customerName = _fixture.Faker.Name.FullName();
        Order request = _fixture.AutoFaker.Generate<Order>();

        // exercise service
    }
}

The fixture also registers its IInjectableTestOutputSink. Inject the current ITestOutputHelper into that singleton when a test class is constructed if logs should appear in that test's output:

using Serilog.Sinks.XUnit.Injectable.Abstract;
using Xunit;

IInjectableTestOutputSink sink = fixture.ServiceProvider!
                                            .GetRequiredService<IInjectableTestOutputSink>();
sink.Inject(testOutputHelper);

Lifecycle and behavior

  • Add or replace registrations before InitializeAsync runs. Changing Services after the provider is built does not update ServiceProvider.
  • Faker is the Bogus generator owned by AutoFaker; use either property depending on whether a value or an entire object graph is needed.
  • The fixture owns the provider and injectable sink and disposes both during xUnit fixture teardown. Consumers should still dispose any scopes they create.
  • Construction assigns the process-wide Serilog.Log.Logger, and teardown flushes it. Use one shared fixture for a test collection or assembly; multiple fixture instances running in parallel can replace each other's global logger and route output to the wrong test.
Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Soenneker.Fixtures.Unit:

Package Downloads
Soenneker.Tests.FixturedUnit

A fundamental xUnit test that stores UnitFixture and provides synthetic inversion of control

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.829 123 11/19/2026
11.0.828 116 11/18/2026
11.0.826 106 11/18/2026
11.0.825 93 11/18/2026
11.0.824 113 11/18/2026
11.0.823 202 11/11/2026
11.0.822 114 11/11/2026
11.0.821 111 11/11/2026
11.0.820 115 11/11/2026
11.0.819 103 11/11/2026
11.0.818 129 11/11/2026
11.0.817 96 11/11/2026
11.0.816 121 11/11/2026
11.0.814 132 11/9/2026
11.0.813 184 11/3/2026
11.0.812 87 11/3/2026
11.0.811 82 11/3/2026
11.0.810 175 10/27/2026
11.0.809 90 10/26/2026
11.0.808 82 10/26/2026
Loading failed

Updated Serilog.Sinks.XUnit.Injectable to 11.0.308