Verify alternatives and similar packages
Based on the "Testing" category.
Alternatively, view Verify alternatives based on common mentions on social networks and blogs.
-
AutoFixture
AutoFixture is an open source framework for .NET designed to minimize the 'Arrange' phase of your unit tests -
Fluent Assertions
A set of .NET extension methods that allow you to more naturally specify the expected outcome of a TDD or BDD-style test -
Shouldly
Shouldly is an assertion framework which focuses on giving great error messages when the assertion fails while being simple and terse. -
Machine.Specifications
Machine.Specifications (MSpec) is a context/specification framework that removes language noise and simplifies tests. -
Compare-Net-Objects
Perform a deep compare of any two .NET objects using reflection. Shows the differences between the two objects. -
GenFu
GenFu is a library you can use to generate realistic test data. It is composed of several property fillers that can populate commonly named properties through reflection using an internal database of values or randomly created data. You can override any of the fillers, give GenFu hints on how to fill them. -
Expecto
A smooth testing framework for F# with tests as values. Unit testing, property based testing, performance testing and stress testing. -
xBehave.net
A BDD/TDD framework based on xUnit.net and inspired by Gherkin. http://xbehave.github.io -
SpecsFor
SpecsFor is a light-weight Behavior-Driven Development framework that focuses on ease of use for *developers* by minimizing testing friction. -
SimpleStubs
*SimpleStubs* is a simple mocking framework that supports Universal Windows Platform (UWP), .NET Core and .NET framework. SimpleStubs is currently developed and maintained by Microsoft BigPark Studios in Vancouver. -
ExpressionToCode
Use plain C# syntax in assertions that include both the expression expression and subexpression values in the failure message. -
Fine Code Coverage
Visualize unit test code coverage easily for free in Visual Studio Community Edition (and other editions too) -
ReportPortal
AI-powered Test Automation Dashboard. Acquire, aggregate and analyze test reports to ascertain release health. -
NCrunch
An automated continuous & concurrent testing tool for Visual Studio. [$]
Get performance insights in less than 4 minutes
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest. Visit our partner's website for more details.
Do you think we are missing an alternative of Verify or a related project?
README
<!-- GENERATED FILE - DO NOT EDIT This file was generated by MarkdownSnippets. Source File: /readme.source.md To change this file edit the source file and then run MarkdownSnippets. -->
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.
Support is available via a Tidelift Subscription.
Part of the .NET Foundation
<!-- toc -->
Contents
- Usage
- Received and Verified
- Videos
- Extensions
- More Documentation
- Alternatives
- Security contact information<!-- endToc -->
NuGet packages
- https://nuget.org/packages/Verify.Xunit/
- https://nuget.org/packages/Verify.NUnit/
- https://nuget.org/packages/Verify.MSTest/
Usage
Class being tested
Given a class to be tested:
<!-- snippet: ClassBeingTested -->
public static class ClassBeingTested
{
public static Person FindPerson()
{
return new Person
{
Id = new Guid("ebced679-45d3-4653-8791-3d969c4a986c"),
Title = Title.Mr,
GivenNames = "John",
FamilyName = "Smith",
Spouse = "Jill",
Children = new List<string>
{
"Sam",
"Mary"
},
Address = new Address
{
Street = "4 Puddle Lane",
Country = "USA"
}
};
}
}
snippet source | anchor <!-- endSnippet -->
xUnit
Support for xUnit
<!-- snippet: SampleTestXunit -->
[UsesVerify]
public class Sample
{
[Fact]
public Task Test()
{
var person = ClassBeingTested.FindPerson();
return Verifier.Verify(person);
}
}
snippet source | anchor <!-- endSnippet -->
NUnit
Support for NUnit
<!-- snippet: SampleTestNUnit -->
[TestFixture]
public class Sample
{
[Test]
public Task Test()
{
var person = ClassBeingTested.FindPerson();
return Verifier.Verify(person);
}
}
snippet source | anchor <!-- endSnippet -->
MSTest
Support for MSTest
<!-- snippet: SampleTestMSTest -->
[TestClass]
public class Sample :
VerifyBase
{
[TestMethod]
public Task Test ()
{
var person = ClassBeingTested.FindPerson();
return Verify(person);
}
}
snippet source | anchor <!-- endSnippet -->
Initial Verification
When the test is initially run will fail with:
First verification. Sample.Test.verified.txt not found.
Verification command has been copied to the clipboard.
The clipboard will contain the following:
cmd /c move /Y "C:\Code\Sample\Sample.Test.received.txt" "C:\Code\Sample\Sample.Test.verified.txt"
Notes:
- More Clipboard info.
- An alternative to using the clipboard is the DiffEngineTray tool.
If a Diff Tool is detected it will display the diff:
To verify the result:
- Execute the command from the clipboard, or
- 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:
<!-- snippet: Verify.Xunit.Tests/Snippets/Sample.Test.verified.txt -->
{
GivenNames: John,
FamilyName: Smith,
Spouse: Jill,
Address: {
Street: 4 Puddle Lane,
Country: USA
},
Children: [
Sam,
Mary
],
Id: Guid_1
}
snippet source | anchor <!-- endSnippet -->
Subsequent Verification
If the implementation of ClassBeingTested
changes:
<!-- snippet: ClassBeingTestedChanged -->
public static class ClassBeingTested
{
public static Person FindPerson()
{
return new Person
{
Id = new Guid("ebced679-45d3-4653-8791-3d969c4a986c"),
Title = Title.Mr,
// Middle name added
GivenNames = "John James",
FamilyName = "Smith",
Spouse = "Jill",
Children = new List<string>
{
"Sam",
"Mary"
},
Address = new Address
{
// Address changed
Street = "64 Barnett Street",
Country = "USA"
}
};
}
}
snippet source | anchor <!-- endSnippet -->
And the test is re run it will fail with
Verification command has been copied to the clipboard.
Assert.Equal() Failure
↓ (pos 21)
Expected: ···\n GivenNames: 'John',\n FamilyName: 'Smith',\n Spouse: 'Jill···
Actual: ···\n GivenNames: 'John James',\n FamilyName: 'Smith',\n Spouse:···
↑ (pos 21)
The clipboard will again contain the following:
cmd /c move /Y "C:\Code\Sample\Sample.Test.received.txt" "C:\Code\Sample\Sample.Test.verified.txt"
See also: Clipboard
The Diff Tool is will display the diff:
The same approach can be used to verify the results and the change to Sample.Test.verified.txt
is committed to source control along with the change to ClassBeingTested
.
Received and Verified
- All
*.verified.*
files should be committed to source control. - All
*.received.*
files should be excluded from source control.
Videos
Extensions
- Verify.AngleSharp.Diffing: Comparison of html files via AngleSharp.Diffing.
- Verify.Aspose: Verification of documents (pdf, docx, xslx, and pptx) via Aspose.
- Verify.Blazor: Verification of Blazor Component via bunit or via raw Blazor rendering.
- Verify.EntityFramework: Verification of EntityFramework bits.
- Verify.ICSharpCode.Decompiler: Comparison of assemblies and types via ICSharpCode.Decompiler.
- Verify.ImageMagick: Verification and comparison of images via Magick.NET.
- Verify.ImageSharp: Verification of images via ImageSharp.
- Verify.NServiceBus: Verify NServiceBus Test Contexts.
- Verify.Phash: Comparison of documents via Phash.
- Verify.RavenDb: Verification of RavenDb bits.
- Verify.Selenium: Verification of Web UIs using Selenium.
- Verify.SqlServer: Verification of SqlServer bits.
- Verify.Uno: Verification to allow verification of Uno UIs.
- Verify.Web: Verification of web bits.
- Verify.WinForms: Verification of WinForms UIs.
- Verify.Xamarin: Verification of Xamarin UIs.
- Verify.Xaml: Verification of Xaml UIs.
More Documentation
- Clipboard <!-- include: doc-index. path: /docs/mdsource/doc-index.include.md -->
- Compared to assertions
- Verify options
- Serializer Settings
- File naming
- Parameterised tests
- Named Tuples
- Scrubbers
- Diff Engine
- Diff Tools
- Diff Tool Order
- Custom Diff Tool
- Using anonymous types
- Verifying binary data
- Build server
- Comparers
- Converters
- Compared to ApprovalTests <!-- endInclude -->
Alternatives
Projects/tools that may be a better alternative to Verify
Security contact information
To report a security vulnerability, use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.
Icon
Helmet designed by Leonidas Ikonomou from The Noun Project.