Verify is a snapshot testing tool that simplifies the assertion of complex data models and documents.
Verify is a snapshot testing tool that simplifies the assertion of complex data models and documents.
Verify is a snapshot tool that simplifies the assertion of complex data models and documents.
Verify is called on the test result during the assertion phase. It serializes that result and stores it in a file that matches the test name. On the next test execution, the result is again serialized and compared to the existing file. The test will fail if the two snapshots do not match: either the change is unexpected, or the reference snapshot needs to be updated to the new result.
[!IMPORTANT] Open Source Maintenance Fee. Every version released after 1 September 2026 is covered by a maintenance fee for organizations that generate revenue, and for government agencies. The source code remains open and free. Details below.
See Milestones for release notes.
This project participates in the Open Source Maintenance Fee. The source code stays freely available under the terms of the license. The fee covers the use of the official binary releases, the packages published to NuGet, by organizations that generate revenue from them. Every version released after 1 September 2026 is covered; versions released on or before that date are not.
The fee is paid by sponsoring VerifyTests at the monthly tier matching the size of the organization:
| Organization size | Fee (USD) |
|---|---|
| Fewer than 40 employees | $5/month |
| 40 to 200 employees | $20/month |
| 200 to 1000 employees | $30/month |
| More than 1000 employees | $100/month |
From v33, sponsorship is verified at build time by SponsorCheck. Nothing phones home: the check runs inside the build, adds no runtime dependency to the packages, and issues no license keys. A sponsoring organization declares its account once, in a Directory.Build.props at the root of the repository, and that covers every project and every Verify package:
<PropertyGroup>
<Verify_GitHubSponsorAccount>your-github-account</Verify_GitHubSponsorAccount>
</PropertyGroup>Who the fee applies to, the exemptions, paying by invoice, and the other declarations (exemptions, private arrangements, opting out) are covered in Open Source Maintenance Fee. The SponsorCheck setup wizard for Verify generates the exact snippet for any of them.
Entity Framework Extensions is a major sponsor and is proud to contribute to the development this project.
Authentication and authorization via
Browser testing via
Get customized instructions for the specific combination of Operating System, IDE, Test Framework, and Build Server.
Accepting or declining a snapshot file is part of the core workflow of Verify. There are several ways to do this and the approach(s) selected is a personal preference.
.received. file to .verified.. This can be automated via scripts to bulk accept all .received. files by matching a pattern.All examples use Implicit Usings. Ensure <ImplicitUsings> is set to enable to ensure examples compile correctly.
<ImplicitUsings>enable</ImplicitUsings>If ImplicitUsings are not enabled, substitute usages of Verify() with Verifier.Verify().
Given a class to be tested:
public static class ClassBeingTested
{
public static Person FindPerson() =>
new()
{
Id = new("ebced679-45d3-4653-8791-3d969c4a986c"),
Title = Title.Mr,
GivenNames = "John",
FamilyName = "Smith",
Spouse = "Jill",
Children =
[
"Sam",
"Mary"
],
Address = new()
{
Street = "4 Puddle Lane",
Country = "USA"
}
};
}Support for NUnit
[TestFixture]
public class Sample
{
[Test]
public Task Test()
{
var person = ClassBeingTested.FindPerson();
return Verify(person);
}
}Support for xUnitV3
public class Sample
{
[Fact]
public Task Test()
{
var person = ClassBeingTested.FindPerson();
return Verify(person);
}
}Support for Fixie
public class Sample
{
public Task Test()
{
var person = ClassBeingTested.FindPerson();
return Verify(person);
}
}Fixie is less opinionated than other test frameworks. As such it leaves up to the consumer how to configure test execution.
To enable Verify the ITestProject and IExecution interfaces need to be used.
Requirements:
ITestProject.Configure using VerifierSettings.AssignTargetAssemblyIExecution.Run using ExecutionState.SetAn example implementation of the above:
…Support for Expecto
open Expecto
open VerifyTests
open VerifyExpecto
[<Tests>]
let tests =
testTask "findPerson" {
let person = ClassBeingTested.FindPerson()
do! Verifier.Verify("findPerson", person).ToTask()
}Due to the nature of the Expecto implementation, the following APIs in Verify are not supported.
settings.UseParameters()settings.UseTextForParameters()Support for TUnit
public class Sample
{
[Test]
public Task Test()
{
var person = ClassBeingTested.FindPerson();
return Verify(person);
}
}Support for MSTest
[TestClass]
public partial class Sample
{
[TestMethod]
public Task Test()
{
var person = ClassBeingTested.FindPerson();
return Verify(person);
}
}The MSTest implementation leverages a Source Generator and requires test classes to opt in to being processed by the Source Generator.
Add the UsesVerifyAttribute.
For all test classes in an assembly:
[assembly: UsesVerify]For a specific a test class:
[UsesVerify]
[TestClass]
public class TheTest...Or inherit from VerifyBase:
[TestClass]
public class VerifyBaseUsage :
VerifyBase
{
[TestMethod]
public Task Simple() =>
Verify("The content");
}No existing .verified. file.
graph TD
run(Run test and<br/>create Received file)
failTest(Fail Test<br/>and show Diff)
closeDiff(Close Diff)
run-->failTest
shouldAccept{Accept ?}
failTest-->shouldAccept
accept(Move Received<br/>to Verified)
shouldAccept-- Yes -->accept
discard(Discard<br/>Received)
shouldAccept-- No -->discard
accept-->closeDiff
discard-->closeDiffWhen the test is initially run it will fail. If a Diff Tool is detected it will be used to display the diff.
To verify the result:
This will result in the Sample.Test.verified.txt being created:
No open issues yet, or sync has not completed.