- Approvals.AssertText
- MachineSpecificReporter
- ApprovalsFilename
- Making Custom Reporters
- Environment SpecificTests
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);
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);
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.
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");
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