|ReleasedLast Release||Oct 2017|
|LOCLines of Code||198|
Before using the library you need to have a project integrated with EarlGrey library. It is highly recommended to follow an official installation guide and create a separate test target for feature testing, since they are less reliable than usual unit tests.
Next, make sure to define two environment variables which point to:
FB_REFERENCE_IMAGE_DIR- directory containing reference snapshots,
IMAGE_DIFF_DIR- directory containing failure snapshots and visual diffs.
Sane default values for those variables are (as proposed in FBSnapshotTestCase README):
Now it is time to record your first reference snapshot. Select the reference element using EarlGrey's selection API and invoke
EarlGrey.select(elementWithMatcher: grey_kindOfClass(AViewToSnapshotClass.self)) .assert(grey_recordSnapshot())
Run the test target. The test should fail with the following error:
Image recorded successfully! Replace with grey_verifySnapshot().
Having followed the instruction you should alter the test as following:
EarlGrey.select(elementWithMatcher: grey_kindOfClass(AViewToSnapshotClass.self)) .assert(grey_verifySnapshot())
That's it! From now on the tests will verify whether selected view matches reference snapshot.
grey_verifySnapshot() will not work when executing the tests against devices with differing resoultions and pixel densities. To enable such tests you should use
grey_verifyDeviceAgnosticSnapshot() APIs instead. They compare the snapshots paired by the test name and also device type, which means you have to separately record snapshots for all the supported device types.
EarlGreySnapshots glues together two libraries:
Make sure to install them both alongside the project.
EarlGreySnapshots is available through CocoaPods. To install
it, simply add following lines to your Podfile:
pod 'EarlGrey', '~> 1.12' pod 'FBSnapshotTestCase', '~> 2.1' pod 'EarlGreySnapshots', '~> 0.0.4'
Don't forget to run
pod install afterwards!
To run the example project, clone the repo, and run
pod install from the Example directory first.
turekj, [email protected]
EarlGreySnapshots is available under the MIT license. See the LICENSE file for more info.