Swevo.AutoAssert 2.4.1

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

AutoAssert

NuGet NuGet Downloads CI License: MIT .NET

Free, MIT-licensed fluent assertions for .NET with familiar Should() syntax, deep object diffs, snapshot testing, and zero commercial license requirements.

Why AutoAssert instead of FluentAssertions?

  • No commercial license requirement for commercial use.
  • Familiar migration path: fluent Should() API for xUnit, NUnit, and MSTest.
  • Deep diff output for BeEquivalentTo mismatches.
  • AOT-safe direction with optional generated reflection-free equivalency comparers.

Install

dotnet add package Swevo.AutoAssert

Optional companion packages:

dotnet add package Swevo.AutoAssert.Analyzers
dotnet add package Swevo.AutoAssert.Generator
dotnet add package Swevo.AutoAssert.AspNetCore
dotnet add package Swevo.AutoAssert.Json

5-minute quickstart

using AutoAssert;

[Fact]
public void Order_total_is_calculated()
{
    var order = new { Subtotal = 100m, Tax = 20m, Total = 120m };

    order.Total.Should().Be(120m);
    order.Should().BeEquivalentTo(new { Subtotal = 100m, Tax = 20m, Total = 120m });
}

High-value examples

1) Basic assertions and fluent chaining

using AutoAssert;

"hello world".Should()
    .NotBeNullOrEmpty()
    .And.StartWith("hello")
    .And.EndWith("world");

5.Should().BePositive().And.BeLessThan(10);

2) Compare complex object graphs with full diffs

using AutoAssert;

var actual = new OrderDto
{
    Id = 42,
    Customer = new CustomerDto { Name = "Ada" },
    Lines = [new OrderLineDto { Sku = "ABC", Quantity = 2 }]
};

var expected = new
{
    Id = 42,
    Customer = new { Name = "Ada" },
    Lines = new[] { new { Sku = "ABC", Quantity = 2 } }
};

actual.Should().BeEquivalentTo(expected, options => options.WithStrictOrdering());

3) Aggregate failures with AssertionScope

using AutoAssert;

using (new AssertionScope())
{
    result.Name.Should().Be("Ada");
    result.Age.Should().Be(30);
    result.Email.Should().NotBeNullOrEmpty();
}

4) Snapshot tests with scrubbers

using AutoAssert;

result.Should().MatchSnapshot(
    scrub: SnapshotScrubbers.Combine(
        SnapshotScrubbers.Guids(),
        SnapshotScrubbers.IsoTimestamps()));

Migration comparison

AutoAssert is designed to keep common usage nearly identical:

Scenario FluentAssertions style AutoAssert style
Basic value value.Should().Be(42); value.Should().Be(42);
Null/empty name.Should().NotBeNullOrEmpty(); name.Should().NotBeNullOrEmpty();
Exception act.Should().Throw<InvalidOperationException>(); act.Should().Throw<InvalidOperationException>();
Equivalency actual.Should().BeEquivalentTo(expected); actual.Should().BeEquivalentTo(expected);

See deeper comparisons in docs/COMPARISON.md.

Recipes

Copy/paste recipes for common test scenarios:

Companion packages

Package Purpose
Swevo.AutoAssert.Analyzers Compile-time diagnostics for assertion footguns.
Swevo.AutoAssert.Generator Reflection-free generated equivalency comparers.
Swevo.AutoAssert.AspNetCore Fluent HttpResponseMessage assertions for integration tests.
Swevo.AutoAssert.Json Fluent assertions over raw JSON strings.

Compatibility matrix

See docs/COMPATIBILITY.md for package-by-package target frameworks and test framework support.

Release notes

See CHANGELOG.md for version history and feature changes.

Growth and distribution assets

The repository now includes reusable go-to-market assets:

License

MIT © Justin Bannister

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Swevo.AutoAssert:

Package Downloads
Swevo.AutoAssert.AspNetCore

Fluent HttpResponseMessage assertions for ASP.NET Core integration tests. Assert status codes, headers, content type, string body, and JSON body equivalency for WebApplicationFactory/TestServer and HttpClient scenarios.

Swevo.AutoAssert.Json

Fluent assertions for raw JSON strings: validate JSON, assert dotted/indexed properties, and compare full JSON structures with clear diffs (object-key-order-insensitive).

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.4.1 143 10/1/2026
2.4.0 145 9/29/2026
1.1.1 135 8/7/2026
1.1.0 134 7/10/2026
1.0.1 125 7/7/2026
1.0.0 136 7/7/2026

2.4.1: Refresh NuGet listing and onboarding assets (rewritten README quickstart, recipes, compatibility/comparison docs, changelog) and update SourceLink dependency to remove NU1902 warning. 2.4.0: Add ExceptionAssertions.WithMessageMatching for wildcard exception message assertions. Add AssertionConfig.UseColorizedOutput to render expected/actual values in ANSI green/red for BeEquivalentTo member-mismatch diffs and Object/String Be/NotBe failures (opt-in, off by default). 2.3.0: Add SnapshotScrubbers (Guids/IsoTimestamps/Pattern/Combine) and a MatchSnapshot(scrub:) parameter to normalize non-deterministic values before snapshot comparison. Add StringAssertions.Subject public accessor (used by the new Swevo.AutoAssert.Json companion package). New companion package: Swevo.AutoAssert.Json (BeValidJson, HaveJsonProperty, HaveJsonPropertyEqualTo, BeEquivalentToJson for raw JSON strings with full structural diffs). 2.2.0: Add companion packages: Swevo.AutoAssert.Generator (compile-time, reflection-free BeEquivalentTo comparers via [GenerateEquivalencyComparer]) and Swevo.AutoAssert.AspNetCore (fluent HttpResponseMessage assertions for WebApplicationFactory/HttpClient integration tests). Core: BeEquivalentTo now consults a GeneratedEquivalencyRegistry fast path before falling back to reflection when both sides are an exact, registered type. 2.1.0: Add AssertionConfig.ConfigureEquivalency for process-wide default BeEquivalentTo options, and MatchSnapshot() snapshot/golden-file testing (serializes the subject to JSON and compares against a baseline file next to the test, auto-recording it on first run). 2.0.0 (breaking): Every assertion method now returns AndConstraint<T> for fluent chaining (.And.Method()...) instead of void. Added AssertionScope for collecting multiple failures into one exception. BeEquivalentTo now supports Excluding(...)/WithStrictOrdering() options and reports a full diff of mismatched members instead of stopping at the first. Added DateTime/DateTimeOffset/TimeSpan/Guid/Nullable<T>/enum/IDictionary assertions, execution-time assertions (ExecutionTime()/CompleteWithin), unsigned numeric Should() overloads, and many new string/numeric/collection/exception assertion methods. 1.1.0: Add BeEquivalentTo deep structural equivalence for objects, nested graphs, and collections with circular-reference protection. 1.0.1: Add missing package icon. 1.0.0: Initial release. Object, string, numeric, boolean, collection, and exception assertions.