<?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 Esraa Ibrahim on Medium]]></title>
        <description><![CDATA[Stories by Esraa Ibrahim on Medium]]></description>
        <link>https://medium.com/@EsraaIbrahim?source=rss-f7fbc4821c2c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*qhCN4F1PL7OKpAcOvAxNcw.jpeg</url>
            <title>Stories by Esraa Ibrahim on Medium</title>
            <link>https://medium.com/@EsraaIbrahim?source=rss-f7fbc4821c2c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 10:58:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@EsraaIbrahim/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[Android: How to Unit Test ? — Part 1]]></title>
            <link>https://medium.com/aqarmap-engineering/android-how-to-unit-test-part-1-807a7d69d40b?source=rss-f7fbc4821c2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/807a7d69d40b</guid>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[tdd]]></category>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Esraa Ibrahim]]></dc:creator>
            <pubDate>Thu, 08 Aug 2019 10:08:10 GMT</pubDate>
            <atom:updated>2019-08-08T10:08:10.204Z</atom:updated>
            <content:encoded><![CDATA[<h3>Android: How to Unit Test ? — Part 1</h3><p>When you start developing Android apps your main target will always be delivering a working application. But when your application became bigger it also became harder to test. You will lose your confidence that the functionality you added didn’t affect any other part.</p><p>At this point you start to think if there is something that can help you be confident that any added new features doesn’t break your app. The answer is <strong>Testing</strong>.</p><blockquote><em>Test code is just as important as production code. It is not a second-class citizen. It requires thought, design, and care. It must be kept as clean as production code.<br></em><strong><em>– Robert C. Martin, Clean Code</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f6sxzZfvFKHSiK0pZDKwiQ.png" /></figure><p>Testing is divided into 3 categories:</p><p>1. Unit tests:</p><ul><li>Small tests that validate your app’s behavior by testing one class per time.</li><li>Testing of units of code.</li><li>Each unit test tests specific feature.</li><li>Requires JVM environment</li></ul><p>2. Integration tests:</p><ul><li>Medium tests that validate interactions between levels of the stack within a module, or interactions between related modules.</li><li>Testing of how pieces being put together</li><li>Tests application behavior</li><li>Often involves testing of UI</li><li>Requires Android environment (emulator/physical device)</li></ul><p>3. UI tests:</p><ul><li>Large tests that validate user journeys spanning multiple modules of your app.</li><li>Slower and are less isolated so are not run as often and can be more flaky than integration and unit tests.</li><li>Requires Android environment (emulator/physical device)</li></ul><p>We will be talking about <strong>Unit Tests</strong>, and how to make sure that your logic do what should be done.</p><p>You will find the unit tests at the <strong>test </strong>folder, Each unit test is a separate method annotated with @Test. This for example is asserting that 2+2 = 4. Assert used to indicate expected results. And fails test when expectation not met.</p><pre>class ExampleUnitTest {<br>    @Test<br>    fun addition_isCorrect() {<br>        assertEquals(4, 2 + 2)<br>    }<br>}</pre><p>Tests grouped in classes for organization convenience and that allows execution grouping, and setup/teardown grouping.</p><p>There are times when we need to run specific operations before/after each test, Thus we can use @Before and @After annotations.</p><pre>@Before<br>fun setUp() {<br>    // Test pre-processing (for ex. initialization)<br>}<br><br>@After<br>fun tearDown() {<br>    // Test post-processing (for ex. reset values)<br>}</pre><p>And If you need to run operations once per class before/after all tests you have @BeforeClass, and @AfterClass annotations.</p><blockquote><em>Tests preserve and enhance the flexibility, maintainability, and reusability of the production code. If you let the tests rot, then your code will rot too. Keep your tests clean.<br></em><strong><em>– Robert C. Martin, Clean Code</em></strong></blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FVJi2vmaQe6w%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DVJi2vmaQe6w&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FVJi2vmaQe6w%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c470271013265962f6c1e98830d2d71e/href">https://medium.com/media/c470271013265962f6c1e98830d2d71e/href</a></iframe><p>References:</p><ol><li>Clean Code [CH 9: Unit Tests]</li><li><a href="https://developer.android.com/training/testing">https://developer.android.com/training/testing</a></li><li><a href="https://codelabs.developers.google.com/codelabs/android-testing">https://codelabs.developers.google.com/codelabs/android-testing</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=807a7d69d40b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aqarmap-engineering/android-how-to-unit-test-part-1-807a7d69d40b">Android: How to Unit Test ? — Part 1</a> was originally published in <a href="https://medium.com/aqarmap-engineering">Aqarmap Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>