Skip to content
ApprovalTest verification library for .Net
C# ASP CSS Shell
Find file
Pull request Compare This branch is 138 commits behind approvals:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.nuget
ApprovalTests.MSTest
ApprovalTests.MSpec
ApprovalTests.MachineSpecific.Tests
ApprovalTests.MbUnit
ApprovalTests.Tests
ApprovalTests.Xunit
ApprovalTests
ApprovalUtilities.Tests
ApprovalUtilities
Asp.Net.Demo
Common
Docs/Images
MvcApplication.Razor
NeedsRepair/ApprovalTests.Silverlight.Tests
ReportingDemo
build
lib/ReportViewer
packages
.gitattributes
.gitignore
ApprovalTests.build
ApprovalTests.ncrunchsolution
ApprovalTests.properties.example
ApprovalTests.sln
ApprovalTests.sln.DotSettings
ApprovalTests.vsmdi
ApprovalsKeyPair.snk
CreateNuget.cmd
DeployToNuget.cmd
LICENSE.md
LocalTestRun.testrunconfig
MyGet.cmd
VersionInfo.cs
readme.md

readme.md

ApprovalTests

Capturing Human Intelligence - ApprovalTests is an open source assertion/verification library to aid unit testing.

It is compatible with most .Net unit testing frameworks (Nunit, MsTest, Xunit, MBUnit)

What can it be used for?

Approval Tests can be used for verifying objects that require more than a simple assert. They also come prepackaged with utilities for some common .Net scenarios including

  • Dictionaries & Collections
  • Long Strings
  • Log Files
  • Asp.Net
  • Asp.Net Mvc
  • Winforms
  • Wpf
  • Entity Framework
  • Rdlc reports

Video Tutorials

You can watch a bunch of short videos on getting started and using ApprovalTests in .Net at YouTube

Podcasts

If you prefer auditory learning, you might enjoy the following podcast

Available on NuGet

Install-Package ApprovalTests

Nightly (CI) Builds available at myget.org:

ApprovalTests Nightly Build Status

ApprovalTests on the MyGet Gallery Note: Select "Include Prerelease" instead of "Stable Only" (-IncludePrerelease in powershell)

Examples

Sample Code

    [UseReporter(typeof(DiffReporter))]
    [TestFixture]
    public class SampleTest
    {
        [Test]
        public void TestList()
        {
            var names = new[] {"Llewellyn", "James", "Dan", "Jason", "Katrina"};
            Array.Sort(names);
            Approvals.VerifyAll(names, "");
        }
    }

Will Produce a File

SampleTest.TestList.received.txt
[0] = Dan
[1] = James
[2] = Jason
[3] = Katrina
[4] = Llewellyn

Simply rename this to SampleTest.TestList.approved.txt and the test will now pass.

Approved File Artifacts

The *.approved.* files must be checked into source your source control. This can be an issue with git as it will change the line endings. The suggested fix is to add *.approved.* binary to your .gitattributes

Do not add *.received.* files to your source control (they are transitory, and some SCMs like TFS will lock them or mark them read-only, which will break every dependent test).

More Info

LICENSE

Apache 2.0 License

Questions?

ask on twitter: @LlewellynFalco or #ApprovalTests

Something went wrong with that request. Please try again.