AutoFixture alternatives and similar packages
Based on the "Testing" category.
Alternatively, view AutoFixture alternatives based on common mentions on social networks and blogs.
-
Bogus
:card_index: A simple fake data generator for C#, F#, and VB.NET. Based on and ported from the famed faker.js. -
Fluent Assertions
A very extensive set of extension methods that allow you to more naturally specify the expected outcome of a TDD or BDD-style unit tests. Targets .NET Framework 4.7, as well as .NET Core 2.1, .NET Core 3.0, .NET 6, .NET Standard 2.0 and 2.1. Supports the unit test frameworks MSTest2, NUnit3, XUnit2, MSpec, and NSpec3. -
Testcontainers
A library to support tests with throwaway instances of Docker containers for all compatible .NET Standard versions. -
Verify
Verify is a snapshot testing tool that simplifies the assertion of complex data models and documents. -
NBomber
Distributed load-testing framework for .NET. Create distributed load test scenarios entirely using plain C# or F#. It is designed to test any system regardless of the protocol or a semantic model (Pull/Push). -
WireMock.Net
WireMock.Net is a flexible product for stubbing and mocking web HTTP responses using advanced request matching and response templating. Based on the functionality from http://WireMock.org, but extended with more functionality. -
Compare-Net-Objects
What you have been waiting for :+1: Perform a deep compare of any two .NET objects using reflection. Shows the differences between the two objects. -
MSTest
This repository holds the source code of Microsoft.Testing.Platform (MTP), a lightweight alternative to VSTest, as well as MSTest adapter and framework. -
Machine.Specifications
Machine.Specifications is a Context/Specification framework for .NET that removes language noise and simplifies tests. -
ArchUnitNET
A C# architecture test library to specify and assert architecture rules in C# for automated testing. -
GenFu
GenFu is a library you can use to generate realistic test data. It is composed of several property fillers that can populate commonly named properties through reflection using an internal database of values or randomly created data. You can override any of the fillers, give GenFu hints on how to fill them. -
Expecto
A smooth testing lib for F#. APIs made for humans! Strong testing methodologies for everyone! -
NBuilder
DISCONTINUED. Rapid generation of test objects in .NET [Moved to: https://github.com/nbuilder/nbuilder] -
Fine Code Coverage
Visualize unit test code coverage easily for free in Visual Studio Community Edition (and other editions too) -
NFluent
Smooth your .NET TDD experience with NFluent! NFluent is an ergonomic assertion library which aims to fluent your .NET TDD experience (based on simple Check.That() assertion statements). NFluent aims your tests to be fluent to write (with a super-duper-happy 'dot' auto-completion experience), fluent to read (i.e. as close as possible to plain English expression), but also fluent to troubleshoot, in a less-error-prone way comparing to the classical .NET test frameworks. NFluent is also directly inspired by the awesome Java FEST Fluent assertion/reflection library (http://fest.easytesting.org/) -
xBehave.net
DISCONTINUED. ✖ An xUnit.net extension for describing each step in a test with natural language. -
SpecsFor
SpecsFor is a light-weight Behavior-Driven Development framework that focuses on ease of use for *developers* by minimizing testing friction. -
Xunit.Gherkin.Quick
BDD in .NET Core - using Xunit and Gherkin (compatible with both .NET Core and .NET) -
Moq.Contrib.HttpClient
A set of extension methods for mocking HttpClient and IHttpClientFactory with Moq. -
SimpleStubs
DISCONTINUED. *SimpleStubs* is a simple mocking framework that supports Universal Windows Platform (UWP), .NET Core and .NET framework. SimpleStubs is currently developed and maintained by Microsoft BigPark Studios in Vancouver. -
#<Sawyer::Resource:0x00007f89811b9240>
:fire: A small library to help .NET developers leverage Microsoft's dependency injection framework in their Xunit-powered test projects -
SecTester
SecTester is a new tool that integrates our enterprise-grade scan engine directly into your unit tests. -
SpecFlow
DISCONTINUED. #1 .NET BDD Framework. SpecFlow automates your testing & works with your existing code. Find Bugs before they happen. Behavior Driven Development helps developers, testers, and business representatives to get a better understanding of their collaboration
InfluxDB high-performance time series database

* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of AutoFixture or a related project?
README
AutoFixture
Project Description
Write maintainable unit tests, faster.
AutoFixture makes it easier for developers to do Test-Driven Development by automating non-relevant Test Fixture Setup, allowing the Test Developer to focus on the essentials of each test case.
Overview
(Jump straight to the CheatSheet if you just want to see some code samples right away.)
AutoFixture is designed to make Test-Driven Development more productive and unit tests more refactoring-safe. It does so by removing the need for hand-coding anonymous variables as part of a test's Fixture Setup phase. Among other features, it offers a generic implementation of the Test Data Builder pattern.
When writing unit tests, you typically need to create some objects that represent the initial state of the test. Often, an API will force you to specify much more data than you really care about, so you frequently end up creating objects that has no influence on the test, simply to make the code compile.
AutoFixture can help by creating such Anonymous Variables for you. Here's a simple example:
[Fact]
public void IntroductoryTest()
{
// Arrange
Fixture fixture = new Fixture();
int expectedNumber = fixture.Create<int>();
MyClass sut = fixture.Create<MyClass>();
// Act
int result = sut.Echo(expectedNumber);
// Assert
Assert.Equal(expectedNumber, result);
}
This example illustrates the basic principle of AutoFixture: It can create values of virtually any type without the need for you to explicitly define which values should be used. The number expectedNumber is created by a call to Create<T>
- this will create a 'nice', regular integer value, saving you the effort of explicitly coming up with one.
The example also illustrates how AutoFixture can be used as a SUT Factory that creates the actual System Under Test (the MyClass instance).
Given the right combination of unit testing framework and extensions for AutoFixture, we can further reduce the above test to be even more declarative:
xUnit
[Theory, AutoData]
public void IntroductoryTest(
int expectedNumber, MyClass sut)
{
int result = sut.Echo(expectedNumber);
Assert.Equal(expectedNumber, result);
}
and
NUnit
[Test, AutoData]
public void IntroductoryTest(
int expectedNumber, MyClass sut)
{
int result = sut.Echo(expectedNumber);
Assert.Equal(expectedNumber, result);
}
Notice how we can reduce unit tests to state only the relevant parts of the test. The rest (variables, Fixture object) is relegated to attributes and parameter values that are supplied automatically by AutoFixture. The test is now only two lines of code.
Using AutoFixture is as easy as referencing the library and creating a new instance of the Fixture class!
.NET platforms compatibility table
Product | .NET Framework | .NET Standard |
---|---|---|
AutoFixture | :heavy_check_mark: 4.5.2 | :heavy_check_mark: 1.5, 2.0 |
AutoFixture.SeedExtensions | :heavy_check_mark: 4.5.2 | :heavy_check_mark: 1.5, 2.0 |
AutoFixture.xUnit | :heavy_check_mark: 4.5.2 | :heavy_minus_sign: |
AutoFixture.xUnit2 | :heavy_check_mark: 4.5.2 | :heavy_check_mark: 1.5, 2.0 |
AutoFixture.NUnit2 | :heavy_check_mark: 4.5.2 | :heavy_minus_sign: |
AutoFixture.NUnit3 | :heavy_check_mark: 4.5.2 | :heavy_check_mark: 1.5, 2.0 |
AutoFakeItEasy | :heavy_check_mark: 4.5.2 | :heavy_check_mark: 1.6, 2.0 |
AutoFoq | :heavy_check_mark: 4.5.2 | :heavy_check_mark: 2.0 |
AutoMoq | :heavy_check_mark: 4.5.2 | :heavy_check_mark: 1.5, 2.0 |
AutoNSubstitute | :heavy_check_mark: 4.5.2 | :heavy_check_mark: 1.5, 2.0 |
AutoRhinoMock | :heavy_check_mark: 4.5.2 | :heavy_minus_sign: |
Idioms | :heavy_check_mark: 4.5.2 | :heavy_check_mark: 2.0 |
Idioms.FsCheck | :heavy_check_mark: 4.5.2 | :heavy_check_mark: 2.0 |
Downloads
AutoFixture is available via NuGet:
- AutoFixture
- AutoFixture.SeedExtensions
- AutoFixture.AutoMoq
- AutoFixture.AutoRhinoMocks
- AutoFixture.AutoFakeItEasy
- AutoFixture.AutoNSubstitute
- AutoFixture.AutoFoq
- AutoFixture.Xunit
- AutoFixture.Xunit2
- AutoFixture.NUnit2
- AutoFixture.NUnit3
- AutoFixture.Idioms
vNext feed
The artifacts of the next major version are published to the MyGet feed:
https://www.myget.org/F/autofixture/api/v3/index.json
(Visual Studio 2015+)https://www.myget.org/F/autofixture/api/v2
(Visual Studio 2012+)
You can use this feed to early access and test the next major version of the AutoFixture.
Notice, this feed exists for the preview purpose only, so use it with caution:
- new versions of packages might contain breaking changes and API could change drastically from package to package. By other words, we don't follow the SemVer policy for the packages in this feed;
- packages might be cleaned up over time (MyGet has storage limits), so don't consider this feed for the permanent usage (or at least ensure to make a copy of the used packages somewhere else).
Versioning
AutoFixture follows Semantic Versioning 2.0.0 for the public releases (published to the nuget.org).
Build
AutoFixture uses FAKE as a build engine. If you would like to build the AutoFixture locally, run the build.cmd
file and wait for the result.
The repository state (the last tag name and number of commits since the last tag) is used to determine the build version. If you would like to override the auto-generated AutoFixture version, set the BUILD_VERSION
environment variable before calling the build.cmd
file. Example for PowerShell:
$env:BUILD_VERSION='3.52.0'; .\build.cmd
Refer to the [Build.fsx](Build.fsx) file to get information about all the supported build keys.
Documentation
Questions
If you have questions, feel free to ask. The best places to ask are:
Who uses AutoFixture
AutoFixture is used around the world, as the following quotes testify:
"I’ve introduced AutoFixture to my developers (at www.gab.de ) some time ago. We’ve been using it successfully with xUnit in multiple projects all across the .NET technology stack. We also use it for feeding dummy data to the UI when developing prototypes. That saved us quite some time.
-Florian Hötzinger, GAB Enterprise IT Solutions GmbH
"I have used AutoFixture for 3 years, it's a vital tool in my TDD toolbox, a real time-saver. Setting up maintainable and robust unit tests with AutoFixture is easy and straightforward - highly recommendable"
-Mads Tjørnelund Toustrup, Senior .Net Developer, d60 a/s
"Autofixture is more than just another test data generator. It helps me to write tests faster, which are robust against changes in my production code. Moreover, with Autofixture I can focus the tests on the behavior I want to check which why they are easier to read and understand."
If you want to add your own testimonial to this list, we (the AutoFixture maintainers) would be very grateful. Send us a pull request to this README.md file.