VOOZH about

URL: https://www.nuget.org/packages/AutoFixture.NUnit4

⇱ NuGet Gallery | AutoFixture.NUnit4 4.19.0




👁 Image
AutoFixture.NUnit4 4.19.0

Prefix Reserved
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package AutoFixture.NUnit4 --version 4.19.0
 
 
NuGet\Install-Package AutoFixture.NUnit4 -Version 4.19.0
 
 
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="AutoFixture.NUnit4" Version="4.19.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AutoFixture.NUnit4" Version="4.19.0" />
 
Directory.Packages.props
<PackageReference Include="AutoFixture.NUnit4" />
 
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 AutoFixture.NUnit4 --version 4.19.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: AutoFixture.NUnit4, 4.19.0"
 
 
#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 AutoFixture.NUnit4@4.19.0
 
 
#: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=AutoFixture.NUnit4&version=4.19.0
 
Install as a Cake Addin
#tool nuget:?package=AutoFixture.NUnit4&version=4.19.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

AutoFixture.NUnit4

👁 License
👁 NuGet version
👁 NuGet preview version
👁 NuGet downloads

AutoFixture.NUnit4 is a .NET library that integrates AutoFixture with NUnit 4.x, allowing you to effortlessly generate test data for your unit tests. By automatically populating your test parameters, it helps you write cleaner, more maintainable tests without having to manually construct test objects.

Table of Contents

Installation

AutoFixture packages are distributed via NuGet.<br /> To install the packages you can use the integrated package manager of your IDE, the .NET CLI, or reference the package directly in your project file.

dotnet add package AutoFixture.NUnit4 --version x.x.x
<PackageReference Include="AutoFixture.NUnit4" Version="x.x.x" />

Getting Started

Basic Usage

AutoFixture.NUnit4 provides an [AutoData] attribute that automatically populates test method parameters with generated data.

For example, imagine you have a simple calculator class:

public class Calculator
{
	public int Add(int a, int b) => a + b;
}

You can write a test using AutoFixture to provide the input values:

using NUnit.Framework;
using AutoFixture.NUnit4;

[TestFixture]
public class CalculatorTests
{
 [Test, AutoData]
 public void Add_SimpleValues_ReturnsCorrectResult(
 Calculator calculator, int a, int b)
 {
 // Act
 int result = calculator.Add(a, b);

 // Assert
 Assert.That(result, Is.EqualTo(a + b));
 }
}

Freezing Dependencies

AutoFixture's [Frozen] attribute can be used to ensure that the same instance of a dependency is injected into multiple parameters.

For example, if you have a consumer class that depends on a shared dependency:

public class Dependency { }

public class Consumer
{
 public Dependency Dependency { get; }

 public Consumer(Dependency dependency)
 {
 Dependency = dependency;
 }
}

You can freeze the Dependency so that all requests for it within the test will return the same instance:

using NUnit.Framework;
using AutoFixture.NUnit4;
using AutoFixture;

[TestFixture]
public class ConsumerTests
{
 [Test, AutoData]
 public void Consumer_UsesSameDependency(
 [Frozen] Dependency dependency, Consumer consumer)
 {
 // Assert
 Assert.That(dependency, Is.SameAs(consumer.Dependency));
 }
}

Integrations

AutoFixture offers a variety of utility packages and integrations with most of the major mocking libraries and testing frameworks.

Since AutoFixture tries maintain compatibility with a large number of package versions, the packages bundled with AutoFixture might not contain the latest features of your (e.g. mocking) library.<br /> Make sure to install the latest version of the integrated library package, alongside the AutoFixture packages.

Core packages

The core packages offer the full set of AutoFixture's features without requring any testing framework or third party integration.

Product Package Stable Preview Downloads
The core package AutoFixture 👁 NuGet
👁 NuGet
👁 NuGet
Assertion idioms AutoFixture.Idioms 👁 NuGet
👁 NuGet
👁 NuGet
Seed extensions AutoFixture.SeedExtensions 👁 NuGet
👁 NuGet
👁 NuGet

Mocking libraries

AutoFixture offers integations with most major .NET mocking libraries.<br/> These integrations enable such features as configuring mocks, auto-injecting mocks, etc.

Product Package Stable Preview Downloads
Moq AutoFixture.AutoMoq 👁 NuGet
👁 NuGet
👁 NuGet
NSubstitute AutoFixture.AutoNSubstitute 👁 NuGet
👁 NuGet
👁 NuGet
FakeItEasy AutoFixture.AutoFakeItEasy 👁 NuGet
👁 NuGet
👁 NuGet
Rhino Mocks AutoFixture.AutoRhinoMocks 👁 NuGet
👁 NuGet
👁 NuGet

Testing frameworks

AutoFixture offers integrations with most major .NET testing frameworks.<br /> These integrations enable auto-generation of test cases, combining auto-generated data with inline arguments, etc.

Product Package Stable Preview Downloads
xUnit v3 AutoFixture.Xunit3 👁 NuGet
👁 NuGet
👁 NuGet
xUnit v2 AutoFixture.Xunit2 👁 NuGet
👁 NuGet
👁 NuGet
xUnit v1 AutoFixture.Xunit 👁 NuGet
👁 NuGet
👁 NuGet
NUnit v4 AutoFixture.NUnit4 👁 NuGet
👁 NuGet
👁 NuGet
NUnit v3 AutoFixture.NUnit3 👁 NuGet
👁 NuGet
👁 NuGet
NUnit v2 AutoFixture.NUnit2 👁 NuGet
👁 NuGet
👁 NuGet
Foq AutoFixture.AutoFoq 👁 NuGet
👁 NuGet
👁 NuGet

You can check the compatibility with your target framework version on the wiki or on the NuGet website.

Contributing

Contributions are welcome!<br/> If you would like to contribute, please review our contributing guidelines and open an issue or pull request.

License

AutoFixture is Open Source software and is released under the MIT license.<br /> The licenses allows the use of AutoFixture libraries in free and commercial applications and libraries without restrictions.

.NET Foundation

This project is supported by the .NET Foundation.

Product Versions Compatible and additional computed target framework versions.
.NET net6.0 net6.0 is compatible.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 was computed.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Framework net462 net462 is compatible.  net463 net463 was computed.  net47 net47 was computed.  net471 net471 was computed.  net472 net472 was computed.  net48 net48 was computed.  net481 net481 was computed. 
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 AutoFixture.NUnit4:

Package Downloads
SFA.DAS.Testing.AutoFixture

Shared library for autofixture extensions

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on AutoFixture.NUnit4:

Repository Stars
recyclarr/recyclarr
Automatically sync TRaSH Guides to your Sonarr and Radarr instances
Version Downloads Last Updated
5.0.0-preview0012 291,591 1/21/2025
5.0.0-preview0011 496,809 4/15/2024
4.19.0 523,511 4/15/2025