public class ApprovalFiles extends Object
Approval Testing relies on 2 specific files for storing the execution results of the Program Under Tests and running comparisons over the output of the program.
Approvals-Java provides various features, including being able to approve single files, but also to validate the output of a program using an approved folder (which can then contain various sub-folders and files).
This class allows to store references of the 2 particular entries to consider: the approved and received entries, which are used to store the reference data, and the temporary output of the program for comparison. The class manages both cases provided by the framework: single files, or complete folders.
This class not only will hold the references of the approved and received entries, but it’ll also provide all the necessary methods allowing to compare and validate the files or folders.
| Modifier and Type | Field and Description |
|---|---|
Path |
approved
Path to an approved entry.
|
Path |
received
Path to an received entry.
|
| Constructor and Description |
|---|
ApprovalFiles(Path approved,
Path received) |
ApprovalFiles(Path folder,
String methodName)
Constructs a pair of approval entries from the provided folder and method name.
|
| Modifier and Type | Method and Description |
|---|---|
String |
approvedContent() |
void |
createEmptyApprovedFileIfNeeded()
Creates an empty approval file if it doesn’t exist yet.
|
boolean |
equals(Object o)
Overriding equals to allow filtering of duplicates.
|
int |
hashCode()
Overriding hashCode to allow filtering of duplicates.
|
boolean |
haveSameContent()
Checks if both files have the same content (by reading them and comparing the data afterwards).
|
ApprovalFolders |
parent() |
String |
receivedContent() |
public final Path approved
Path to an approved entry.
This entry can contain:
public final Path received
Path to an received entry.
This entry can contain:
public ApprovalFiles(Path folder, String methodName)
Constructs a pair of approval entries from the provided folder and method name. The path for both approved and received files will be computed and used as approval files.
folder - The folder in which the approval files will be locatedmethodName - The name of the method calling the test. It is used to actually name the approval filespublic String approvedContent()
public String receivedContent()
public boolean haveSameContent()
Checks if both files have the same content (by reading them and comparing the data afterwards).
public void createEmptyApprovedFileIfNeeded()
Creates an empty approval file if it doesn’t exist yet. If it already exists, that method does nothing.
public ApprovalFolders parent()
public boolean equals(Object o)
Overriding equals to allow filtering of duplicates.
Copyright © 2018–2019 Write Them First!. All rights reserved.