facebookarchive / ios-snapshot-test-case

Snapshot view unit tests for iOS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Xcode8 searches reference screenshots in wrong directory (_32 instead of _64)

delebedev opened this issue · comments

I'm using Xcode8 and getting following error:
-[swiftGift2Tests.AddVoucherTests testVoucherAddedState] : failed - Snapshot comparison failed: Optional(Error Domain=FBSnapshotTestControllerErrorDomain Code=1 "Unable to load reference image." UserInfo={NSLocalizedFailureReason=Reference image not found. You need to run the test in record mode, NSLocalizedDescription=Unable to load reference image., FBReferenceImageFilePathKey=/Users/denis/src/swiftgfit/thor/swiftGift2Tests/ReferenceImages_32/swiftGift2Tests.AddVoucherTests/testVoucherAddedState@2x.png})

Notice ReferenceImages_32. I tried iPhone 6 (iOS 9) / iPhone 6s / iPhone 7. I expected it to be
ReferenceImages_64 as it was when I used it along with Xcode7.

Probably this can be important: I'm using Carthage as dependency manager, so library is assembled as a framework.

I tried to test the following method in empty Xcode8 project but in this case it works as expected and returns YES for all x64 devices.

BOOL FBSnapshotTestCaseIs64Bit(void)
{
#if __LP64__
    return YES;
#else
    return NO;
#endif
}

Probably it's not related with architecture.

Short story short:
Looks like you didn't record image.

Short story long:
Test first check your device architecture snapshot (64 bit for iPhones 6(s)/7) and then checks other architecture (32 bit). If compare between reference image and your view snapshot is OK your test pass. But if compare for first architecture fails framework try to check other architecture. If this fail you will get fail only for other than your device architecture.
Check FBSnapshotTestCase.h, line 88:

  • start test loop
  • first check 64 bit
  • remove all errors
  • fails, so add error to errors array
  • check 32 bit
  • remove all errors
  • fails, so add error to errors array
  • end test loop
  • assert with first error (but in array is only one error about 32 bit image)

We discussed about this with @nscoding here: #119 (you need to expand 2-nd comment). Error reporting should be improved.

@Grubas7 thanks for the explanation, I am not able to check it ATM but I think you are right.