facebookarchive / ios-snapshot-test-case

Snapshot view unit tests for iOS
MIT License
2.66k stars 253 forks source link

Snapshots differ between Xcode and buck/xctool #206

Closed alanzeino closed 7 years ago

alanzeino commented 7 years ago

Posting this in case someone at Facebook has more insight into this issue — we routinely see issues where a snapshot that passes in Xcode doesn't pass in buck (via xctool).

Regenerating the snapshot in one setting (either Xcode or on the command line via Buck), invalidates it for the other setting.

Are we missing something? The difference is typically seen in UIViews with a corner radius set.

ryu2 commented 7 years ago

Not sure of the exact cause, but we're deprecating xctool in favor of fbxctest so it might be a good idea in any case to move as well.

cc: @lawrencelomax in case he might have some ideas.

ultramiraculous commented 7 years ago

@ryu2 - That's actually awesome/sensible news!

lawrencelomax commented 7 years ago

fbxctest does launch Simulators slightly differently, but I'd be surprised if this affects the output of the screen. This should be possible to test by changing the options to be 0 here

alanzeino commented 7 years ago

Thanks for the responses.

I took a go at using fbxctest by plugging it in to our buckconfig, unfortunately the issue persists, even with Lawrence's proposed change.

My guess is it's something we've done in our setup that is causing this.

alanzeino commented 7 years ago

We didn't end up finding out why buck/xctool was causing this issue.

However, for the affected tests we found that enabling usesDrawViewHierarchyInRect and re–generating the snapshots would fix it.

That can only be done on a case–by–case basis because usesDrawViewHierarchyInRect — which in turn uses drawViewHierarchyInRect:afterScreenUpdates: — is about 10x slower than the CoreGraphics default snapshot method.