From ace0c38d5e9997772181dc8327adeab1cf9a193f Mon Sep 17 00:00:00 2001 From: Hugo Bastien Date: Tue, 29 Nov 2016 21:55:33 -0500 Subject: [PATCH 1/2] Define a FailureDiffs folder This took an unexpected turn. There's a nice interface defined for the reference folder: https://github.com/facebook/ios-snapshot-test-case/blob/master/FBSnapshotTestCase/FBSnapshotTestController.h#L72 That's not the case for the failure diffs folder. I had to get creative so I used the setenv in order to give this failure diffs folder mapping by default. See here to know how it's used in the FBSnapshotTestCase project: https://github.com/facebook/ios-snapshot-test-case/blob/master/FBSnapshotTestCase/FBSnapshotTestController.m#L266-L268 --- HaveValidSnapshot.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/HaveValidSnapshot.swift b/HaveValidSnapshot.swift index 66713050..b1297798 100644 --- a/HaveValidSnapshot.swift +++ b/HaveValidSnapshot.swift @@ -99,6 +99,8 @@ func getDefaultReferenceDirectory(_ sourceFileName: String) -> String { let folderPathComponents = pathComponents.subarray(with: NSRange(location: 0, length: currentIndex)) as NSArray let folderPath = folderPathComponents.componentsJoined(by: "/") + setDefaultFailureDiffsDirectory(testTargetFolderPath: folderPath) + return folderPath + "/ReferenceImages" } @@ -111,6 +113,10 @@ private func parseFilename(filename: String) -> String { return sanitizedName } +func setDefaultFailureDiffsDirectory(testTargetFolderPath: String) { + setenv("IMAGE_DIFF_DIR", "\(testTargetFolderPath)/FailureDiffs", 0) +} + func sanitizedTestName(_ name: String?) -> String { guard let testName = currentTestName() else { fatalError("Test matchers must be called from inside a test block") From 3c1724e84eea6c68ef777a63b52dda1e05690f9b Mon Sep 17 00:00:00 2001 From: Hugo Bastien Date: Tue, 29 Nov 2016 22:07:36 -0500 Subject: [PATCH 2/2] A note about test failure artifacts and vcs --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index a6bc5ffc..eb8fe202 100644 --- a/README.md +++ b/README.md @@ -178,3 +178,14 @@ implement the `ViewResizer` protocol and resize yourself. The custom behavior can be used to record the views too. For more info on usage, check the [dynamic sizes tests](Bootstrap/BootstrapTests/DynamicSizeTests.swift). + +## A note about test failures artifacts + +By default Nimble-Snapshot will place test failures image diffs in a folder right next to `ReferenceImages`. It is strongly recommended that you don't commit those files to your source repo. + +Add this to your `.gitignore`: + +``` +# Nimble-Snapshot +FailureDiffs +``` \ No newline at end of file