Texture icon indicating copy to clipboard operation
Texture copied to clipboard

Texture Framework causing FBSnapshotTestCase UI Testing framework to fail due to a diff in the UI (with suggested solution)

Open 0xkuj opened this issue 4 years ago • 0 comments

Description of the issue: We have an SDK that utilizes the Texture library and when applications integrate our SDK while using FBSnapshotTestCase Framework to run UI Tests, tests will fail showing diff failure between different UI elements. in the example below we will see one example of UI changing (this time - its round corners but not limited only to that). while only using Texture framework

Texture Version: 3.0.0-rc.2 Xcode version: 13.1 idevice + iOS Version: iPhone 11 Pro running iOS 14.0.1 link to example project containing this description and an example project (Already include texture) to reproduce the issue: https://github.com/0xkuj/Example_APP_with_Snapshot_and_Texture

Informative description:

Example FBSnapshotTestCase with Snapshot and Texture

this repository contains an example app to include a reproduction of an issue with the Texture framework combined with FBSnapshotTestCase.

Description of the issue: Integrating Texture Framework while using FBSnapshotTestCase Framework to run UI Tests, tests will fail showing diff failure between different UI elements. in the example below we will see one example of UI changing (this time - its round corners but not limited only to that).

Below - Instructions on how to reproduce the failures using the example app from this repository:

  1. Download the zip file "Example_app_with_texture_and_FBSnapshotTestCase.zip" from this repo (or clone this repo by using "git clone https://github.com/0xkuj/Example_APP_with_Snapshot_and_Texture.git"

  2. Unzip the file and open "App.xcodeproj" (Note - I use Xcode 13.1 but it is probably not a must)

  3. Make sure "AsyncDisplayKit.xcodeproj" is under "Core"

Screen Shot 2021-11-29 at 14 49 45

  1. Make sure the "Core" Target is using "AsyncDisplayKit.framework"

Screen Shot 2021-11-29 at 14 51 16

  1. Go to Test Navigator tab in Xcode
  2. Make sure your simulator is on device running 14.0.1 (this should not be iOS specific, but this test case is working 100% of the times) (I am using iPhone 11 Pro with iOS 14.0.1)
  3. run the tests named "FeatureTests" - this stage will run the UI tests using the "Snapshot" framework. tests will must likely fail. in the diff file ("FailureDiffs")

Screen Shot 2021-11-29 at 14 55 39

  1. Check the failure diff inside the folder, and the diff will look like this:

Screen Shot 2021-11-29 at 14 57 38

This actually means that the Snapshot framework is trying to compare between a screen it expects to find

testSnapshot@3x vs what it actually finds (this is due to Texture framework integration - once the Texture framework is removed from within the "Core" frameworks list {stage 4} the issue is gone)

failed_testSnapshot@3x

Consider - Suggested solution: We found that moving the initialization of allowsGroupOpacityFromUIKitOrNil and allowsEdgeAntialiasingFromUIKitOrNil from "ASInitializeFrameworkMainThread(void)" to their respective functions before being used (in this one and only time) (BOOL ASDefaultAllowsGroupOpacity() and BOOL ASDefaultAllowsEdgeAntialiasing()) will solve this issue. Screen Shot 2021-11-29 at 15 15 01

0xkuj avatar Nov 29 '21 13:11 0xkuj