Skip to main content

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

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

Get Started

dotnet add package Nullean.Snapshots.TUnit --version 0.18.0
ProductVersions
.NET
net10.0net11.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

Partial runs

A test process started with a filter (--treenode-filter, --filter-uid, --filter) marks its run manifest partial, and so does a journey or .http file skipped by SkipReason. snap orphans then skips the project instead of reporting every untouched snapshot as an orphan. A runner that selects tests another way calls SnapshotDefaults.MarkRunPartial(reason).

Downloads by Version

Similar & Alternative Packages

Hand-picked matching NuGet libraries based on tags & ecosystem

Depended On By

Find packages that declare this package as a dependency. NuGet does not provide a reverse-dependency endpoint, so candidates are checked on demand.

Adoption Assessment

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

Compatibility metadata lists 2 target frameworks; confirm the exact target used by your application.

Related Guides & Workflows

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