Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
V

Verify

> 测试质量
Open source

Verify is a snapshot testing tool that simplifies the assertion of complex data models and documents.

3.5K stars0 likes1 views
WebsiteGitHub

About

Verify is a snapshot testing tool that simplifies the assertion of complex data models and documents.

Verify

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.

Open Source Maintenance Fee

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:

xml
<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.

Supporters

Entity Framework Extensions

Entity Framework Extensions is a major sponsor and is proud to contribute to the development this project.

Developed using JetBrains IDEs

Duende Software

Authentication and authorization via

TestMu AI

Browser testing via

Requirements

  • Supported runtimes: net462, net472, net48, net481, net6, net8, net9, and net10.
  • Supported SDK: 9.0.301 and up

Getting started wizard

Get customized instructions for the specific combination of Operating System, IDE, Test Framework, and Build Server.

Start wizard.

NuGet

  • https://nuget.org/packages/Verify.NUnit/
  • https://nuget.org/packages/Verify.XunitV3/
  • https://nuget.org/packages/Verify.Fixie/
  • https://nuget.org/packages/Verify.Expecto/
  • https://nuget.org/packages/Verify.MSTest/
  • https://nuget.org/packages/Verify.TUnit/

Snapshot management

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.

  • In the Windows Tray via DiffEngineTray
  • ReSharper test runner plugin (Source)
  • Rider test runner plugin (Source)
  • Via the clipboard.
  • Manually making the change in the launched diff tool. Either with a copy paste, or some tools have commands to automate this via a shortcut or a button.
  • Manually on the file system, by renaming the .received. file to .verified.. This can be automated via scripts to bulk accept all .received. files by matching a pattern.
  • Using the dotnet tool Verify.Terminal.

Usage

ImplicitUsings

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().

Class being tested

Given a class to be tested:

cs
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"
            }
        };
}

snippet source | anchor

NUnit

Support for NUnit

cs
[TestFixture]
public class Sample
{
    [Test]
    public Task Test()
    {
        var person = ClassBeingTested.FindPerson();
        return Verify(person);
    }
}

snippet source | anchor

xUnitV3

Support for xUnitV3

cs
public class Sample
{
    [Fact]
    public Task Test()
    {
        var person = ClassBeingTested.FindPerson();
        return Verify(person);
    }
}

snippet source | anchor

Fixie

Support for Fixie

cs
public class Sample
{
    public Task Test()
    {
        var person = ClassBeingTested.FindPerson();
        return Verify(person);
    }
}

snippet source | anchor

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:

  • Assign the target assembly in ITestProject.Configure using VerifierSettings.AssignTargetAssembly
  • Wrap test executions in IExecution.Run using ExecutionState.Set

An example implementation of the above:

…

snippet source | anchor

Expecto

Support for Expecto

fs
open Expecto
open VerifyTests
open VerifyExpecto

[<Tests>]
let tests =
    testTask "findPerson" {
        let person = ClassBeingTested.FindPerson()
        do! Verifier.Verify("findPerson", person).ToTask()
    }

snippet source | anchor

Caveats

Due to the nature of the Expecto implementation, the following APIs in Verify are not supported.

  • settings.UseParameters()
  • settings.UseTextForParameters()

TUnit

Support for TUnit

cs
public class Sample
{
    [Test]
    public Task Test()
    {
        var person = ClassBeingTested.FindPerson();
        return Verify(person);
    }
}

snippet source | anchor

MSTest

Support for MSTest

cs
[TestClass]
public partial class Sample
{
    [TestMethod]
    public Task Test()
    {
        var person = ClassBeingTested.FindPerson();
        return Verify(person);
    }
}

snippet source | anchor

Marking tests as 'Using Verify'

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:

cs
[TestClass]
public class VerifyBaseUsage :
    VerifyBase
{
    [TestMethod]
    public Task Simple() =>
        Verify("The content");
}

snippet source | anchor

Initial Verification

No existing .verified. file.

mermaid
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-->closeDiff

When 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:

  • Execute the command from the Clipboard, or
  • Accept with DiffEngineTray tool,
  • Accept with ReSharper Plugin or Rider Plugin
  • Use the diff tool to accept the changes, or
  • Manually copy the text to the new file

Verified result

This will result in the Sample.Test.verified.txt being created:

tx

Issues· 3 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C#assertion-librarysnapshotsnapshot-testingtesting

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category测试质量
PricingOpen source

> Related tools

J
Jest
JavaScript 测试框架
P
Playwright
现代端到端测试框架
E
eslint-plugin-test-selectors
Enforces that data-test-id attributes are added to interactive DOM elements (JSX) to help with UI testing. JSX only.