-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recognise and enable acceptance of AutoRecorded images. #72
base: master
Are you sure you want to change the base?
Conversation
This pull request stands alone, but would function best in combination with the following three pull requests: In combination, and with the AutoRecord change to iOSSnapshotTestCase linked above, these changes enable snapshots to be automatically created on first run of a test if a reference image does not exist, to be reviewed, to be accepted or rejected via FBSnapshotsViewer, and in both cases for the test images to be cleaned up afterwards. |
Complementary feature to the implementation of AutoRecord proposed to iOSSnapshotTestCase in this pull request: uber/ios-snapshot-test-case#32
Enable image to be accepted (“swapped”) as a reference image, when an original reference image does not exist.
Rebased on current master. |
@@ -34,7 +34,7 @@ class SnapshotTestResultAcceptor { | |||
let failedImageSizeSuffix = imagePath.substring(with: failedImageSizeSuffixRange) | |||
let recordedImageURLs = testResult.build.fbReferenceImageDirectoryURLs.flatMap { fbReferenceImageDirectoryURL -> URL? in | |||
let url = fbReferenceImageDirectoryURL.appendingPathComponent(testResult.testClassName).appendingPathComponent("\(testResult.testName)\(failedImageSizeSuffix)").appendingPathExtension("png") | |||
return fileManager.fileExists(atPath: url.path) ? url : nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to change it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. This change was the shortest path to implement the desired functionality here, which was to still create test images even if a reference image didn't exist. However, now that I look at it, it seems like maybe it would be better to still throw SnapshotTestResultAcceptorError.notExistedRecordedImage but then catch it and handle it by doing what we want with the autoRecording functionality. I think I was put off a bit by framing this as a SnapshotTestResultAcceptorError when really it's a SnapshotTestResultAcceptorResult, given a missing reference snapshot is no longer considered an error per se, if and when this pull request is integrated.
I will take another look at this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @babbage ;)
Complementary feature to the implementation of AutoRecord proposed to iOSSnapshotTestCase in this pull request: uber/ios-snapshot-test-case#32. Enables image to be accepted (“swapped”) as a reference image, when an original reference image does not exist.