<?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 Sachithra Dangalla on Medium]]></title>
        <description><![CDATA[Stories by Sachithra Dangalla on Medium]]></description>
        <link>https://medium.com/@sachithradangalla?source=rss-8bc25ca22702------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*kYshjw14hKSSKfvfVHsVCA.jpeg</url>
            <title>Stories by Sachithra Dangalla on Medium</title>
            <link>https://medium.com/@sachithradangalla?source=rss-8bc25ca22702------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 06:47:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sachithradangalla/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[Mid point algorithm ~ How to draw a circle!]]></title>
            <link>https://sachithradangalla.medium.com/mid-point-algorithm-how-to-draw-a-circle-b6ed7c47c803?source=rss-8bc25ca22702------2</link>
            <guid isPermaLink="false">https://medium.com/p/b6ed7c47c803</guid>
            <category><![CDATA[computer-graphics]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[Sachithra Dangalla]]></dc:creator>
            <pubDate>Sun, 27 Jun 2021 14:30:54 GMT</pubDate>
            <atom:updated>2021-06-27T14:33:03.904Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever tried to draw a circle using code? If yes, you would have tumbled across the mid point algorithm, which defines how to determine the coordinates required to draw a circle.</p><p>I have the video explaining it here:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fbo-5qEAiwIk%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dbo-5qEAiwIk&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fbo-5qEAiwIk%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/4204cf7a336cce9b5cb0e039ae6f01f9/href">https://medium.com/media/4204cf7a336cce9b5cb0e039ae6f01f9/href</a></iframe><p>Or you can read through for the explanation.</p><h3>All you need is an octant</h3><p>To draw a circle, all you need is to draw one octant (one eighth) of the circle, because a circle is symmetrical across all axis and therefore, when you have one octant in place, you just need to mirror it in 8 ways to get the full circle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qkWM5bRPnN8HZOwas1uhmQ.gif" /></figure><h3>Let’s draw the octant</h3><p>Let’s consider the octant starting from the positive X axis and going upwards. We know the starting point coordinates (12, 0). For this particular octant:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tidDOxwAnIU_10DCB_4KEw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OifExRDaIxALFlyY076BKA.png" /></figure><p>The “y” value is always increasing by 1</p><p>The “x” value is either the same or decreasing by 1</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z_u0Mq9dif3UzcJny1ORLA.png" /></figure><p>So it would mean that, if we know one point, there will be 2 candidates for the next point.</p><p>Mid point algorithm determines which of them is actually closer to the circle (which of them is more accurate) by using their mid point.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SZLLXkkjInatm31yXqI7JA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yStgV6ikjZMB5ZJiYO-eaQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tekWOLU8REdRt3GQQ3w3SQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KNu0jG8tnHguKwiXAFkGQg.png" /></figure><p>So now we have all the information we need to keep calculating the next points until the octant is full.</p><p>Once the octant is full, it’s a matter of mirroring the data in 8 ways to get the full circle.</p><h3>Proof of (PK+1)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YHHYEox_GExKgJk_UN-qng.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b6ed7c47c803" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rubber Ducking ~ awfully simple, but works like a charm]]></title>
            <link>https://sachithradangalla.medium.com/rubber-ducking-awfully-simple-but-works-like-a-charm-aa49d5f1bb33?source=rss-8bc25ca22702------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa49d5f1bb33</guid>
            <category><![CDATA[rubber-ducking]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[debugging]]></category>
            <dc:creator><![CDATA[Sachithra Dangalla]]></dc:creator>
            <pubDate>Thu, 24 Jun 2021 06:46:10 GMT</pubDate>
            <atom:updated>2021-06-24T06:46:10.654Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*-iZQ0gWzCgMSOL91nBR-uQ.png" /><figcaption>Source: <a href="https://www.pandaandpolarbear.com/">https://www.pandaandpolarbear.com</a></figcaption></figure><h3>What is Rubber Ducking?</h3><p>Rubber Ducking or Dubber Duck debugging is the simple concept of explaining your code or your problem to a rubber duck.</p><p>Have you ever wanted to ask your question in Stack Overflow but didn’t need to post the question because you understood what is wrong while typing in the question? This is exactly what Rubber Ducking is. Well, not exactly, because you didn’t use a rubber duck, but you get the gist.</p><p>If you are stuck in a problem and cannot understand what the issue is, rubber ducking is one of the best ways to untangle yourself. The idea behind is to simplify and explain the piece of code or the problem line by line, so that you can clearly see where the problem lies.</p><p>The origin of the idea dates back to 1999 where “The Pragmatic Programmer”, written by Andrew Hunt and David Thomas talks about a developer carrying around a rubber duck. It has proven to be an efficient strategy in finding solutions to problems.</p><h3><strong>Why does it work?</strong></h3><p>The psychology behind it is pretty simple too. We work with computers, which are extremely fast and precise and we too, tend to follow it and think fast. But the human mind is not as precise as computers, because we are naturally forgiving. So we can loose track of certain understandings unconsciously and when those lost pieces are prominent enough, they can create a roadblock.</p><p>When explaining your problem to someone new, you make sure to explain all the details, from the beginning to the end, and without knowing, we trace back those forgotten bits and pieces to finally achieve that satisfying “Aha!” moment.</p><h3>Does it have to be a rubber duck?</h3><p>Of course not. While you can use an actual rubber duck if you’re comfortable with it, basically, the idea behind is for you to be able to explain your problem to a complete newbie. You can imagine you’re explaining your problem to a colleague, your dog, your coffee mug, or even as I mentioned above, writing about it in Stack Overflow.</p><p>You know how you trace back your steps, when you forget where you put something? This is exactly that for developers. We, as developers, are passionate about problem solving, so when we hit a wall, we tend to try hard and solve it rather than taking a step back. So let this be a kind reminder to practice Rubber Ducking to save the time you spend in distress.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa49d5f1bb33" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Selective Retransmission Vs. Go Back N]]></title>
            <link>https://sachithradangalla.medium.com/selective-retransmission-vs-go-back-n-e823e9fc1887?source=rss-8bc25ca22702------2</link>
            <guid isPermaLink="false">https://medium.com/p/e823e9fc1887</guid>
            <category><![CDATA[software]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Sachithra Dangalla]]></dc:creator>
            <pubDate>Mon, 22 Feb 2021 03:32:23 GMT</pubDate>
            <atom:updated>2021-02-22T03:32:23.711Z</atom:updated>
            <content:encoded><![CDATA[<p>Go back N and Selective retransmission are 2 methods of continuous ARQ or Automatic Repeat Request. Here is a comparison between the two concepts along with a simple demonstration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wGF4jPgOV87MrOwYPopWAA.png" /></figure><p><strong>Go Back N Demonstration:</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FgaocB7unrqs%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DgaocB7unrqs&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FgaocB7unrqs%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/fb5d221a0f1aed71c6c91ff779de36ed/href">https://medium.com/media/fb5d221a0f1aed71c6c91ff779de36ed/href</a></iframe><p><strong>Selective retransmission demonstration:</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F6fz_Wo8jkAc%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D6fz_Wo8jkAc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F6fz_Wo8jkAc%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/be82c99fa764ed6d9718050881da5dc9/href">https://medium.com/media/be82c99fa764ed6d9718050881da5dc9/href</a></iframe><p>Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e823e9fc1887" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to unscramble and analyse an external call stack in IntelliJ]]></title>
            <link>https://sachithradangalla.medium.com/how-to-unscramble-and-analyse-an-external-call-stack-in-intellij-413abec729d2?source=rss-8bc25ca22702------2</link>
            <guid isPermaLink="false">https://medium.com/p/413abec729d2</guid>
            <category><![CDATA[intellij]]></category>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[source-code]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[test-automation]]></category>
            <dc:creator><![CDATA[Sachithra Dangalla]]></dc:creator>
            <pubDate>Sun, 21 Feb 2021 09:20:43 GMT</pubDate>
            <atom:updated>2021-02-21T09:20:43.509Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*YTAj1L5OPQbOcwWsZQa9vg.png" /><figcaption>Source: <a href="https://www.pandaandpolarbear.com/">https://www.pandaandpolarbear.com</a></figcaption></figure><p>When debugging a program in the popular IDE IntelliJ, you may have used the call stack links which conveniently conveniently takes you to the corresponding class and line of code. But when you receive a stack trace from an external party (E.g. customer bug report) you would always want to easily analyse the stack trace in relation to your source code instead of manually following the files and line numbers.</p><p>IntelliJ’s Stack Trace Analyser is the tool that will save your life at a time like this.</p><ol><li>Copy the stack trace</li><li>In IntelliJ, select “<strong>Analyze</strong>” from the main menu and then click “<strong>Stack trace or thread dump…</strong>”</li><li>Most probably, the copied trace will already be pasted, but if not, paste it.</li><li>Click OK</li></ol><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FW86F7Tl2LI8%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DW86F7Tl2LI8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FW86F7Tl2LI8%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/7d6d6eb1ab49b96116668afd94c34223/href">https://medium.com/media/7d6d6eb1ab49b96116668afd94c34223/href</a></iframe><p><strong>References:</strong> <a href="https://www.jetbrains.com/help/idea/analyzing-external-stacktraces.html">https://www.jetbrains.com/help/idea/analyzing-external-stacktraces.html</a></p><p>Hope you learned something today! Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=413abec729d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why writing is important for software developers (or anyone, really)]]></title>
            <link>https://sachithradangalla.medium.com/why-writing-is-important-for-software-developers-or-anyone-really-de1795463d76?source=rss-8bc25ca22702------2</link>
            <guid isPermaLink="false">https://medium.com/p/de1795463d76</guid>
            <category><![CDATA[authors]]></category>
            <category><![CDATA[writing]]></category>
            <category><![CDATA[blogging]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Sachithra Dangalla]]></dc:creator>
            <pubDate>Sun, 07 Feb 2021 02:23:20 GMT</pubDate>
            <atom:updated>2022-07-14T05:53:51.476Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MbQO2bUUtGG6k2nFNjYINA.png" /><figcaption>Source: <a href="https://www.pandaandpolarbear.com/2012/08/on-cooking/">https://www.pandaandpolarbear.com/2012/08/on-cooking/</a></figcaption></figure><h3>It helps others</h3><p>The main goal of your writing should be to share your knowledge. Think of all the times you’ve Googled something and it showed you the way to solve your problem in a matter of minutes. Your writing could be the key to solve someone else’s problems.</p><h3>It improves your digital footprint</h3><p>Digital footprint represents your online presence and in today’s world of technology, one’s digital footprint serves as an unofficial resume. It would tell the world about your knowledge and your interests, which often plays a major role in recruitment.</p><h3>You would remember it more</h3><p>Information will stick in your mind more when you write it in your own words. It has the same effect of teaching someone. Even if you forget what you wrote, you will always know where to look.</p><p>Rubber duck programming is quite similar where a programmer would explain his piece of code to a rubber duck (or another programmer) in order to ensure everything makes sense. If you have used Stackoverflow to ask questions, you may have faced instances where you realise the solution on your own when trying to explain the problem using words.</p><h3>It improves your communication skills</h3><p>You may have faced situations where you spoke and after sometime, you come up with better ways and vocabulary you could have used. When you’re writing, you first gather your thoughts onto a piece of paper (or mostly on a computer). Unlike spoken communication, you have the luxury of revising your thoughts and improve it. When writing continuously, you would notice that the need for revision decreases, which means you know how to express your thoughts effectively. This is also reflected in your speech which improves your overall communication skills.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de1795463d76" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[3 Life saving subjects a techie must know]]></title>
            <link>https://sachithradangalla.medium.com/3-life-saving-subjects-a-techie-must-know-cda2ee94e74e?source=rss-8bc25ca22702------2</link>
            <guid isPermaLink="false">https://medium.com/p/cda2ee94e74e</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[career-advice]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Sachithra Dangalla]]></dc:creator>
            <pubDate>Fri, 05 Feb 2021 09:19:27 GMT</pubDate>
            <atom:updated>2021-02-13T01:30:40.350Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*Wvb1Icbg8ZE1ZA9rlDcFxQ.jpeg" /><figcaption>Source: Panda and Polar Bear</figcaption></figure><p>Everybody talks about the vague non technical skills a software engineer or a developer should have. Communication skills, attention to detail, creativity blah blah blah. Yes, they are important especially at the beginning of your career. But with time, you would realise that the following subjects too play a major role in your career even though you’re not prepared for them by your degree or course.</p><p>But fear not. Almost all the time, software developers are made to be passionate about learning new things, owing to the fact that the world of technology is constantly evolving. So learning the following subjects too is not a challenge, and in fact, there are so many resources online that you can use to self learn about these.</p><h3>Financial management</h3><p>This simply means the ability to handle your finances. Know what you’re paid (breakdown of the salary and taxes, increments, bonuses), evaluate and use possible saving options, learn about income protection insurance.</p><h3>How the stock market works</h3><p>A lot of tech companies allow employees to vest in their stocks, so it is important to know how the stock market works. Not knowing what you’re doing while trying to beat the market is the worst.</p><h3>Taxation</h3><p>Based on where you live in the world, you may face different taxation and tax return options. So it is quite important to keep an eye out for how you’re taxed, how different regulations may affect your taxation and how you can get the maximum returns out of them.</p><p>Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cda2ee94e74e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Interview tips for Software Developers]]></title>
            <link>https://sachithradangalla.medium.com/interview-tips-for-software-developers-12fc6dbe5dbc?source=rss-8bc25ca22702------2</link>
            <guid isPermaLink="false">https://medium.com/p/12fc6dbe5dbc</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[interview-tips]]></category>
            <category><![CDATA[interview]]></category>
            <dc:creator><![CDATA[Sachithra Dangalla]]></dc:creator>
            <pubDate>Fri, 18 Dec 2020 13:34:16 GMT</pubDate>
            <atom:updated>2021-01-01T05:46:40.513Z</atom:updated>
            <content:encoded><![CDATA[<h3>3 minute guide to win a software developer interview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*hc7usx8yx2C8Kf1FGRt75A@2x.jpeg" /></figure><p>Hello all,</p><p>Today I will be talking about some tips and tricks to help you land your dream job as a software developer.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FaYrdOFIKgoY%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DaYrdOFIKgoY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FaYrdOFIKgoY%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/f6df1a28618debc8c25e9eb0a3419aec/href">https://medium.com/media/f6df1a28618debc8c25e9eb0a3419aec/href</a></iframe><h3>Technical skills</h3><p>Obviously, you need to master at least one programming language. It is always best to look for job opportunities that match your proficiency. One thing to keep in mind is that the world of programming is constantly evolving and you need to keep up with it which is not very difficult thanks to the abundant resources that are available online.</p><p>Among all the topics involved with programming, data structures and algorithms are the most commonly sought out topics. Knowing the differences of applications of data structures and the time complexities of algorithms can save your life in an interview.</p><p>In addition to theoretical knowledge, the most important skill you should have is problem solving. There are so many platforms out there that you can use to practice problem solving In fact, some companies are using these platforms to host remote coding interviews.</p><h3>Communication skills</h3><p>You can work on your communication skills way before the interview. After all, it is an important life skill. As a software developer, your digital footprint is something that can be easily improved. Writing or blogging about projects you work on or the problems you solve is a simple but efficient way of improving your visibility.</p><p>During the interview, do not worry about your accent or pronunciation. All that matters is how well you organize your thoughts and explain them sensibly to the interviewer. During problem solving, most companies encourage thinking out loud which is a good way to declutter your mind and come up with a solution. For example, if you are thinking about multiple solutions to a problem, do not hesitate to share them all with the interviewer and go through pros and cons of each solution so that you can reach a final solution easily.</p><h3>People skills</h3><p>A lot of software companies work in teams are expect you to have people skills that will adapt well with the company culture. Basically, if you are a good team player, that’s it. Regarding the questions that may be asked, there are many platforms that will tell you about the past interview questions of different companies. Just respond naturally and honestly and you should be good to go.</p><h3>CV or Resume</h3><p>What should be included:</p><ol><li>Career objective</li><li>Work experience</li><li>Skills and attributes (Technical skills/technology stack)</li><li>Qualifications</li><li>Projects and activity history</li></ol><p>The most important thing is the use of keywords. A lot of companies have automated tools that filter out CVs based on keywords so when you’re describing your work experience, skills and past projects, make sure to use adequate but relevant keywords.</p><h3>Conclusion</h3><p>To sum it up, practice doing things right by following best practices and design patterns. Always research on what to expect and be punctual and that’s not just an interview tip.</p><p>Thank you and good luck!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12fc6dbe5dbc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mockito verify — How to test method invocations]]></title>
            <link>https://sachithradangalla.medium.com/mockito-verify-how-to-test-method-invocations-8cf15be9bc19?source=rss-8bc25ca22702------2</link>
            <guid isPermaLink="false">https://medium.com/p/8cf15be9bc19</guid>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[mockito]]></category>
            <category><![CDATA[code-testing]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[java-development]]></category>
            <dc:creator><![CDATA[Sachithra Dangalla]]></dc:creator>
            <pubDate>Fri, 04 Dec 2020 12:34:20 GMT</pubDate>
            <atom:updated>2020-12-15T08:48:56.332Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mockito verify — How to test method invocations</h3><p>Mockito verify is an impressive tool used in testing and there are various functionalities that would allow a developer to test method invocations.</p><h3>Test number of invocations of a method</h3><p>verify(mockedObject, times(1)).someMethod(); would test if someMethod() was called exactly 1 time.</p><p>verify(mockedObject, never()).someMethod(); would test if someMethod() was never called.</p><h3>Test order of invocation</h3><pre>InOrder inOrder = Mockito.inOrder(mockedObject);        inOrder.verify(mockedObject).firstMethod();        inOrder.verify(mockedObject).secondMethod();</pre><p>The above would verify that the firstMethod() was called before the secondMethod()</p><h3>Test minimum/maximum number of invocations</h3><p>verify(mockedObject, atLeast(2)).someMethod; would test if someMethod() was called at least 2 times.</p><p>verify(mockedObject, atMost(5)).someMethod(); would test if someMethod() was called not more than 5 times.</p><h3>Test no interactions were made with the test object</h3><p>verifyNoMoreInteractions(mockedObject); can be used to test if none of the methods of mockedObject were called.</p><h3>Complete example</h3><p>For this article, I will be using a sample Animal.java class with simple sample methods. The ParrotTest.java test class is testing an instance of a parrot. The methods to be tested are nested methods (which do not work on mocks directly) andverify works on mocked instances, therefore I have used spy to mock a solid animal instance.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc62e22a23eb911a3feba89ebd2b8cb2/href">https://medium.com/media/dc62e22a23eb911a3feba89ebd2b8cb2/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8cf15be9bc19" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Combine Git Commits — Rebase And Squash]]></title>
            <link>https://sachithradangalla.medium.com/how-to-combine-git-commits-rebase-and-squash-2ce83699b09e?source=rss-8bc25ca22702------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ce83699b09e</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[version-control]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[git-commands]]></category>
            <dc:creator><![CDATA[Sachithra Dangalla]]></dc:creator>
            <pubDate>Sat, 28 Nov 2020 02:59:20 GMT</pubDate>
            <atom:updated>2020-11-28T02:59:20.863Z</atom:updated>
            <content:encoded><![CDATA[<h3>How To Combine Git Commits — Rebase And Squash</h3><p>This post explains how to combine git commits by using <strong>git rebase</strong> and <strong>git squash</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/439/1*ABW9uAKza3Fk7Q037scf8g.jpeg" /></figure><p>Let’s assume that we have a couple of commits as follows that we wish to combine into one commit. You can use git log --online to view a summary or shortened version of <strong>git log</strong> output.</p><p>Let’s assume that we have a couple of commits as follows. <strong>— oneline</strong> gives the short version of <strong>git log</strong> output. It will open up vim editor and you can type :q to exit it without saving. (Some useful vim commands can be found at the end of the post)</p><pre>$ git log --oneline  <br>c123456 Edit file-B again  <br>b234567 Edit file-B  <br>a012345 Edit file-A</pre><p>As you can see, there are 2 commits that edits a certain file-B and we want to combine those commits into one.</p><p>So first of all, we have to go back a step and rebase into the commit that happened before our intended 2 commits, i.e. the “Edit file-A”. So copy the commit ID and use the following command to rebase:</p><p>git rebase -i a012345</p><p>The above command will open the editor with commit info up to the specified commit. Type i to enter into the Insert mode and edit the log as follows:</p><pre>pick b234567 Edit file-B  <br>squash c123456 Edit file-B again</pre><p>In the above commands we tell git to “squash” the unwanted commit.</p><p>Press Esc and type :wq to save and exit the editor. And that’s it! You can check the commit logs again to ensure the results.</p><p>If you have already pushed your changes to a remote, you might need to force push your changes using --force. E.g. git push origin --force</p><p>Hope you learned something today! Cheers!</p><p><strong>Quick tips: vim commands</strong></p><ul><li><strong>:wq</strong> — to save and exit</li><li><strong>:q</strong> — exit without saving</li><li><strong>i</strong> — to enter Insert mode</li><li><strong>Esc</strong> — to enter Command mode from Insert mode</li></ul><p><a href="https://www.google.lk/search?q=vim+commands&amp;oq=vim+commands&amp;aqs=chrome.0.69i59j0l5.3072j0j4&amp;sourceid=chrome&amp;ie=UTF-8">Google more on vim commands</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ce83699b09e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Write Parameterized Tests in Java]]></title>
            <link>https://sachithradangalla.medium.com/how-to-write-parameterized-tests-in-java-24be77572c90?source=rss-8bc25ca22702------2</link>
            <guid isPermaLink="false">https://medium.com/p/24be77572c90</guid>
            <category><![CDATA[junit]]></category>
            <category><![CDATA[parameterized-tests]]></category>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[java-test]]></category>
            <dc:creator><![CDATA[Sachithra Dangalla]]></dc:creator>
            <pubDate>Tue, 03 Nov 2020 10:04:43 GMT</pubDate>
            <atom:updated>2020-11-03T10:04:43.428Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi all!</p><p>Parameterized tests are extremely useful when you need to test a series of inputs against the same functionality. JUnit offers <strong><em>Parameterized</em></strong> class that facilitates this purpose.</p><p>As usual, let’s go through an example.</p><p>Assume you have a simple add method that takes 2 Integers and returns their sum. The Parameterized test for a such implementation would be:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c7bd8684794175778ae827f714c310dc/href">https://medium.com/media/c7bd8684794175778ae827f714c310dc/href</a></iframe><p>The test class constructor takes 3 arguments, the first input number, the second input number and the expected output respectively.</p><p>The <strong><em>data()</em></strong> method returns an array of 5 of objects, each containing 3 Integers.</p><p>During runtime, <strong><em>AdderTest</em></strong> will be instantiated 5 times, with the corresponding elements returned in the <strong><em>data() </em></strong>method.</p><p>The <strong><em>@Parameters</em></strong> annotation can be fed with a name, so that each test can be easily identified. The name contains placeholders for each parameter. Additionally, an “index” placeholder will keep track of the current parameter index.</p><p>When the test class is executed, the results will look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5XIoXlEYQln1qMQjUfvQCA.png" /><figcaption>Test results</figcaption></figure><p>If the test method requires only a single argument, there is no need to wrap it in an array and can be implemented as shown below:</p><pre>@Parameterized.Parameters<br>public static Object[] data() {<br>    return new Object[]{&quot;first test&quot;, &quot;second test&quot;};<br>}</pre><p>or</p><pre>@Parameterized.Parameters<br>public static Iterable&lt;? extends Object&gt; data() {<br>    return Arrays.<em>asList</em>(&quot;first test&quot;, &quot;second test&quot;);<br>}</pre><p>Hope you learned something today. Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24be77572c90" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>