One key element of approvals is the approved artifacts that are created, and I wanted to take some time to go into these. First off, it is worth mentioning that for xUnit type tests, what is created is a file of the name
... and ...
This file resides in the same directory as the source file for MyClass.
Many times this is simply a text file. The output being approved being taken from the toString() method, or a similar printer. Sometimes it is an html file, which is really just a txt file, sometimes it is a Pdf file or Png image file.
Q: Are these files kept in source control?
Yes, the approved files reside in your source control. This has 2 big benefits
1) The test are repeatable on different systems.
2) You can flip back through easy to view output, to pinpoint when and where a bug got introduced.
Q: What configuration is needed?
Q: How can I write to a custom file format?
Simple, all Approvals.approve(object) calls simply construct an approver, and a reporter. The approver is normally a FileApprover, which takes a FileApprovalWriter and an ApprovalNamer.
To do a custom file output simply make your own ApprovalWriter and your own convenience approve() function