GithubHelp home page GithubHelp logo

ht101996 / approvaltests.net Goto Github PK

View Code? Open in Web Editor NEW

This project forked from approvals/approvaltests.net

0.0 1.0 0.0 21.52 MB

ApprovalTest verification library for .Net

License: Other

C# 99.87% HTML 0.04% Batchfile 0.10%

approvaltests.net's Introduction

ApprovalTests

Build status License NuGet Status Backers on Open Collective Sponsors on Open Collective

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)

Contents

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:

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

Docs

Available on NuGet

Install-Package ApprovalTests

Examples

Verifing a List

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

snippet source | anchor

Will Produce a File

`SampleTest.TestList.received.txt`

[0] = Dan
[1] = James
[2] = Jason
[3] = Katrina
[4] = Llewellyn

snippet source | anchor

It will also open these 2 files (.received. & .approved. ) in a diff editor.

You can approve these results by copying everything (ctrl+a, ctrl+c) and pasting it in the right hand side (ctrl+a, ctrl+v)

In most situations, you will use one of the supported DiffTools to examine and approve the result.

Alternatively, you can rename the .received. file to SampleTest.TestList.approved.txt and the test will now pass.

note: The diff tools are NOT opened when the tests pass, only on failure.

Approved File Artifacts

The *.approved.* files must be checked into source your source control. ApprovalTests now ignores line endings by default (so you can remove *.approved.* binary from your .gitattributes file if you added previously).

If you would like to verify line endings, simply add [assembly: IgnoreLineEndingsAttribute(false)] to your AssemblyInfo.cs

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

Questions?

ask on twitter: @LlewellynFalco or #ApprovalTests

Credits

Contributors

This project exists thanks to all the people who contribute.

Backers

Thank you to all our backers! ๐Ÿ™ [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

approvaltests.net's People

Contributors

isidore avatar simoncropp avatar jamesrcounts avatar ondjuric avatar staxmanade avatar steenhulthin avatar jaybazuzi avatar julian-maughan avatar markskiba avatar jakeginnivan avatar asherber avatar claremacrae avatar michaelferrante avatar skalinets avatar valdisthomann avatar stocksr avatar dionfoster avatar 304notmodified avatar jim-cooper avatar manuc66 avatar dalpert-korewireless avatar distantcam avatar rasher666 avatar danielmarbach avatar timbussmann avatar spascoe avatar russkie avatar raseesink avatar mvestergaard avatar kharabasz avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.