This documentation explains how to capture received files from a Continuous Integration (CI) system when tests pass on your local machine but fail on CI.
One of the challenges developers face is when tests pass on their local machine but fail on the CI system. This is particularly common with image or binary files but can occur with any file type.
ApprovalTests provides a reporter called FileCaptureReporter
that can help address this issue. When a test fails, FileCaptureReporter
adds the received file to your Git repository and pushes it. This allows you to capture feedback from a headless CI machine.
NOTE: Keep in mind that this process will create one commit per received file. If multiple tests fail, you will have multiple commits.
Here is an example:
CustomPanel panel = new CustomPanel(true, 20);
AwtApprovals.verify(panel, new Options(new FileCaptureReporter()));
The example above demonstrates how to use FileCaptureReporter with ApprovalTests to capture received files on test failure.
FileCaptureReporter
is currently compatible with GitHub Actions and any machine where Git is configured to allow committing and pushing from the command line. You can extend this compatibility as needed for your specific system.