Install
dotnet add package Nullean.Snapshots.TUnit --version 0.12.2
| Product | Versions |
|---|---|
| .NET |
README
Nullean.Snapshots.TUnit

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.
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 callTUnitTestIdentity.Register()from a[Before(Assembly)]hook.
Learn more
- Documentation: https://snapshots.nullean.net
- Layout of snapshot files: https://snapshots.nullean.net/reference/layout/
- Source and issues: https://github.com/nullean/snapshots
Changes from Previous Version
v0.12.1v0.12.2
Added Frameworks
net11.0
Added Dependencies
Nullean.Snapshots(net11.0)
TUnit.Core(net11.0)
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.