<?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 Umair Naseem on Medium]]></title>
        <description><![CDATA[Stories by Umair Naseem on Medium]]></description>
        <link>https://medium.com/@umairnaseem?source=rss-620d4cf80558------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Umair Naseem on Medium</title>
            <link>https://medium.com/@umairnaseem?source=rss-620d4cf80558------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 12:45:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@umairnaseem/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[ “Secure by Design: Why Engineers Must Think Like Hackers”]]></title>
            <link>https://medium.com/@umairnaseem/secure-by-design-why-engineers-must-think-like-hackers-05809fc88e84?source=rss-620d4cf80558------2</link>
            <guid isPermaLink="false">https://medium.com/p/05809fc88e84</guid>
            <dc:creator><![CDATA[Umair Naseem]]></dc:creator>
            <pubDate>Sun, 04 May 2025 17:41:41 GMT</pubDate>
            <atom:updated>2025-05-04T17:41:41.986Z</atom:updated>
            <content:encoded><![CDATA[<p>In an era where data is gold and systems are increasingly complex, software engineers are the first line of defense against cyber threats. It’s no longer enough to just write clean and functional code — developers must <strong>think like security professionals</strong> from day one. That means cultivating a <strong>security mindset</strong> that proactively identifies and mitigates risks long before they can be exploited.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xIAfo1w6mXvTVX0txOcwiA.png" /></figure><h3>🧠 What is a Security Mindset?</h3><p>A <strong>security mindset</strong> means designing, developing, and deploying software with the constant assumption that adversaries are actively trying to exploit it. It’s the habit of:</p><ul><li>Asking “What could go wrong?” at every design and implementation phase.</li><li>Considering both intended and unintended uses of your code.</li><li>Thinking like an attacker to anticipate vulnerabilities.</li></ul><p>It’s about being paranoid in a productive way.</p><h3>🚨 Why It Matters Now More Than Ever</h3><h3>1. Exploding Attack Surfaces</h3><p>With the rise of cloud services, APIs, microservices, and IoT, every additional line of code or endpoint could be an attack vector.</p><blockquote><strong><em>Example:</em></strong><em> In 2021, attackers exploited a vulnerability in the </em><strong><em>Log4j</em></strong><em> library — a widely used Java logging tool — which allowed remote code execution. It was a small oversight with catastrophic potential. Millions of applications were exposed.</em></blockquote><h3>2. Shift-Left Security</h3><p>Modern DevSecOps practices advocate for <strong>“shifting security left”</strong> — integrating security early in the development lifecycle. This avoids costly fixes later and catches vulnerabilities at their root.</p><blockquote><strong><em>Example:</em></strong><em> Catching SQL injection during code review is cheaper than post-deployment, when customer data might already be compromised.</em></blockquote><h3>3. Security is Everyone’s Job</h3><p>Security used to be the responsibility of a dedicated team. Not anymore. With fast CI/CD pipelines and agile cycles, <strong>developers deploy code daily or even hourly</strong>. If they aren’t security-aware, bugs ship fast — and so do vulnerabilities.</p><h3>🔍 Common Mistakes When Security Isn’t a Priority</h3><ul><li><strong>Hardcoded credentials</strong> in source code or version control</li><li><strong>Insecure default configurations</strong> or exposing sensitive ports</li><li><strong>Missing input validation</strong>, leading to injection attacks</li><li><strong>Over-permissioned roles</strong> in APIs or cloud services</li><li><strong>Failure to log or monitor</strong> suspicious behavior</li></ul><p>These errors are often not due to malice or incompetence — just a <strong>lack of security thinking</strong>.</p><h3>🧰 Building a Security Mindset: Best Practices</h3><h3>🔑 1. Threat Modeling</h3><ul><li>Regularly ask: <strong>“How could this be abused?”</strong></li><li>Use tools like STRIDE or PASTA to model threats</li></ul><h3>🛡️ 2. Learn Secure Coding Practices</h3><ul><li>Follow OWASP Top 10 (a list of the most critical security risks)</li><li>Use linters and static analysis tools that flag insecure patterns</li></ul><h3>🔍 3. Code Reviews with Security in Focus</h3><ul><li>Make security a checklist item</li></ul><h3>👯 4. Collaborate with Security Teams</h3><ul><li>Treat security engineers as partners, not blockers</li><li>Use their insights during architecture reviews and deployments</li></ul><h3>💡 Final Thought: Security is a Feature</h3><p>A system can’t be <strong>reliable</strong> or <strong>trustworthy</strong> if it’s not <strong>secure</strong>. That’s why engineers must treat security not as an afterthought, but as a core requirement — as fundamental as performance or usability.</p><p>So start coding like a hacker is watching — because one probably is.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=05809fc88e84" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Navigating the Financial Landscape: Unveiling the Power of ERP Systems]]></title>
            <link>https://medium.com/@umairnaseem/navigating-the-financial-landscape-unveiling-the-power-of-erp-systems-35005ed83c14?source=rss-620d4cf80558------2</link>
            <guid isPermaLink="false">https://medium.com/p/35005ed83c14</guid>
            <dc:creator><![CDATA[Umair Naseem]]></dc:creator>
            <pubDate>Wed, 01 May 2024 13:49:14 GMT</pubDate>
            <atom:updated>2024-05-01T13:49:14.574Z</atom:updated>
            <content:encoded><![CDATA[<p>In the dynamic landscape of modern businesses, where agility and precision are paramount, Enterprise Resource Planning (ERP) emerges as a cornerstone for financial management. ERP software stands as a beacon of efficiency, offering a comprehensive solution to streamline processes, facilitate data-based decisions, ensure financial accuracy, and maintain confidentiality.</p><p>ERP system help in a lot of ways from streamlining process, and financial recordings. Exhaustive areas were it helps are as follow.</p><p><strong>Streamlining Processes with ERP:</strong></p><p>One of the primary advantages of ERP lies in its ability to streamline processes across various departments within an organization. ERP eliminates redundancies, reduces manual efforts, and fosters seamless collaboration on a centralized platform. From procurement to inventory management, from sales to finance, ERP optimizes workflows, enhancing operational efficiency and productivity.</p><p><strong>Empowering Data-Based Decisions:</strong></p><p>In today’s data-driven era, informed decision-making is non-negotiable for sustained success. ERP plays a pivotal role by providing real-time access to critical financial data and analytics. With comprehensive reporting tools and customizable dashboards, stakeholders gain deeper insights into performance metrics, market trends, and customer behaviors. This empowers leaders to make data-driven decisions swiftly, driving strategic growth and competitive advantage.</p><p><strong>Ensuring Financial Accuracy and Confidentiality:</strong></p><p>Financial accuracy is the bedrock of any successful enterprise. ERP systems enforce rigorous controls and automation, minimizing errors and ensuring compliance with accounting standards.</p><p><strong>Identifying Process Issues and Loopholes:</strong></p><p>ERP implementation goes beyond mere automation; it serves as a catalyst for process optimization. By analyzing data across various functions, ERP identifies inefficiencies, bottlenecks, and loopholes in existing processes. This proactive approach enables organizations to address issues promptly, optimize resource allocation, and drive continuous improvement initiatives.</p><p><strong>Building Control in Transactional Systems:</strong></p><p>Transactional systems form the backbone of financial operations. ERP empowers organizations to build robust controls and governance mechanisms around these systems. By enforcing segregation of duties, implementing approval workflows, and conducting regular audits, ERP minimizes the risk of fraud, errors, and non-compliance, ensuring the integrity of financial transactions.</p><p><strong>Adopting Financial Best Practices:</strong></p><p>In the pursuit of excellence, organizations must continuously evolve and embrace best practices. ERP facilitates this journey by providing access to industry-standard processes, benchmarks, and compliance frameworks. By adopting financial best practices embedded within ERP modules, organizations can align their operations with global standards, enhance transparency, and mitigate regulatory risks.</p><p><strong>Conclusion:</strong></p><p>In conclusion, ERP stands as a transformative force in modern financial management, offering a plethora of benefits ranging from process optimization to data-driven decision-making, from risk mitigation to performance monitoring. By embracing ERP, organizations can embark on a journey towards operational excellence, financial integrity, and strategic resilience in today’s competitive landscape. As the digital revolution accelerates, the adoption of ERP emerges not just as a choice but as a strategic imperative for sustainable success.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35005ed83c14" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Art of Exchanging Effective Feedback]]></title>
            <link>https://medium.com/@umairnaseem/the-art-of-exchanging-effective-feedback-8d70c6aea4ad?source=rss-620d4cf80558------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d70c6aea4ad</guid>
            <dc:creator><![CDATA[Umair Naseem]]></dc:creator>
            <pubDate>Sun, 31 Mar 2024 17:42:23 GMT</pubDate>
            <atom:updated>2024-03-31T17:42:23.849Z</atom:updated>
            <content:encoded><![CDATA[<p>Offering feedback and receiving feedback is an Art. Unfortunately, many peoples lack the art to offer it, and the employees on the receiving end are sometimes not so happy to get it.</p><p>As a part of a team, if you’re not exchanging feedback with peers, then you are missing opportunities to progress.</p><p>Enhancing our skills to provide and accept feedback resembles honing a muscle that necessitates practice. It’s common to find ourselves in situations where feedback discussions become defensive, causing individuals involved to withdraw. Despite their difficulty, these conversations are often the most fulfilling and essential for fostering personal and collective development.</p><p>The core of feedback should be around these key objectives:</p><ul><li>Ensure that the individual you’re providing feedback to, understands the behavior you’ve observed and why it’s problematic.</li><li>Clearly outline to the individual the improvements that can resolve the issue.</li><li>Take steps to minimize the chances of the behavior repeating in the future.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W36emqWvi5w0DRuXoCg6PA.png" /></figure><h3>Giving Feedback</h3><p>Before giving feedback, remind yourself <strong>why</strong> you are doing it. The purpose of giving feedback is to improve the situation or the person’s performance. You won’t accomplish that by being harsh, critical or offensive.</p><p>You’ll likely get much more from people when your approach is positive and focused on improvement. That’s not to say feedback always has to be good, but it should be fair and balanced. You should follow following guidelines to give effective feedback:</p><ul><li>Be specific.</li><li>State feedback in behavioral terms.</li><li>Suggest an alternative behavior when providing improvement information.</li><li>Use the SBI(Situation-Behavior-Impact)® model.</li><li>Provide feedback on things the individual can do something about.</li><li>Check to ensure clear communication.</li><li>Intentions should be very clear and its always to help colleagues get better versions of him/herself.</li><li>It should not be personal things, there should be no hard feeling about others.</li><li>It should be instance, should not be delayed otherwise not easy to relate and may be its no more relevant other person might have overcome</li><li>Providing positive feedback effectively requires sincerity and authenticity. It’s crucial for the recipient to perceive your genuine conviction in order for the feedback to have meaningful impact.</li><li>When providing negative or corrective feedback, it’s important to consider the other person’s emotions and convey the feedback in a respectful manner and tone. The recipient needs to feel reassured that you are giving the feedback because you want them to improve, grow and succeed rather than tearing them down</li><li>Let the receiver respond to your feedback and allow them to ask follow up questions. Once the issue is clear, then you two can work together to land on a solution or course-of-action.</li><li>One important point about these examples — there are no “buts.” Especially when inserted after a compliment or positive remark, the word “but” negates the entire first part and may actually increase defensiveness when giving feedback. Replacing “but” with “yet,” can help to soften the impact of what you’re saying. So remember to keep your big but out of the discussion.</li></ul><h3>Receiving Feedback</h3><p>In addition to giving feedback, there are also times when we will receive feedback. Here are some guidelines for when you’re on the other end of the conversation:</p><p>The whole purpose of feedback is to improve performance. You need to measure whether or not that is happening and then make adjustments as you go. Be sure to document your conversations and discuss what is working and what needs to be modified.</p><p>And those moments are often the toughest in both work and life. Hearing potentially negative feedback about yourself isn’t enjoyable, and many prefer to avoid the awkwardness of offering constructive criticism to others.</p><p>But what do we lose out on when we avoid these tough conversations? One of the fundamental skills of life is being able to give and receive advice, feedback and even criticism.</p><p>Following guideline helps how to receive feedback effectively:</p><ul><li>Be ready to listen actively.</li><li>Seek specifics. Using a non-defensive tone and body language, seek additional information, particularly if the person giving you feedback hasn’t provided you with specific details.</li><li>Restate the feedback to ensure clear communication.</li><li>Focus on behavior and not the person.</li><li>Take feedback as useful information that can provide you with new insights or understandings about how you or your behaviors are perceived by others.</li><li>Take time to process the feedback.<strong> </strong>You might need some time to reflect on what you heard before you can make the necessary changes.</li><li>Acknowledge your mistakes and learn from those and move on.</li><li>Think of feedback as an opportunity to grow rather than criticism about your current performance.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d70c6aea4ad" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Significance of Unit Tests in Software Development: Building Confidence and Elevating Code…]]></title>
            <link>https://medium.com/@umairnaseem/the-significance-of-unit-tests-in-software-development-building-confidence-and-elevating-code-1af73b290ef8?source=rss-620d4cf80558------2</link>
            <guid isPermaLink="false">https://medium.com/p/1af73b290ef8</guid>
            <dc:creator><![CDATA[Umair Naseem]]></dc:creator>
            <pubDate>Mon, 26 Feb 2024 17:50:42 GMT</pubDate>
            <atom:updated>2024-02-26T17:50:42.360Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Significance of Unit Tests in Software Development: Building Confidence and Elevating Code Quality</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*8F93yOSndae-1rS6ATgFqA.png" /></figure><h4>Introduction:</h4><p>In the dynamic landscape of software development, the importance of unit tests often remains underestimated. While developers may invest time in crafting elegant code, the pivotal role of unit testing cannot be overstressed. This blog explores the essence of unit tests, highlighting their crucial role in the development process and how they contribute to enhanced code quality and maintainability.</p><h4>Building Confidence through Tests:</h4><p>Unit tests serve as the foundation of confidence in the ever-evolving world of software development. When we write production code, it’s not just about making things work at a given moment. It’s about ensuring that they continue to work as the codebase evolves. Unit tests act as a safety net, allowing developers to make changes, refactor code, or add new features with the assurance that existing functionality remains intact.</p><h4><strong>Increasing Confidence in Refactoring</strong></h4><p>When developers make changes to the codebase, whether it’s adding new features, refactoring existing code, or fixing bugs, having a comprehensive suite of unit tests provides a safety net. Running the unit tests gives developers immediate feedback on the impact of their changes and ensures that the code behaves as expected. This increased confidence allows for more experimentation, and faster iterations, and promotes a culture of frequent code changes without the fear of introducing unintended side effects.</p><p>Unit test are important part of development process and they equally important as production code as it gives confident to change/refactor any code later on.</p><h4>Unit Tests: Silent Guardians of Code Quality:</h4><p>Many developers, despite writing impeccable code, often overlook the importance of unit tests. However, unit tests are not just an accessory; they are the unseen guardians of code quality. Writing unit tests inherently pushes developers to write modular, testable, and maintainable code. As we strive to make our code testable, we inadvertently adhere to principles like the single responsibility rule, resulting in cleaner and more precise code.</p><h4>Fostering Clean Code Principles:</h4><p>Unit tests play a significant role in promoting clean code. The process of writing testable code encourages developers to embrace simplicity and clarity. Code written with testing in mind naturally becomes more modular, following best practices such as encapsulation and separation of concerns. This, in turn, cultivates a codebase that is not only more understandable but also simpler to maintain and extend.</p><h4>Empowering Continuous Integration and Deployment:</h4><p>In the era of agile development and continuous integration, unit tests play a pivotal role. Automated testing, including unit tests, allows for the seamless integration of code changes and enables swift deployment. A comprehensive suite of unit tests allows developers to catch regressions early in the development cycle, preventing the introduction of bugs into the codebase.</p><h4>Reducing Debugging Time:</h4><p>An essential advantage of unit tests lies in their ability to expedite the debugging process. When a test fails, it precisely identifies the location and nature of the problem. This expedites the identification and resolution of issues, saving valuable development time. One of the primary advantages of unit testing is its ability to uncover bugs and inconsistencies during the development phase</p><h4>Reducing Technical Debt</h4><p>Technical debt refers to the accumulated cost of delayed or suboptimal software development practices. By neglecting unit testing, developers may unknowingly introduce bugs or regressions into the codebase, leading to increased technical debt. Over time, technical debt can slow down development, hinder the ability to introduce new features and make the codebase more difficult to maintain. By investing in comprehensive unit testing, developers can proactively address potential issues, prevent technical debt from accumulating, and keep the codebase in a healthy and maintainable state.</p><h4>TDD (Test-Driven Development)</h4><p>TDD is an art and north star for Unit testing. You really need to practice at home. TDD done halfway makes a nightmarish mess. Once you are good at TDD it makes to ship quality code faster and with more confidence. TDD also help you write code which is required only.</p><h4>Conclusion:</h4><p>Unit tests are not a mere luxury in the development process; they are a necessity. By instilling confidence, promoting clean code, and facilitating continuous integration, unit tests play an integral role in the software development lifecycle. Embracing a test-driven development approach not only enhances the robustness of your code but also leads to a more sustainable and agile development process. As we recognize the indispensable role of unit tests, let’s ensure they become an inseparable component of our coding endeavors.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1af73b290ef8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Qualities of a Successful Software Engineering Leader]]></title>
            <link>https://medium.com/@umairnaseem/qualities-of-a-successful-software-engineering-leader-e0f32a2d2778?source=rss-620d4cf80558------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0f32a2d2778</guid>
            <dc:creator><![CDATA[Umair Naseem]]></dc:creator>
            <pubDate>Sun, 29 Oct 2023 03:56:10 GMT</pubDate>
            <atom:updated>2023-10-29T03:56:10.121Z</atom:updated>
            <content:encoded><![CDATA[<p>In the fast-paced and ever-evolving world of technology, effective leadership within software engineering teams is more critical than ever. A successful software engineering leader doesn’t just manage code; they inspire and guide their team to create innovative solutions, navigate challenges, and drive organizational success. To excel in this role, there are several key qualities that distinguish exceptional leaders in the field.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*D-p6ieQ7WcH6lRJ1MQkJCQ.jpeg" /></figure><h3>1. Technical Expertise</h3><p>A great software engineering leader should be technically proficient. This doesn’t mean you have to be the best coder on the team, but you should have a deep understanding of the technology stack your team works with. Technical expertise commands respect and allows you to make informed decisions, assist your team when needed, and lead by example.</p><h3>2. Adaptability</h3><p>In the tech world, change is constant. A great leader needs to be adaptable and open to embracing new technologies and methodologies. Staying up-to-date and being willing to pivot when necessary ensures your team remains competitive and innovative.</p><h3>3. Empathy</h3><p>Understanding your team members’ needs, concerns, and aspirations is crucial. Empathy creates a supportive and inclusive work environment. It shows that you value your team as individuals and not just as resources. This, in turn, motivates them to perform at their best.</p><h3>4. Problem-Solving Ability</h3><p>Leaders often encounter complex problems. Your problem-solving skills are put to the test when you face challenges. Strong problem-solving abilities, combined with resourcefulness and resilience, help you navigate hurdles and find innovative solutions.</p><h3>5. Mentorship and Development</h3><p>Investing in the growth and development of your team members is a hallmark of a great leader. By providing mentorship and opportunities for skill improvement, you not only strengthen your team but also create a workforce that’s better equipped to contribute to your organization’s success.</p><h3>6. Decision-Making</h3><p>Leadership involves making tough decisions, and a good leader uses data and experience to make informed choices. Balancing short-term and long-term goals while considering the impact on the team is a critical aspect of this skill.</p><h3>7. Communication Skills</h3><p>Effective communication is at the heart of great leadership. You need to be able to articulate complex technical concepts in a way that’s accessible to both technical and non-technical team members. Clarity in communication fosters collaboration, ensures alignment, and prevents misunderstandings.</p><h3>8. Vision</h3><p>A clear vision for your team’s objectives is your north star. You should be able to articulate this vision to your team and inspire them to rally around it. A shared vision provides direction and purpose, motivating your team to work towards a common goal.</p><h3>9. Collaboration</h3><p>The best leaders understand the importance of collaboration. Encouraging teamwork not only within your team but also with other departments and stakeholders is essential. A leader who can bring people together can achieve remarkable outcomes.</p><h3>10. Leading from the Front</h3><p>One of the most influential qualities of a great software engineering leader is leading by example. Demonstrating a strong work ethic encourages your team to follow suit. If you consistently put in the effort and show dedication to your projects, your team is likely to do the same. When you set high standards for the quality of work, your team is more likely to meet and even exceed those standards. Moreover by demonstrating adaptability in the face of change and challenges, you instil confidence in your team. They’ll know that they, too, can adapt and overcome obstacles.</p><h3>11. Humbleness</h3><p>Humbleness is a quality often overlooked in leadership, but it’s a powerful tool in a software engineering leader’s arsenal. A humble leader is open to feedback, recognizing that they can always improve. Humbleness allows you to give credit where it’s due. A humble leader isn’t afraid to admit when they’re wrong or when they’ve made a mistake. Humbleness makes you approachable. Team members are more likely to share their concerns, ideas, and challenges when they feel that their leader is down-to-earth and willing to listen.</p><h3>12. Resilience</h3><p>In software engineering, setbacks and challenges are a part of the journey. Resilience is the ability to persevere through these obstacles and maintain a positive attitude. Your ability to bounce back from setbacks will inspire your team to do the same.</p><p>So, which of these qualities resonates most with you, and are there any additional qualities you believe are essential for software engineering leaders? Share your thoughts.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0f32a2d2778" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to maintain Android code test coverage]]></title>
            <link>https://medium.com/@umairnaseem/how-to-maintain-android-code-test-coverage-e0cd3a9ab81d?source=rss-620d4cf80558------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0cd3a9ab81d</guid>
            <category><![CDATA[jacoco]]></category>
            <category><![CDATA[code-coverage-tools]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[git-hooks]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Umair Naseem]]></dc:creator>
            <pubDate>Tue, 22 Mar 2022 10:07:36 GMT</pubDate>
            <atom:updated>2022-03-22T10:07:36.932Z</atom:updated>
            <content:encoded><![CDATA[<p>This article talks about the importance of code test coverage and tools that can help to achieve and maintain required goals. Code test coverage play really important role when it comes to overall health of application’s code base. Therefore, It’s important to write tests cases and maintain coverage.</p><p>So for maintaining coverage it’s important to have right tools in-place to ensure that new code have required test coverage and it does not degrade overall test coverage.</p><h3>Kent Beck 🌻 on Twitter: &quot;Being proud of 100% test coverage is like being proud of reading every word in the newspaper. Some are more important than others. / Twitter&quot;</h3><p>Being proud of 100% test coverage is like being proud of reading every word in the newspaper. Some are more important than others.</p><p>Code test coverage helps in many ways including as follow:</p><ul><li>Helps in refactoring code &amp; validating behaviour</li><li>Helps in shipping fast, with more confidence and reliability</li><li>Helps in improving code quality; as only good code is testable only</li><li>Helps in detecting bugs earlier</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*ZoM5tAmMMrmz7ZhvQCUfUA.png" /></figure><h4>Generate test coverage report</h4><p>Write gradle task in app build.gradle file to generate test coverage report as follow. Make sure you have minimum jacoco version 0.8.7</p><pre>task getCoverage(<strong>type</strong>: JacocoReport, <strong>dependsOn</strong>: <strong>&#39;testDebugUnitTest&#39;</strong>) <strong>{<br>    </strong>group = <strong>&quot;Reporting&quot;<br>    </strong>description = <strong>&quot;Generate Jacoco coverage reports after running tests.&quot;<br>    </strong>reports <strong>{<br>        </strong>xml.enabled = <strong>true<br>        </strong>html.enabled = <strong>true<br>    }<br>    </strong>getClassDirectories().setFrom(fileTree(<br>            <strong>dir</strong>: <strong>&#39;build/tmp/kotlin-classes/debug&#39;</strong>,<br>            <strong>excludes</strong>: androidExclusion<br><br>    ))<br>    getSourceDirectories().setFrom(files(<strong>&#39;src/main/java&#39;</strong>))<br>    getExecutionData().setFrom(files(<strong>&#39;build/jacoco/testDebugUnitTest.exec&#39;</strong>))<br><strong>}</strong></pre><blockquote><strong>androidExclusion;</strong> includes the classes/packages which we can exclude from overall coverage. This can include generated classes or view, etc like below.</blockquote><pre><strong>def </strong>androidExclusion = [<br>        <strong>&#39;**/R.*&#39;</strong>,<br>        <strong>&#39;**/R$*.*&#39;</strong>,<br>        <strong>&#39;**/BuildConfig.*&#39;</strong>,<br>        <strong>&#39;**/Manifest*.*&#39;</strong>,<br>        <strong>&#39;**/*Fragment*.*&#39;</strong>,<br>        <strong>&#39;**/*Activity*.*&#39;<br></strong>]</pre><h4>Test coverage rule task</h4><p>Now we will write task in build.gradle file to implement minimum coverage rule. Here <strong>minimum </strong>define overall minimum test coverage to failure check.</p><pre>task jacocoTestCoverageVerification(<strong>type</strong>: JacocoCoverageVerification, <strong>dependsOn</strong>: <strong>&#39;getCoverage&#39;</strong>) <strong>{<br>    </strong>getClassDirectories().setFrom(fileTree(<br>            <strong>dir</strong>: <strong>&#39;build/tmp/kotlin-classes/debug&#39;</strong>,<br>            <strong>excludes</strong>: androidExclusion<br><br>    ))<br>    getSourceDirectories().setFrom(files(<strong>&#39;src/main/java&#39;</strong>))<br>    getExecutionData().setFrom(files(<strong>&#39;build/jacoco/testDebugUnitTest.exec&#39;</strong>))<br>    violationRules <strong>{<br>        </strong>failOnViolation = <strong>true<br>        </strong>rule <strong>{<br>            </strong>limit <strong>{<br>                </strong>minimum = 0.9 <em>// 90%<br>            </em><strong>}<br>        }<br>    }<br>}</strong></pre><h4>Git hook</h4><p>Now we can write pre-push/pre-commit git hook file to validate coverage rule on code commit or push. Add this file in .git/hooks directory of application.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/386b4639bf942882a1076a9d11822243/href">https://medium.com/media/386b4639bf942882a1076a9d11822243/href</a></iframe><blockquote>To make this hook works on every developer machine, we will write task which copy this to git/hook directly.</blockquote><pre><em>// task to copy git hook on local<br></em>task installLocalGitHook(<strong>type</strong>: Copy)<strong>{<br>    </strong>from <strong>new </strong>File(rootProject.rootDir, <strong>&#39;././scripts/pre-push&#39;</strong>)<br>    into <strong>{ new </strong>File(rootProject.rootDir, <strong>&#39;././.git/hooks&#39;</strong>)<strong>}<br>    </strong>fileMode 0775<br><strong>}<br></strong><em>// add git hook dependency on build<br></em>build.dependsOn installLocalGitHook</pre><p>Full code is available <a href="https://github.com/umairnaseem/android-test-coverage-rule-hook">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0cd3a9ab81d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>