Skip to main content
net10.0

TUnit test identity for Nullean.Snapshots: the runtime class, method and arguments of the running test.

Published
Nov 12, 2026
11d ago
Total Downloads
6.1K
6,105

Install

dotnet add package Nullean.Snapshots.TUnit --version 0.12.1
ProductVersions
.NET
net10.0

README

Nullean.Snapshots.TUnit

snapshots.

TUnit test identity for Nullean.Snapshots: snapshot names come from the running test's runtime class, method and arguments, so every case of a data-driven test gets its own file. Adds the [SnapshotFiles], [JourneyFiles] and [HttpFiles] data sources.

NuGet

Install

dotnet add package Nullean.Snapshots.TUnit

Quick start

Reference it from every TUnit test project that asserts snapshots; a buildTransitive targets file registers it, so there is nothing to call.

using AwesomeAssertions;
using Nullean.Snapshots;
using Nullean.Snapshots.TUnit;

public class RenderTests
{
	[Test]
	[Arguments("kibana")]
	[Arguments("beats")]
	public void Renders(string product) =>
		Catalog.Greet(product).Should().MatchSnapshot();        // Renders.<argsHash>.verified.txt per case

	[Test]
	[SnapshotFiles("cases", "*.md")]                              // one case per file: Formats(nested/case)
	public void Formats(SnapshotFile file)
	{
		var result = Snapshot.MatchFile(File.ReadAllText(file.Path).ToUpperInvariant(), SnapshotFormats.Text, file.Path);
		if (!result.Passed)
			Assert.Fail(result.FailureMessage!);
	}
}
  • Without this package the class folder is the test file name and arguments add no hash, so every case of a data-driven test shares one verified file.
  • The hash is of each argument's invariant text. Use records or primitives: a class without a ToString() override hashes the same for every case and fails, asking for a name.
  • The folder is the runtime class, so [InheritsTests] classes get their own snapshots.
  • To register by hand, set <SnapshotsTUnitAutoRegister>false</SnapshotsTUnitAutoRegister> and call TUnitTestIdentity.Register() from a [Before(Assembly)] hook.

Learn more

Changes from Previous Version

No structural changes between v0.12.0 and v0.12.1.

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

Compatibility metadata lists 1 target framework; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.