<?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[quiQUA - Medium]]></title>
        <description><![CDATA[the official quiQUA blog - Medium]]></description>
        <link>https://medium.com/blog-quiqua?source=rss----fa948f42aa09---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>quiQUA - Medium</title>
            <link>https://medium.com/blog-quiqua?source=rss----fa948f42aa09---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 12:48:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/blog-quiqua" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Be A Tester. Save The World.]]></title>
            <link>https://medium.com/blog-quiqua/be-a-tester-save-the-world-420c8a3771d5?source=rss----fa948f42aa09---4</link>
            <guid isPermaLink="false">https://medium.com/p/420c8a3771d5</guid>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[quality-assurance]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[Priyansh Shandilya]]></dc:creator>
            <pubDate>Fri, 21 Jun 2019 08:55:56 GMT</pubDate>
            <atom:updated>2019-07-02T17:28:43.866Z</atom:updated>
            <content:encoded><![CDATA[<p>“<em>Thanks for raising the issue, buddy. This bug was a potential blocker.</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*L9b569id68Qw6_iVRdBjqg.png" /></figure><p>I have been a Test Engineer throughout my professional life. With a few years of experience under my belt, I think it is the right time to reflect upon my career and although it’s a small issue, it’s worth discussing as to why I chose to be a Test Engineer and could I have chosen some other “<em>better”</em> option.</p><p>For me, being a Test Engineer is not by chance, it’s a choice I made. Some people might think the other way around that it is a compromise and may have their own justified reasons, which I am not against. I have my own reasons, although they differ from what most people (or at least the few I know) think. Now, I don’t promise to change the way you think, but hear me out. So, fasten your seat belts and let’s try to bust some stereotypes people have about the testing role :</p><p><strong>It’s just about playing with the apps.</strong></p><p>Really? Rethink, my friend. Gone are the days when it was all about playing with the app. It’s time to show your metal to the developers. Today, you have to be analytical, have an approach which bangs on the bug and race through the conventional scenarios, and yet it’s just half done. Call the bug out, be expressive and communicate. Convince the developer to acknowledge the bug, get it fixed and recheck it. Phew, still playing?</p><p><strong>Hello non-coder, go be a Tester.</strong></p><p>Excuse me, what? Our industry has moved beyond the record and playback thing. It’s the automation era and mind you, in this era, testers are supposed to read the code, understand the code <strong>and</strong> write the code. Almost all of the testing nowadays is dependent on automation. From a basic app launch to complex test scenarios mimicking human gestures, it’s all being automated. Needless to say, I am in no way undermining the vital role played by manual testers, but the idea is to automate the menial tasks to open up quality work for them.</p><p><strong>But you know, developers will always have an upper hand.</strong></p><p>Well, okay, I am not denying the fact that developers do have a slight upper hand and why should they not have it? After all, they are the ones who are actually writing the code. Nonetheless, that’s what the defining area is for a developer and a tester. Be a tester who works with a developer and strives to bring out the perfection. Got connected with the opening statement of the blog? No? Let’s make it gentlemen style; in a cricket match, can you say batsmen are superior to bowlers? Well yes, when the team is batting. But what, when the same team is fielding? You got it, I hope.</p><p><strong>You can start testing when we are done coding.</strong></p><p>Indeed, you must have heard about a term known as “<em>show-stopper</em>”. Anyhow, let me tell you, the more mature the bug gets, the harder it becomes to pluck it. The testing team is ideally involved right with the inception of the codes, at each level, working with the developers, figuring out potential bugs as early as possible and getting them fixed. Trust me, it’s a tester who gives developers confidence to proceed further and backs him at every stage of development until release and then post-release. So friend, don’t start without us.</p><p><strong>Find a bug, log it and move aside.</strong></p><p>A big, big no. A tester’s role is not just to report a bug. Although, at the very core, this is exactly what he/she is supposed to do. But apart from that, you have a huge responsibility to make sure that the product which is going in the market is functioning exactly the way it is supposed to. And it’s not as easy as it sounds. It’s a big thing, the product once launched is directly going to hit the company’s business, both in terms of revenue as well as market value. And it’s you who will be giving the final green signal to the product release. Close your eyes for a second and absorb what you just read. It’s <strong>YOU</strong>. And that’s the reason I said, be a Tester, save the world.</p><p>Well, I hope you got a fair idea as to why just after spending a little over 2 years as a software tester, I absolutely love it. And by no way, I am switching to any other “<em>better</em>” option anytime soon.</p><p>With this, let’s bring our first reflection to an end. I hope you liked it. I cannot wait to talk to you guys about automation and its many perks.</p><p>In the meanwhile share your experience in the industry as a software test engineer. Your suggestions are welcome and I would love to address them in my upcoming blogs.</p><p>And with <a href="https://www.linkedin.com/company/14539604"><strong>quiQUA</strong></a>, I have found a platform to be a better Test Engineer and explore myself in uncharted territories under the guidance of some great mentors. If you are interested in working with us to create an impact in the Indian startup space with test and release solutions, please checkout our <a href="https://www.quiqua.in/careers"><strong>career</strong></a><strong> </strong>page.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=420c8a3771d5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/blog-quiqua/be-a-tester-save-the-world-420c8a3771d5">Be A Tester. Save The World.</a> was originally published in <a href="https://medium.com/blog-quiqua">quiQUA</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google I/O 2019 takeaways]]></title>
            <link>https://medium.com/blog-quiqua/google-i-o-2019-takeaways-dcfeb2bc4244?source=rss----fa948f42aa09---4</link>
            <guid isPermaLink="false">https://medium.com/p/dcfeb2bc4244</guid>
            <category><![CDATA[gradle]]></category>
            <category><![CDATA[google-play]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[release-engineering]]></category>
            <dc:creator><![CDATA[quiQUA]]></dc:creator>
            <pubDate>Wed, 29 May 2019 09:48:47 GMT</pubDate>
            <atom:updated>2019-05-29T12:30:15.419Z</atom:updated>
            <content:encoded><![CDATA[<h3>Chapter II: Build &amp; Release</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*eFhf9jLd9nrB1l_j7jb82Q.gif" /></figure><p>We talked about the Testing related takeaways from this year’s I/O event in the previous <a href="https://medium.com/blog-quiqua/https-medium-com-blog-quiqua-google-i-o-2019-takeaways-chapter-i-30b03a14bd72">blog</a>. We ended with a promise to follow up with Build and Release related announcements, and here we are. We try to portray a succinct summary of these talks in this chapter. Let’s see them topic by topic :</p><p><strong>Customisable delivery and easy sharing of test builds</strong></p><p>A plethora of new features were announced with respect to app bundles :</p><ol><li><strong>In-app updates: </strong>2 flavours for in-app updates were announced. <strong>Immediate</strong> and <strong>Flexible</strong>. With Immediate, the user is given a notification for a new update and on acceptance, Google Play manages the UX and the flow. With Flexible, once the user accepts for the update, the control is returned back to the application and Play notifies the application on update completion. The app has full control over the flow.</li><li><strong>Conditional delivery: </strong>With this, the developer can specify the conditions under which a feature would be delivered as part of app installation and which feature would be left out. You can set conditional delivery for modules based on 3 factors — Geolocation (country), minSDKVersion and device feature (eg: VR headset support)</li><li><strong>On-Demand delivery: </strong>You can now install or remove modules on demand. For example, you can now remove the on-boarding flow once the user has been on-boarded to the application. Vice-versa, you can install the on-boarding module if the need be.</li><li><strong>Asset delivery for games: </strong>Introduction of asset packs. Now you can create multiple asset packs and choose to ship only certain assets with your game. This allows to reduce the size of your app and provide assets on a need basis.</li><li><strong>Internal App Sharing :</strong> Now you can share app bundles with your test/dev team directly. With Internal App sharing, you can upload your app bundle to Play, which would then generate a shareable link that can be propagated across the team. With this link, you can install the app on your device and perform testing. <br>This test bundle is served and hosted by Play and is not a part of the release track. The uploader doesn’t have to be a Play console member. The app is signed with a test certificate. A unique version isn’t required. You can give your custom version.</li></ol><p><strong>Google Play</strong></p><p>Apart from the new features mentioned above, a few other enhancements to Google Play have been made.</p><ol><li>In addition to efficiency and modularity, the Android App Bundle also now offers increased security with the launch of <strong>app signing key upgrade for new installs</strong>. With this feature, you can upgrade the cryptographic strength of your signing key for new installs and their updates on Google Play. Many developers sign their apps with keys generated a long time ago, and this new feature is the only backwards-compatible way to increase their strength.</li><li><strong>Core Metrics Refresh:</strong> To better understand your churn, including data on returning users, automatic change analysis, metric benchmarking.</li><li><strong>Change in average rating calculation:</strong> More weight would be given to most recent ratings. This would be available by August.</li><li><strong>Auto-suggest for replies to reviews:</strong> This is an extension from Gmail’s auto-suggestions.</li></ol><p><strong>Features to help your business grow</strong></p><ol><li>There would be <strong>custom listing by install state</strong> under 3 categories — Not installed, Uninstalled, Currently installed. You can target custom messages according to these categories.</li><li>Additionally, there will be <strong>custom listing pages for Pre-registration and Pre-registration rewards</strong>, which let you incentivise players for signing up for notifications prior to the launch.</li><li>Early access to a <strong>‘Subscribe and Install’</strong> feature.</li></ol><p><strong>Tools to optimise app size and boost installs</strong></p><ol><li><strong>Improved uninstall wizard</strong>: Smart suggestions based on app size and usage will be provided.</li><li><strong>Optimised installs:</strong> Play has now reduced new installs size by 10% and up-to 85% for app updates.</li><li><strong>Optimised native library (coming soon): </strong>Game engines are common among app games. So a base common native library would be provided on which your app specific assets can be added thus reducing apk size.</li><li><strong>Peer-to-peer transfers:</strong> Quite a few apks get shared via P2P applications among users. However, apk shared over P2P is not authenticated by the play store. New Play API announced which these P2P app developers can integrate. With this, the compatibility for apk shared would be checked.</li><li><strong>Data at no cost (coming soon):</strong> Ongoing tie-ups with mobile operators to provide access to PlayStore without any data cost incurred.</li><li><strong>Update in existing bundle tool:</strong> Now you can measure apk download size and the actual size on the device post install by a customisable statistics page in Play console.</li><li><strong>Devices with low free storage (coming soon):</strong> Metrics for uninstalls on devices due to low free storage. Also, analysis of devices with low storage on which your app is currently installed.</li><li><strong>Analysis of app size</strong> over time.</li><li><strong>App size breakdown</strong> by its contents.</li><li><strong>Suggestions</strong> for <strong>optimisations for app bundles</strong>.</li></ol><p><strong>Improving app performance by benchmarking</strong></p><p><strong>Jetpack Benchmark Library</strong> was introduced. This is our personal favourite. It is currently in alpha stage. It measures code performance and is integrated with Android Studio. It supports Kotlin as well as Java. With Studio 3.5, you can create benchmark modules in your project.</p><p>There’s a <strong>Gradle</strong> plugin for the same. The plugin helps you to pull benchmark reports when you run<strong><em> gradlew</em></strong>. Along with that, there are some Gradle tasks added for <strong>CPU clock stability</strong>. The test runner has some baked-in tricks to stabilise benchmarks.</p><p>There is <strong>addition for proguard rules</strong> as well. The template supplies pre-configured proguard rules. The idea is to mimic production behaviour and that’s why they bundle these rules along. Keeping that in mind, they are providing detailed logs with apt warnings. Say you run in debug mode. This defeats the purpose of benchmarking as it is expected to work slow in debug mode. Hence the flashy warning in logs which running benchmarking.</p><p>The benchmarking module is written to account for <strong>ramp-up period</strong> as well. In short, benchmark spins loop for minimum 250ms and starts measuring only once the performance of the app stabilises.</p><p>The module also has an API to lower the max CPU clock to prevent CPU throttling to prevent inconsistencies due to device OS functioning.</p><p>You can watch the complete <a href="https://www.youtube.com/watch?v=ZffMCJdA5Qc&amp;list=PLOU2XLYxmsILVTiOlMJdo7RQS55jYhsMi&amp;index=174&amp;t=0s">talk</a> on how to get started with your first benchmark test.</p><p><strong>Improving build time execution with Gradle</strong></p><p>There were a couple of talks on how to improve your android builds with Gradle. I recommend you to watch the talks for deeper understanding. Here, let’s see the highlights of the talks.</p><ol><li><strong>R classes will directly be compiled </strong>to class file now. The intermediate Java file will not be generated.</li><li><strong>Workers:</strong> New API called workers introduced. It allows for safe, parallel and asynchronous execution. You can get the detailed working <a href="https://guides.gradle.org/using-the-worker-api/">here</a>.</li><li><strong>Faster artifact transform APIs:</strong> It is used for dexing and enables caching of pre-dexed libraries.</li><li><strong>Lazy task configuration: </strong>It helps you to configure only the required tasks at build time.</li><li><strong>Incremental Annotations processing:</strong> Implementation of the ability to have incremental compilation even when there is annotation processor on class pass. This is supported for Kotlin as well.</li><li><strong>Improvement in sync inside studio:</strong> Dependency resolution is only done once after you load the project in studio.</li><li><strong>Apply changes:</strong> This enables you to make small edits and deploy while keeping your app in state. It no longer modifies your apk during builds.</li><li><strong>Improved build output window</strong>: UI and Parser has been improved to better highlight the cause of your failure.</li><li><strong>Build speed attribution (coming soon):</strong> The idea is to provide clear information about Gradle plugins and tasks causing the build to slow down.</li></ol><p>Well, this is it. We have tried to cover all test and release related talks. The summary just paints a brief picture and we recommend that you check out each of these talks individually for deeper analysis. You can check out our previous <a href="https://medium.com/blog-quiqua/https-medium-com-blog-quiqua-google-i-o-2019-takeaways-chapter-i-30b03a14bd72">blog</a> to see the Test related announcements.</p><p>Despite our best efforts, we might have missed out on some points here and there(the chances of that happening is 1 in 14,000,605). If we did hit that possibility AND you happen to notice it (that would indeed be the mother of all possibilities), let us know in the comments below and we would include the same in the blog.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dcfeb2bc4244" width="1" height="1" alt=""><hr><p><a href="https://medium.com/blog-quiqua/google-i-o-2019-takeaways-dcfeb2bc4244">Google I/O 2019 takeaways</a> was originally published in <a href="https://medium.com/blog-quiqua">quiQUA</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google I/O 2019 takeaways]]></title>
            <link>https://medium.com/blog-quiqua/https-medium-com-blog-quiqua-google-i-o-2019-takeaways-chapter-i-30b03a14bd72?source=rss----fa948f42aa09---4</link>
            <guid isPermaLink="false">https://medium.com/p/30b03a14bd72</guid>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[google-io-2019]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[quiQUA]]></dc:creator>
            <pubDate>Mon, 27 May 2019 08:29:53 GMT</pubDate>
            <atom:updated>2019-05-29T08:24:11.219Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Chapter I: Test</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*eFhf9jLd9nrB1l_j7jb82Q.gif" /></figure><p>Google conducted its coveted annual developer conference, I/O, from 7th-9th of May. The conference saw a staggering 177 sessions (including the keynotes and the fireside chats). As always, google uploads all these sessions on YouTube. So convenient for us folks, who can’t attend this conference, to sit at home and watch them — either live or later at our convenience.</p><p>But but but … can you really go through all these talks where each talk ranges from 35–60 minutes? That’s the catch, isn’t it.</p><p>We, at <a href="https://www.quiqua.in/"><strong>quiQUA</strong></a>, strive to keep ourselves updated with all the latest <em>‘whats’</em> and <em>‘hows’ </em>with a focus on test and release domain. So to make your life a bit easier, we have shortlisted all the talks pertaining to test and release domain from the I/O and bring to you a shorthand version of these talks.</p><p>Now mind you, these are just an abstraction of the talk — a bird’s eye view. We will be adding the links to the videos as well. For in-depth details, you can always go through the complete talk itself.</p><p>Let’s browse through these talks then, shall we?</p><p><strong>Puppeteer<br></strong>Puppeteer has been gaining traction across the test (and dev) community for quite some time now. It is a node.js library that provides high level APIs to control headless chromium. Quite a few announcements were made for this tool :</p><ol><li><strong>Puppeteer for Firefox</strong> has been launched on experimental basis. Currently, it supports ~90% of puppeteer APIs.</li><li>New API for <strong>Browser Context</strong> has been added — It is based on Incognito mode and hence the sessions are isolated and prevents the user from launching a new browser session for each test case. This would save considerable amount of time.</li><li><strong>waitForX()</strong> API has been added to lessen the flakiness of tests due to network connections or javascript running in the background. The ‘X’ could be selector, request, response. More details for this API can be seen <a href="https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md">here</a>.</li><li><strong>Mobile support </strong>has been added. The API <a href="https://github.com/GoogleChrome/puppeteer/blob/v1.6.2/docs/api.md#pageemulateoptions"><strong>emulate()</strong></a> provides an extensive emulation including User Agent, DPI, touch support. This mimics the physical device and adds robustness to emulator testing. Google has added support for a staggering 100+ devices.</li><li>Support to test with <strong>Service Workers</strong> has been added. Now you can attach to service workers and perform cache testing from browser’s perspective.</li><li>The API <a href="https://pptr.dev/#?product=Puppeteer&amp;version=master&amp;show=api-browsercontextoverridepermissionsorigin-permissions"><strong>overridePermissions()</strong></a> to play around with an array of permissions for the website under test. This could be geolocation, camera, microphone etc</li><li>In addition to Network monitoring, support for <strong>network modification</strong> has been added. You can now snoop on the request and send in your own response. This could effectively help you mock out the entire server and test just the UI</li><li>The big one for us though was the <strong>accessibility support</strong>. You can get your website’s accessibility snapshot that renders an accessibility tree which is close to what’s read or displayed</li></ol><p><strong>Firebase<br></strong>Firebase is a mobile and web development platform. In a nutshell, firebase enables you to build better apps, monitor app quality and grow your business. While google announced enhancements in all three domains, we will just be focussing on the app quality perspective.</p><ol><li><strong>Local emulators</strong> for firebase and Realtime database was launched in October. This emulator suite has been extended to <strong>include cloud functions</strong>. This would help you to test your application locally without connecting to a remote database</li><li>Support for <strong>Wear OS, Android Q, Android App Bundles</strong> have been added to Firebase Test Lab</li><li><strong>Game testing</strong> has been improved by <strong>augmenting the same ML kit</strong>. Instead of testing the game by random taps, Firebase’s crawler makes intelligent decisions as to where to tap to form a game loop</li><li><strong>Flaky test detection</strong> — To give the user a better sense of their tests’ quality</li><li><strong>BigQuery Integration</strong> — Performance monitoring data can now be exported into BigQuery so that you can run your own analysis on the data</li><li><strong>Performance analysis for web applications</strong> has been launched</li><li><strong>Integration of Crashlytics</strong> beta with Firebase called App Distribution. The plan is to bid farewell to Fabric by March, 2020.</li><li><strong>Support for Customisable Velocity alerts</strong>. This can be configured in the settings under the Crashlytics console.</li></ol><p><strong>Improve app &amp; game quality with Play Console tools</strong></p><p>The 2 tools in Play console — <strong>Pre-Launch report (PLR)<em> </em></strong>and<strong><em> </em>Android Vitals</strong> have been instrumental in monitoring and improving app quality over time. A few enhancements were announced for the same :</p><ol><li><strong>Non-SDK interface restrictions</strong> in Android Q. Interfaces not in use would be restricted to avoid runtime crashes</li><li>You can now see<em> </em><strong>Android Compatibility issues</strong> right in the report (errors and warnings) with details</li><li>You can now add a <strong>test credentials</strong> for your application under settings in PLR. This would allow the crawler to test the app better beyond the login page</li><li>For game applications, you can now create a <strong>game loop for key test path</strong>. Instead of random clicks, it would test the game loop defined by you. Details <a href="https://firebase.google.com/docs/test-lab/android/game-loop">here</a></li><li>2 new tools added in Android Vitals since last I/O — <strong>Startup time</strong> and <strong>Permissions</strong></li><li><strong>Peer benchmarking</strong> introduced. Developer can now select 8–12 peers and benchmark their application against their peers for all Android Vitals data as well as for public metrics like your ratings</li><li>You can now sign up for <strong>Vitals email alerts</strong> as well</li><li>Added support for <strong>App size metrics</strong> and reports. You can now gain insights about your app size in Android Vitals, including download size, size on device, changes compared to peers over time. Tailored optimisation suggestions will also be provided. Along with this, the app’s complete breakdown is provided — code v/s resources v/s data libraries</li><li><strong>PLR and Android Vitals have been linked</strong> to provide better debug analysis. Screenshots and videos of test flows provided in PLR</li></ol><p>This concludes the quality related developments announced by Google at this year’s IO event. While we have tried to cover all relevant points from the plethora of talks, we understand this is not sufficient for you to dive deep into a particular topic. If need be, we encourage you to watch the talk.</p><p>Irrespective, we hope that the above gist helps you with quick takeaways. Keep a tab on this space as we will share the follow-up chapter on <strong>Build &amp; Release</strong> engineering updates soon.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30b03a14bd72" width="1" height="1" alt=""><hr><p><a href="https://medium.com/blog-quiqua/https-medium-com-blog-quiqua-google-i-o-2019-takeaways-chapter-i-30b03a14bd72">Google I/O 2019 takeaways</a> was originally published in <a href="https://medium.com/blog-quiqua">quiQUA</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unit testing your API Controllers — A code walkthrough]]></title>
            <link>https://medium.com/blog-quiqua/https-medium-com-blog-quiqua-unit-testing-your-api-controllers-a-code-walkthrough-44439728e0fa?source=rss----fa948f42aa09---4</link>
            <guid isPermaLink="false">https://medium.com/p/44439728e0fa</guid>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[software-test-design]]></category>
            <category><![CDATA[api-testing]]></category>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Kumar Pratyush]]></dc:creator>
            <pubDate>Sun, 19 May 2019 11:27:09 GMT</pubDate>
            <atom:updated>2019-05-19T12:16:18.308Z</atom:updated>
            <content:encoded><![CDATA[<p>Unit testing your API Controllers — A code walkthrough</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fch7H19TGb4qOtr-3ymRLA.png" /></figure><p>In the <a href="https://medium.com/blog-quiqua/https-medium-com-blog-quiqua-unit-testing-your-api-controllers-879dbf01796f">previous blog</a> we talked about why you should be testing your API controllers with the common pitfalls that come along with it. Now, theory without a code walkthrough is like fool’s gold. Beautiful to look at, but of no relevance. (<strong>Nerd fact :</strong> The element Pyrite is commonly known as Fool’s gold)</p><p>So we ended that blog mentioning that we would follow up with a code walkthrough and voila! Here we are! Let’s get to the meat of the matter then.</p><p>For the purpose of this blog, we have created a basic <a href="https://spring.io/projects/spring-boot">spring-boot</a> based project. It’s an employee management system (a bare extraction of the supposed mammoth project). A DAO to store the employees in the organisation. A client interacts with the DAO to check the details of the employee add CRUD operations for the same.</p><p>Let’s start with the employee DAO and the employee POJO.</p><pre>@Entity<br>@Builder<br>@Data<br>public class Employee {<br><br>    @Id<br>    @GeneratedValue<br>    private Long id;<br>    private String name;<br>    private int level;<br>    private String role;<br>    private long salary;<br>}</pre><p>Then we add a service implementation to fetch the employee details. Here, we have stubbed the db connection logic and hard-coding an employee for test purpose.</p><pre>@Override<br>public Employee getEmployeeById(long id) {<br><br>    Employee employee = null;<br><br>    //Here goes your db connector which is not really important to us since we will be mocking it out<br>    //Hence we are putting dummy condition here to write our tests<br>    if (id == 1L) {<br>        employee = Employee.<em>builder</em>()<br>                .id(1L)<br>                .name(&quot;quiQUA&quot;)<br>                .level(1)<br>                .role(&quot;FTE&quot;)<br>                .build();<br>    } else {<br>        throw new EmployeeDoesNotExistException(id);<br>    }<br>    return employee;<br>}</pre><p>Finally, we add a controller to fetch the employee details via API :</p><pre>public ResponseEntity&lt;Employee&gt; getEmployeeById(@PathVariable long id) {<br><br>    Employee employee = employeeService.getEmployeeById(id);<br>    return ResponseEntity.<em>status</em>(HttpStatus.<em>ACCEPTED</em>)<br>            .contentType(MediaType.<em>APPLICATION_JSON</em>)<br>            .body(employee);<br>}</pre><p>So we have an API which returns the employee details if the employee exists, otherwise throws an exception. Let’s see how we can test the same by using @webMvcTest annotation provided by spring.</p><p>Let’s add a test file to test our controller. We will name this class as <strong>EmployeeControllerTests.</strong></p><pre>@RunWith(SpringRunner.class)<br>@WebMvcTest<br>public class EmployeeControllerTests {<br><br>    @Autowired<br>    private MockMvc mockMvc;<br>}</pre><p>Here we set jUnit’s default runner to run the tests with @RunWith annotation provided by spring. Next, <a href="https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTest.html">@webMvcTest</a> annotation tells the class to disable full auto-configuration and instead apply only configuration relevant to MVC tests.</p><p>Now we are all set to add tests. Let’s add our first happy test case.</p><pre>@Test<br>public void shouldReturnEmployeeIfExists() throws Exception {<br><br>    Employee employee = Employee.<em>builder</em>()<br>            .id(1L)<br>            .name(&quot;quiqua&quot;)<br>            .salary(10000)<br>            .build();<br><br>    Mockito.<em>when</em>(employeeService.getEmployeeById(1)).thenReturn(employee);<br><br>    this.mockMvc.perform(<em>get</em>(&quot;/employee/1&quot;))<br>            .andDo(<em>print</em>())<br>            .andExpect(<em>status</em>().is2xxSuccessful())<br>            .andExpect(MockMvcResultMatchers.<em>jsonPath</em>(&quot;$.id&quot;)<br>                    .value(1))<br>            .andExpect(MockMvcResultMatchers.<em>jsonPath</em>(&quot;$.name&quot;)<br>                    .value(&quot;quiqua&quot;));<br>}</pre><p>In above test, we first create a dummy employee object to stub out the service layer call. We are just bothered about the controllers. Next, with <a href="https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/test/web/servlet/MockMvc.html">mockMvc</a>, we perform an API call and assert the response. Here, we are asserting the status code and the response body itself. On the similar lines, you can add assertions for headers, content-type, errors, forward URLs, redirect URLs. This really opens up new dimensions for testing the logic in controllers with just enabling a slice of the entire project.</p><p><a href="https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/test/web/servlet/result/MockMvcResultMatchers.html">MockMvcResultMatchers</a> provides a plethora of APIs to test our controller response and verify for all sorts of test cases. You should check it out for more details.</p><p>Next, let’s see one more example of how we can test any exception thrown by the controller.</p><pre>@Test<br>public void shouldThrowEmployeeDoesNotExistExceptionWhenNoEmployeeExists() throws Exception {<br><br>    Employee employee = Employee.<em>builder</em>().build();<br>    Mockito.<em>when</em>(employeeService.getEmployeeById(1)).thenReturn(employee);<br><br>    this.mockMvc.perform(<em>get</em>(&quot;/employee/1&quot;))<br>            .andDo(<em>print</em>())<br>            .andExpect(<em>status</em>().isNotFound())<br>            .andExpect(MockMvcResultMatchers.<em>content</em>().string(&quot;&quot;));<br>}</pre><p>Here, we check that the status is <em>NotFound </em>and the body is empty. This would have been more meaningful if you are using custom error handling in your code with @ControllerAdvice annotation. I leave that to you as an exercise to dig deep.</p><p>So, we saw how we can bring up just a slice of your application and save a considerable amount of test sanity time. Then we saw how we can test the logic of our controllers or check the sanity of the APIs by just stubbing out the business logic.</p><p>The more you delve into it, the more use cases you would find based on your project structure. I implore you to play around with it and see how creative your tests can be.</p><p>I have run the entire code in my IDE and have also pushed the same in <a href="https://github.com/quiqua-infotech/SpringControllerTests">github</a>. Please leave comments if you find this useful. Let us know what creative tests you are writing for your controllers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44439728e0fa" width="1" height="1" alt=""><hr><p><a href="https://medium.com/blog-quiqua/https-medium-com-blog-quiqua-unit-testing-your-api-controllers-a-code-walkthrough-44439728e0fa">Unit testing your API Controllers — A code walkthrough</a> was originally published in <a href="https://medium.com/blog-quiqua">quiQUA</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unit testing your API Controllers]]></title>
            <link>https://medium.com/blog-quiqua/https-medium-com-blog-quiqua-unit-testing-your-api-controllers-879dbf01796f?source=rss----fa948f42aa09---4</link>
            <guid isPermaLink="false">https://medium.com/p/879dbf01796f</guid>
            <category><![CDATA[software-test-design]]></category>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[api-testing]]></category>
            <dc:creator><![CDATA[Kumar Pratyush]]></dc:creator>
            <pubDate>Thu, 02 May 2019 17:23:35 GMT</pubDate>
            <atom:updated>2019-05-02T17:23:35.798Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*2oq36DL_5KYKTS3uLgwHpA.png" /></figure><p>Just a couple of days back, <a href="https://www.linkedin.com/in/vivek-upreti-85530762/">Vivek</a> and I came across a difference of opinion while planning the testing strategy for a project. The project in question was a Spring Boot based web application. As we all know, Spring provides a <a href="https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller">Model-View-Controller architecture</a> to develop flexible and extensible web components. From initial analysis we found that, the project was quite structured and the multiple layers were easily discernible; and <strong>WITHOUT</strong> a single <strong>Unit Test</strong>. We started discussing the plethora of <a href="https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-testing.html">test components provided by Spring</a> for different layers.</p><p>As is with the MVC architecture, the controllers are the API gateways and are supposed to forward the request to the service layer (which is solely responsible for business logic). I suggested Vivek that we start our tests with the controller layer. The classic approach, you know. Take an API, see what all functions it hits in the service layer and write tests for them.</p><p><em>“To start off,”</em> I said, <em>“let’s write UTs for the controller layer itself first and then move on to the service layer”.</em></p><p><em>“KP, that would be wrong,’’</em> he said, <em>“We shouldn’t write tests for controller layer. The controllers do not contain any logical code. They just call functions in the lower layers (service layer).They get tested when you write your API regression tests. It is simply pointless and would lead to irrelevant tests”</em></p><p>My opinion differed as I strongly believe that unit testing the controllers can be significantly beneficial.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*kVgWAXBiU3uTLE_xZEEg-Q.gif" /></figure><p>Ideally, you don’t write any business logic in your controller layer. It is supposed to just be a handler (routing mechanism) for the API call and should simply pass on the baton to some function in the service layer. So it does sound menial and over-engineering to write tests for this layer.</p><p>However, this notion is incorrect. There is quite a lot which a controller does.</p><ol><li>It is responsible for mapping the incoming request to a function based on the API path, the HTTP method and the content type.</li><li>It then parses the incoming HTTP request and deserialises the request variables to apt Java objects.</li><li>The controller is your first line of defence. This is where your request is validated to catch faulty requests at an early stage.</li><li>The controller, post validation, would call the service layer to perform the required business logic and await a response.</li><li>On receiving the response from the service layer, the controller would deserialise the object into a JSON/HTML/XML object and create the apt HTTP response with required headers.</li><li>In all this, the controller is also the exception handler of the project. It is responsible for handling any exception and create the HTTP response accordingly.</li></ol><p>Quite a lot of work, right? So it makes sense to test the controllers thoroughly. Ideally, with integration tests, you call the API and forget about all the HTTP/S magic happening in the controller. So basically you avoid all steps and just focus on step #4. This leaves some room for untested code leading to a possibility of undiscovered bug in the code. So testing the controllers is quite beneficial. Let’s look into some of these in detail.</p><ol><li><strong>Request validations</strong> — Often we write the validation of the request object in the controller itself. We verify the sanity of the request object and then pass it on to the service layer. It doesn’t make sense to actually write an over-the-network API call just to test the object validation. You can get away with it by writing apt UTs. This ensures that you don’t have to write negative tests as part of your regression and save some considerable amount of time there. <br>Let’s take an elementary example. Say there is a username-password based login system which allows the user 3 attempts to enter correct credentials before blocking the user out of the system. To test this flow, would you make 3 API calls with incorrect mechanism to check the response of each API or have the controller unit tested to check the apt HTTP response being formed?</li><li><strong>Exception handling </strong>— The service layer is expected to handle the business logic and return a response or an exception back to the controller. The controller is responsible to handle the exceptions thrown by the service layer. Now, it is absolutely tedious to write regression to test whether the exception is being handled aptly by the controller or not. We can again just test this part by Unit tests. No need to have negative regression tests. You simply mock the service layer call and make it deliberately throw an exception and voila! Your exception handling logic is tested without bringing up the web server at all.</li><li><strong>Response validations </strong>— Just as it is with request, the response is also constructed by the controller. Once the service layer sends back a response, the controller would usually serialise into an object which complies with the contract between server and UI (JSON/HTML/XML). On top of that, there could be custom response headers being added. Once again, you wouldn’t want to hit the API to test all possible responses (positive/negative cases). Ideally, you would want to mock the service layer and check for all possible responses. <br>Let’s take an elementary example. Say there is a username-password based login system which allows the user 3 attempts to enter correct credentials before blocking the user out of the system. To test this flow, would you make 3 API calls with incorrect mechanism to check the response of each API or have the controller unit tested to check the apt HTTP response being formed?</li><li><strong>Assert fast and fail faster </strong>— API tests come with it’s own overhead. You need to bring up the entire web server, provide DB connectivity, ensure network availability. Of course they are time taking. With a growing project, your sanity time will keep increasing. In cases when you just want to check your APIs — whether the routes defined are working correctly or not, you wouldn’t want to rely on the regression. What if there was a way to bring your web server up with just the controllers. Mock all the other layers and just test whether the API is up and running or not. Well, there is a way. Spring provides the <a href="https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-testing.html#boot-features-testing-spring-boot-applications-testing-autoconfigured-mvc-tests"><strong>@WebMvcTest</strong></a> for this very reason. This allows you to bootstrap a single controller with all other layers mocked. How fun, right? Your API is up without any hassle of dependencies. Magic!</li></ol><p>Although it is a good strategy to isolate one layer of tests, it could be migrainous if not implemented in the right manner. Lets see some common pitfalls as well :</p><ol><li><strong>Over-engineer </strong>— This could happen with any approach you try to follow. You might end up relying too much on your controller UTs. Writing too many tests for less cases is digging your own grave. Keep your tests restricted. The ideal way would be to see where the particular test fits in your test pyramid. Based on criticality, you might want to move it to integration test or simply write a UT. It is subjective and varies from project to project.</li><li><strong>Costly overhead </strong>— If your tests for the controllers are not adding any additional test value or are duplicating test coverage, it would just be overhead and add development time for no benefit. Also, it adds to the maintenance weight. Your demarcation for a test case should be clear — whether it would be a unit test or an integration test. There is some scope of overlapping test cases, but quite rare.</li></ol><p>Designing your test cases is an intricate process and the incorrect decision could add your execution time without any benefits. On one hand, you should definitely write UTs to test the ‘HTTP magic’ these controllers do. On the other hand though, you should be careful that you do not completely rely on them. Integration tests are equally valuable. It is just that you can shift some of the workload from integration tests to unit tests.</p><p>So what do you guys think? I am sure you would have some differing or additional thoughts..We will be following up on this soon with a code walkthrough on how to actually write tests for your controllers. Leave comments if you want us to cover something specific.</p><p><strong>P.S. </strong>— Vivek and I did end up writing UTs for some of the controllers. ;)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*qOmp6ssa9YoXrU_9" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=879dbf01796f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/blog-quiqua/https-medium-com-blog-quiqua-unit-testing-your-api-controllers-879dbf01796f">Unit testing your API Controllers</a> was originally published in <a href="https://medium.com/blog-quiqua">quiQUA</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dev and Test codebase — A part or Apart?]]></title>
            <link>https://medium.com/blog-quiqua/dev-and-test-codebase-a-part-or-apart-e5631517620b?source=rss----fa948f42aa09---4</link>
            <guid isPermaLink="false">https://medium.com/p/e5631517620b</guid>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[automation-test-design]]></category>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[test-automation-framework]]></category>
            <dc:creator><![CDATA[Kumar Pratyush]]></dc:creator>
            <pubDate>Mon, 01 Apr 2019 15:19:39 GMT</pubDate>
            <atom:updated>2019-04-02T16:58:49.384Z</atom:updated>
            <content:encoded><![CDATA[<h3>Dev and Test codebase — A part or Apart?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8HXUxdizQr5muspl" /><figcaption><strong>To be in a live in, or not to be!</strong></figcaption></figure><p>There has been a monumental shift of paradigm from manual to automation with respect to testing a software application. With that, there has been an implicit need for automation frameworks. Conventionally, the popular school of thought has been to maintain 2 separate code bases — <strong>development</strong> and <strong>automation</strong>. Developers maintain the former while SDETs look into the latter. Theoretically, it sounds quite apt. A clear demarcation of roles and responsibilities and separation of concerns.</p><p>I too was following this norm up till now. Over time I have realised that merging your automation framework with application code is quite beneficiary. To be more specific, all kinds of tests (Unit, Functional, Integration, Regression and even UI tests) can be, and should be, accommodated under the same project as separate modules.</p><p>What are the benefits, you ask? Well, here you go :</p><ol><li><strong>Shared Resources</strong> : Constants and properties of the application code are often duplicated in automation code. Under the same hood, the common resources can be pulled in a separate module and used at both places. I personally find it terrifically cumbersome to change my string-based assertions for every identifier change that the developers would make in the application. This generally leads to false failures and additional debug time. Also, if the project supports localisation, you might have multiple tests pertaining to multiple languages. In the same repository, you can easily test all languages supported without having to duplicate the constants in the automation code.</li><li><strong>Test as you code</strong> : The biggest advantage of having both dev and test code bases in the same repository — developers don’t have to jump between projects to test their changes. Now every time a developer writes a new piece of code, he would deploy his changes and then run the automation code on the new deployment. This adds additional steps in your development phase. Not to mention the need to jump between 2 projects (or multiple if you have decided to go that way). With the same repo, dev can just run the test module against the latest code piece locally. With this, the responsibility of developer doesn’t just end at Unit tests. He is implicitly getting involved with regression and integration tests. This would also give early feedback about their code and help in catching bugs earlier.</li><li><strong>Push the onus on developers :</strong> The usual practice has been that developers would write their unit tests and the rest of the tests would be handled by testers. Why the discrimination? The logic that dev would test his/her code with unit tests and the bigger picture would be handled by automation testers because they “specialise” in testing is absolutely bogus. If the developer is writing the UTs, why is he not involved in functional or regression? The framework has been laid down by the automation testers. All they have to do is write your tests on top of it. Also, when there is new code which breaks existing tests (not unit tests), a developer is less likely to fix it if it lies in a different project. In the same repository, a developer would be running these tests themselves and are more likely to fix them on their own. Also, you could enforce git hooks to prevent check-in of code with failing tests.</li><li><strong>Better exposure to automation engineers</strong> : I have often seen SDETs stay away from application code base. “Not our domain”. “No point going there, we are bothered about automation only”. “I don’t understand the code / it is beyond my comprehension”. The idea is not to have a clear demarcation between these two roles. The idea should be to permeate through the boundaries and jump into the application code itself. It has multi-pronged benefits. It allows automation testers to help out with unit tests. Large picture though, it could be a good learning for SDETs to understand the application code design and eventually start contributing to the dev code itself.</li><li><strong>Access to DAO layers</strong> : We all agree that UI tests are costly. Yet, we all start there and then gradually shift to lower levels of tests. Having a common project allows us to write tests for functions which might not have public-facing APIs. The DAO layer and business methods can be tested without hitting the UI. All frameworks today provide an in-built server. This enables to spawn an abstraction of your application as opposed to bringing the entire mammoth up. That leads to using your web services for faster and less brittle execution.</li></ol><p>These are just some of the benefits I have found by having the automation project as a same entity. However, like any other design approach, this one has <strong>cons</strong> as well. It would be unfair to not list them. Here’s what you should be cautious about:</p><ol><li><strong>Improper separation of concerns :</strong> Code pushes could be tricky if you do not have proper separation of concerns in your project. Let’s take a trivial example. Say you merge your automation code with your application code. The way to separate a prod deployment from a QA deployment is some flag in some property file. How long until an engineer pushes QA flag to prod environment? It might sound quite trivial, but a potential pitfall to watch out for.</li><li><strong>Change in thought process :</strong> Your way of writing tests could change dramatically with automation and application code under the same hood. So, your test cases should be derived from your business logic, and not from your code base. A test derived from code base would never fail. In fact, it could potentially be a false positive. You tend to look into the code to understand the flow and design test cases around it. This thought process could be detrimental to the sanity of your test cases itself. On the contrary, you should think of the business requirement and design test cases around that.</li></ol><p>Despite the cons, I am glad to have challenged the age-old belief of separate projects and have got good results off it. I am sure it is not a 1:1 relation when it comes to deciding which approach to go by. But today, this is my go-to approach for building frameworks and you would have to really convince me that separate projects would be better.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tebW90C48alshVc5kfiYeQ.png" /><figcaption><strong>Let’s give it a chance, shall we?</strong></figcaption></figure><p>If you have differing thoughts or extensions to these, we would love to hear about them. Leave comments to let us know what you think.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5631517620b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/blog-quiqua/dev-and-test-codebase-a-part-or-apart-e5631517620b">Dev and Test codebase — A part or Apart?</a> was originally published in <a href="https://medium.com/blog-quiqua">quiQUA</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>