Save all artifacts to disk in the event of failure #902
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective:
In the event of a failing snapshot test, keep in disk artifacts not only for the snapshot that failed, but also for the reference against it was compared to and the diff between them. (Probably sort of what´s being requested in issue #176)
The easiest way I figured out to do this is by adding a third parameter returned by
diff
closure fromDiffing
struct, but of course I´m open to suggestions if there are neater/simpler ways (I exploredXCTestAttachment
since the function is already returning these, but found no way of getting out images from there).Context
I´m trying to move away my projects from iOSSnapshotTestCase (previously FBSnapshotTestCase) to this library, since the other ones are no longer maintained and this one seems much more flexible and customizable.
One of the things I´d miss from those libraries though is the ability to get, in the event of failure, all three artifacts, for ease of analysis in CI/CD
Experiment ran for verifying
I created some snapshot tests for a simple view to which I added a red background color. Reference images were generated/recorded with this color. Then changed background color to blue, disabled record mode and ran tests again for them to fail. Resulting folder content is depicted in beneath screenshot