<?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 rishabh agarwal on Medium]]></title>
        <description><![CDATA[Stories by rishabh agarwal on Medium]]></description>
        <link>https://medium.com/@rishabhagarwal_15261?source=rss-c76112a488c9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*IOLTZUAQGOnqDirT</url>
            <title>Stories by rishabh agarwal on Medium</title>
            <link>https://medium.com/@rishabhagarwal_15261?source=rss-c76112a488c9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 21:00:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rishabhagarwal_15261/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[Unit Testing for Powerplay]]></title>
            <link>https://medium.com/@rishabhagarwal_15261/unit-testing-for-powerplay-5a43ee6e69d9?source=rss-c76112a488c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a43ee6e69d9</guid>
            <dc:creator><![CDATA[rishabh agarwal]]></dc:creator>
            <pubDate>Thu, 02 Dec 2021 08:36:35 GMT</pubDate>
            <atom:updated>2021-12-02T08:50:31.584Z</atom:updated>
            <content:encoded><![CDATA[<p>अत्यंत दुख</p><h4><strong>Unit testing and Instrumentation testing</strong></h4><ul><li>Unit test: <br>i. done on business logics ie MVVM mainly<br>ii. Need to setup CI command line<br>iii. JUnit5 framework<br>iv. <strong>Mockito</strong> (Java) or more prominently used <strong>MockK</strong>(kotlin)… Mockk provides kotlin multi-platform support (<a href="https://tonisives.com/blog/2020/06/03/testing-with-mockk-and-koin/">https://tonisives.com/blog/2020/06/03/testing-with-mockk-and-koin/</a>)</li><li>Instrumentation test:<br>i. Testing on UI part, views and activity lifecycles<br>ii. Long time to run<br>iii. <strong>Expresso</strong> is used mostly. (also helps in testing deeplinks)</li></ul><h4>Mockito vs RoboElectric:</h4><p>Mockito alone can cover most cases.</p><p>However, Roboelectric can also provide limited operations on Android Component such as Activity or Fragment in <strong>Unit Test</strong> (not instrumentation test, which has no dependency on Android SDK), which does not require any emulator or devices and is considerably faster than instrumentation tests.</p><p>Use Mockito for unit test and Espresso for UI test since they are semi-official test frameworks for Android.</p><p>Add Roboelectric in your Unit Test if there are some dependencies on Android SDK</p><h4>Dagger or Koin for Unit testing</h4><p>We planned on shifting to dagger, therefore that needs to be finalised before proceeding… dagger has bigger user support than koin</p><h4>Procedure</h4><ul><li>we should first write unit tests for view models which mainly have Retrofit and DAO mocks…</li><li>Create a UnitTestBase class which provides success and error response</li><li>It is generally recommended to create a Dagger component in your tests to instantiate objects, whether that is a larger test component for many tests or a small focused test component for the individual test.</li></ul><h4>Important Links</h4><ul><li>Unit testing with mvvm+DI+retrofit: <a href="https://medium.com/@sreeharikv112/android-unit-testing-clean-code-architecture-with-mvvm-73eb2992cab7"><em>article</em></a></li><li>Instrumentation testing with above: <a href="https://medium.com/@sreeharikv112/android-instrumentation-testing-with-clean-code-architecture-and-mvvm-5df4615f0e4a"><em>article</em></a></li><li>Good Article for understanding: <a href="https://www.smashingmagazine.com/2018/07/improving-test-coverage-android-app-mockito-espresso/"><em>article</em></a></li><li>Unit testing for modular apps (<a href="https://github.com/tsaha-cse/SkyTracker">https://github.com/tsaha-cse/SkyTracker</a>)</li></ul><h4><strong>Todo:</strong></h4><ol><li>Find good open source projects having unit testing for MVVM+DI</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a43ee6e69d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>