AutoFixture

Write tests. Skip the arrange noise.

AutoFixture creates anonymous test data for .NET so your unit tests stay focused on behavior, not boilerplate setup.

Keep tests expressive, flexible, and useful

AutoFixture fills object graphs and dependencies — you focus on behavior, not boilerplate setup.

C#
[Theory, ShippingData]
public void CreateLabel_ForExistingOrder_IncludesShippingDetails(
    [Frozen] Mock<ICommerceOrderRepository> repository,
    [Greedy][Frozen(Matching.ImplementedInterfaces)] ShippingRateCalculator calculator,
    ShippingLabelService sut,
    Order order)
{
    repository
        .Setup(r => r.GetById(order.Id))
        .Returns(order);

    var label = sut.CreateLabel(order.Id);

    Assert.Contains(order.ShippingAddress.Name, label);
    Assert.Contains(order.ShippingAddress.Country, label);
    Assert.Contains("Weight: 2.5 kg", label);
}

What you get

From quick one-off specimens to constrained graphs and framework integrations.

Anonymous test data
Create strings, numbers, and nested objects without hand-written arrange code.
Build DSL
Pin properties and satisfy business rules when Create is not enough.
Object graphs
Fill constructors and properties across nested types in one call.
Customizations
Register factories and customize composers for fixture-wide defaults.
Integrations
Works with xUnit.net 3, NUnit 4, Moq, NSubstitute, and FakeItEasy.
API reference
Browse generated docs for every public type across AutoFixture packages.

Ready to try it?

Install the package and follow the get-started path — or jump straight into the API reference.

Terminal
dotnet add package AutoFixture
.NET Foundation logo

AutoFixture is supported by the .NET Foundation