Skip to content

Latest commit

 

History

History
104 lines (75 loc) · 3.61 KB

Features.md

File metadata and controls

104 lines (75 loc) · 3.61 KB

ApprovalTests Features

Contents

Approvals.AssertText

Watch a Video demo of this feature

If you prefer not to store your expectations in the .approved. files, you can store them directly in-line with your code. Sample:

(Before):

var header = new Header();
var actual = header.MakeHeading("I am ten chars");
var expected = "";
Approvals.AssertText(expected, actual);

snippet source | anchor

When you do this, it will copy the c# for the .received. to your clipboard, so you can paste it in-line.

(After)

var header = new Header();
var actual = header.MakeHeading("I am ten chars");
var expected = new[]{
    "**************",
    "I am ten chars",
    "**************",

};
Approvals.AssertText(expected, actual);

snippet source | anchor

Currently, it put the text as an array of strings that gets concatenated as this tends to read better.

It will also write the results to a temp files on failure and open a DiffTool, so you can easily view the results and differences.

ApprovalsFilename

Sometimes you want to parse an approvals filename to get the parts.

var approvalsFilename = ApprovalsFilename.Parse(@"..\Email\EmailTest.Testname.Microsoft_Windows_10_Education.approved.eml");

snippet source | anchor

Will produce

GetFullPath: ..\Email\EmailTest.Testname.Microsoft_Windows_10_Education.approved.eml
Directory: ..\Email
ClassName: EmailTest
MethodName: Testname
AdditionalInformation: [Microsoft_Windows_10_Education]
ApprovedStatus: approved
Extension: eml

snippet source | anchor


Back to User Guide