<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Priya Patel on Medium]]></title>
        <description><![CDATA[Stories by Priya Patel on Medium]]></description>
        <link>https://medium.com/@priya-patel-78243?source=rss-af095d0e180c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*59PShcEi8grL-hLW</url>
            <title>Stories by Priya Patel on Medium</title>
            <link>https://medium.com/@priya-patel-78243?source=rss-af095d0e180c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 13:25:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@priya-patel-78243/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Snapshot Testing (FBSnapshotTestCase / iOSSnapshotTestCase)]]></title>
            <link>https://medium.com/globant/snapshot-testing-fbsnapshottestcase-iossnapshottestcase-8fa9cc8cbb37?source=rss-af095d0e180c------2</link>
            <guid isPermaLink="false">https://medium.com/p/8fa9cc8cbb37</guid>
            <category><![CDATA[snapshot-testing]]></category>
            <category><![CDATA[test-case]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[visual-ui-testing]]></category>
            <dc:creator><![CDATA[Priya Patel]]></dc:creator>
            <pubDate>Tue, 08 Dec 2020 07:42:31 GMT</pubDate>
            <atom:updated>2020-12-08T07:42:31.161Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ct_pJcY9gm7_1ydu.png" /></figure><h3>What it does</h3><p>FBSnapshotTestCase is renamed as iOSSnapshotTestCase. A “snapshot test case” takes a configured UIView or CALayer and uses the necessary UIKit or Core Animation methods to generate an image snapshot of its contents.</p><p>iOSSnapshotTestCase create a reference image on the predefined path and compare it to the actual image generate from the code. only 1 pixel change can be fail test case.</p><p>iOSSnapshotTestCase is helpful while you are working with multiple UI and when you mistakenly change your UI.</p><h3>Installation</h3><h3>Step 1: Create Test target for snapshot testing in project</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Q8bJ8nOZc2P4teeU.png" /></figure><h3>Step 2: Add iOSSnapshotTestCase to your project</h3><blockquote><em>Make sure to add pod in Test target, not in App target.</em></blockquote><h3>CocoaPods:</h3><p><em>Add the following lines to your podfile:</em></p><p>For Swift:</p><pre>target “AppTests” douse_frameworks!pod ‘iOSSnapshotTestCase’end</pre><p>For Objective-C: (which doesn’t contain Swift support)</p><pre>target “AppTests” douse_frameworks!pod ‘iOSSnapshotTestCase/Core’end</pre><h3>Carthage:</h3><p><em>Add the following lines to your c</em>artfile<em>:</em></p><pre>github &quot;uber/ios-snapshot-test-case&quot; ~&gt; 6.1.0</pre><h3>Step 3: Setup Test Scheme</h3><blockquote><em>Add Environment Variable in below path with mentioned Name and Value</em></blockquote><h3>App Target -&gt; Edit Scheme -&gt; Run -&gt; Environment Variables</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iSUThBf0ZowN3IhD.png" /></figure><p><strong>FB_REFERENCE_IMAGE_DIR</strong> : $(SOURCE_ROOT)/$(PROJECT_NAME)Tests/ReferenceImages</p><p><strong>IMAGE_DIFF_DIR</strong> : $(SOURCE_ROOT)/$(PROJECT_NAME)Tests/FailureDiffs</p><blockquote><em>Here we are using FB_REFERENCE_IMAGE_DIR and IMAGE_DIFF_DIR to store reference and failed/diffs images on perticular path.</em></blockquote><h3>Implementation</h3><ol><li>Subclass FBSnapshotTestCase instead of XCTestCase.</li></ol><p>2. From within your test, use FBSnapshotVerifyView or FBSnapshotVerifyViewController as per your need.</p><p>3. Run the test once with self.recordMode = true; in the test’s -setUp method.</p><p>4. Remove the line enabling record mode(self.recordMode = true) and run the test.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*E5bGE-yYZVqLXZuv.png" /></figure><blockquote><em>While you are writing multiple test case in one test method make sure to add different identifier for each of item.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*s2gSwis-7xhTVUYP.png" /></figure><p>Now you must have a question that how its work with the dynamic UI. In simple language we will make that dynamic UI to static UI. Here we will provide static text in setup method. You can provide mock data for each element.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GoVClndXFJvNnxqj.png" /></figure><p>Sometimes you can face application crash issue in setup method while adding mock text for elements. its because view couldn’t find frame. so in that case we have to add frame for view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-oKykE-PPU7eVqX9.png" /></figure><h3>Extra:</h3><blockquote><em>iOSSnapshotTestCase creates total 2 folder.</em></blockquote><blockquote><em>1) ReferenceImages_64</em></blockquote><blockquote><em>While we record image that time it will be generated here with name: FunctionName + Identifier(if added)</em></blockquote><blockquote><em>2) FailureDiffs</em></blockquote><blockquote><em>While test case will be failed it will create failure image and difference image (combination of reference and failure image)</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rbUv1yuykZwHduOY.png" /></figure><h3>Pros:</h3><p>When We creates multiple UI class in one controller that time its easy to test. No tapping through my app to get to the right view. It gives me a way to test view-related code and it can be used to visualise view states without jumping through hoops in the simulator or real devices.</p><h3>Cons:</h3><p>Test case will be failed while your reference image and current simulator device are not same. As its matching pixel to pixel.</p><h3>Conclusion</h3><p><em>FBSnapshotTestCase</em> lets us able to do a single test and instantly see the changes we make to the different states. snapshot tests are fast. Having lots of tests in an application’s test suite is no problem. If you haven’t used it yet, you should give it a try.</p><p>Reference from <a href="https://github.com/uber/ios-snapshot-test-case#carthage">GITHUB</a><br>Reference Images from <a href="https://www.raywenderlich.com/5043-ios-snapshot-test-case-testing-the-ui">Raywenderlich</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8fa9cc8cbb37" width="1" height="1" alt=""><hr><p><a href="https://medium.com/globant/snapshot-testing-fbsnapshottestcase-iossnapshottestcase-8fa9cc8cbb37">Snapshot Testing (FBSnapshotTestCase / iOSSnapshotTestCase)</a> was originally published in <a href="https://medium.com/globant">Globant</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>