<?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 Devesh Bajpai on Medium]]></title>
        <description><![CDATA[Stories by Devesh Bajpai on Medium]]></description>
        <link>https://medium.com/@deveshbajpai_3123?source=rss-65ba178b4f60------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*zgT3q9p6LyEcgjBY</url>
            <title>Stories by Devesh Bajpai on Medium</title>
            <link>https://medium.com/@deveshbajpai_3123?source=rss-65ba178b4f60------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 20:57:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@deveshbajpai_3123/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: Test behaviors not functions]]></title>
            <link>https://medium.com/@deveshbajpai_3123/unit-testing-test-behaviors-not-functions-98a046879844?source=rss-65ba178b4f60------2</link>
            <guid isPermaLink="false">https://medium.com/p/98a046879844</guid>
            <category><![CDATA[bdd]]></category>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[agile-testing]]></category>
            <dc:creator><![CDATA[Devesh Bajpai]]></dc:creator>
            <pubDate>Fri, 23 Nov 2018 09:13:20 GMT</pubDate>
            <atom:updated>2018-11-23T09:13:20.946Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*O9nABqTOLRxKnrnMvwU2Pg.jpeg" /></figure><p>We write a lot of unit test for our code to make sure that our new changes does not break existing behavior of the application.</p><p>We write unit test to cover each and every function and branch of our code to get high coverage, and it is assumed, that high code coverage is indicator of application is covered and if unit test are all green application is fine.</p><p>Managers are also happy to see green coverage bar shooting above 80%.</p><p>But this assumption is wrong, high code coverage doesn&#39;t mean that your application behaviors are covered.</p><h3>Defining “Unit” in Unit Testing</h3><p>Most of us misunderstood the term “ <em>unit “ in </em>unit testing. Somehow it became a general practice to think unit testing means testing all your method or functions.</p><p>So when we are asked to write a unit test for our code we write the test for all the methods in our code providing stubs and mock for other parts of your application to which the method interact.</p><p>Its because most of the examples in book and online tutorials teach in similar way where they test a create a small sample application and test its function.</p><p>By definition</p><p><em>“ unit testing is a software testing method by which individual units of source code, sets of one or more computer program modules together with associated control data, usage procedures, and operating procedures, are tested to determine whether they are fit for use ”</em></p><p><em>Source: Wikipedia</em></p><p>Pay attention to below lines</p><p><em>“ individual units of source code, sets of one or more computer program modules “</em></p><p>In a real world application behavior is not determined by single function, but functions in different components executing one after other in some sequence will actually result in some application behavior.</p><p>By testing functions of our code in isolation we make sure they are behaving as expected and then we derive the conclusion that because individual function are working properly the application behavior that depend on these functions running in some order should also work.</p><p>But that’s not always true.</p><p>Your individual function may work as intended but when run in required sequence they may not produce the desired behavior.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*kJW_tg0HkLqPvH_hG8oKcA.png" /></figure><p>They may be all green but your behavior may be broken. At the end of the day what you really want to test is the behavior of our application.</p><p>Another issue with tests written for functions and not for behaviors is that these type of tests are highly dependent on the implementation and are very fragile. When ever you refactor your code they will break even if the behavior of your application does not change. This will create fear in developer and he will resist from refactoring.</p><p>Instead of creating fear in developer minds unit test must support developers and make them fearless by giving them confidence application behavior is not broken whenever they add or refactor code.</p><h3>BDD Approach</h3><p>Behavior driven development recommends all team members including developers, testers and product owners to discuss at start of sprint and decide the behaviors that will be added to the application in that sprint and come up with scenarios and examples for those behaviors.</p><p>This will help developers in writing unit test for the expected behavior.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98a046879844" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Agile Testing: Test Pyramid and BDD]]></title>
            <link>https://medium.com/@deveshbajpai_3123/agile-testing-test-pyramid-and-bdd-842a155d0337?source=rss-65ba178b4f60------2</link>
            <guid isPermaLink="false">https://medium.com/p/842a155d0337</guid>
            <category><![CDATA[agile]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[testing-pyramid]]></category>
            <category><![CDATA[bdd]]></category>
            <dc:creator><![CDATA[Devesh Bajpai]]></dc:creator>
            <pubDate>Thu, 22 Nov 2018 18:46:15 GMT</pubDate>
            <atom:updated>2018-11-22T18:46:15.883Z</atom:updated>
            <content:encoded><![CDATA[<p>In the Agile world, we keep adding small features to our application in each sprint. While adding new features we also want to be sure that we are not breaking any previously developed feature.</p><p>For that, we write different types of automated test like unit, integration or component, API, and e2e UI tests. These automated test will run every week, every day or some test may even run after every commit. Successfully passing of these test help us to have the confidence that our recent push has not broken anything that was working earlier.</p><p>A better way to distribute these test we must follow the Testing Pyramid concept.</p><h3>Testing Pyramid</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B5m_7E1isP8fGgyScc4klQ.gif" /><figcaption>The testing pyramid is a concept developed by Mike Cohn, described in his book Succeeding with Agile.</figcaption></figure><p>Tests on top of the pyramid provide higher confidence but are slow, flaky and require higher effort in maintenance and debugging for the cause of failure.</p><p>As we go downwards test becomes more focused and less dependent on external factors. They execute very fast and provide better detection for the reason of failure.</p><p>Unit tests are less dependent on external factors hence more reliable and will produce same results on repetitive executions.</p><h3>E2E UITest</h3><p>E2E or UI tests give high confidence to the team as they mimic the user and test the application like an actual user with real calls to backend servers.</p><p>But this confidence comes with a cost of slowness, high maintenance, and effort involved in investing for the cause of failure.</p><p>Testing pyramid suggests writing very few e2e tests. We should write end to end tests only for the major workflows and core functionalities of our application.</p><p>It may feel that translating your manual test cases into automated scripts and let machines execute them will help you, but in reality, the shortcomings of e2e like slowness, flakiness, and effort involved in maintenance and failure detection will actually slow you down.</p><h3>Integration Test</h3><p>Integration test target components of different domain that communicate with each using standard message formats.</p><p>Integration Test test the interface between two components isolating all other dependencies. Mostly they should focus on</p><ul><li>Input parameters</li><li>Expected resulting outputs</li><li>Maximum time to receive a response</li><li>Parsing inputs</li><li>Error handling</li><li>Proper response formatting</li></ul><h3>Unit Test</h3><p>Unit tests should be the biggest chunk of all your test.</p><p>Unit test has no external dependencies hence it&#39;s easy to set up the initial state for our test and get faster feedbacks.</p><p>Unit tests are ideal for testing multiple scenarios of individual functionalities that include different permutations and combinations of input data, initial state, and edge cases.</p><p>With unit tests, we must test the independent behavior of your application in isolation by mocking or stubbing any external calls. An independent behavior of your application may involve multiple functions or components within the same domain.</p><h3>Manual Test</h3><p>Manual testing should be done for user acceptance, usability issues, and exploratory testing.</p><h3>BDD</h3><p>BDD stands for Behaviour driven development which is an extension to TDD (Test Driven Development).</p><p>BDD involves discussion involving developers, testers, and PO at the start of the sprint about the feature that needs to be developed. Everyone should decide how the feature will behave and come up with scenarios and examples.</p><p>These scenarios with examples are then recorded in plain English like sentences so that it is understood by everyone. Mostly gherkins syntax is used to record these scenarios in Given, When Then (GWT) format.</p><p>GWT format with examples and data tables provide clear understanding of the behavior to everyone and help in developing code and writing automation test scripts.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=842a155d0337" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>