{"id":9888,"date":"2018-04-24T16:36:32","date_gmt":"2018-04-24T16:36:32","guid":{"rendered":"http:\/\/abstracta.us\/blog\/?p=9888"},"modified":"2025-05-05T21:23:48","modified_gmt":"2025-05-05T21:23:48","slug":"devs-unit-testing-wrong","status":"publish","type":"post","link":"https:\/\/abstracta.us\/blog\/testing-strategy\/devs-unit-testing-wrong\/","title":{"rendered":"Devs, You Have Unit Testing All Wrong"},"content":{"rendered":"<p><!-- Go to www.addthis.com\/dashboard to customize your tools --><script src=\"\/\/s7.addthis.com\/js\/300\/addthis_widget.js#pubid=ra-58d80a50fc4f926d\" type=\"text\/javascript\"><\/script><\/p>\n<h1><span style=\"font-weight: 400;\">Why you shouldn&#8217;t skip unit testing for building high-quality software<\/span><\/h1>\n<p><span style=\"font-weight: 400;\">If you\u2019re a developer or work in the world of software development, you might have heard some misconceptions about unit testing. We\u2019ll go debunking some of them one by one in this post, and maybe you\u2019ll see unit testing in a new light.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Common_Misconceptions_About_Unit_Tests\"><\/span><strong><span style=\"color: #00b674;\">Common Misconceptions About Unit Tests<\/span><\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"%E2%80%9CUnit_testing_is_useless%E2%80%9D\"><\/span><strong><span style=\"color: #3056a2;\">&#8220;Unit testing is useless.&#8221;<\/span><\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">This is probably one of the most popular misconceptions around unit testing in the dev world, but it\u2019s far from the truth!<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Unit testing offers several benefits for a project. To start with, it helps to detect issues at an early stage of the development process preventing several costs in the future\u00a0without affecting any other parts of the software. It also gives us the opportunity to make the code more robust. Moreover, detecting and fixing bugs is much easier when found in a unit rather than in the whole system.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E2%80%9CUnit_testing_slows_down_development%E2%80%9D\"><\/span><strong><span style=\"color: #3056a2;\">&#8220;Unit testing slows down development.&#8221;<\/span><\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Even though unit testing may seem like it makes the development process slower, it actually does the opposite: <\/span><span style=\"font-weight: 400;\">i<\/span><span style=\"font-weight: 400;\">f you invest time in unit testing now, you will save much more time tomorrow, which means you save time!<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E2%80%9CThe_code_is_so_simple_why_should_I_write_a_test_for_it%E2%80%9D\"><\/span><strong><span style=\"color: #3056a2;\">&#8220;The\u00a0code is so simple, why should I write a test for it?&#8221;<\/span><\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Not only does unit testing prevent bugs in code, it also makes it more reliable and stable. It promotes better architecture, design, and maintainability. You will definitely sleep better if you know your code is undergoing unit testing!<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E2%80%9CTesters_are_in_charge_of_unit_testing%E2%80%9D\"><\/span><strong><span style=\"color: #3056a2;\">&#8220;Testers are in charge of unit testing.&#8221;<\/span><\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Actually, this one is also a great distance from the truth. Following the <\/span><a href=\"https:\/\/abstracta.us\/blog\/agile-testing\/not-convinced-yet-shift-left-testing\/\"><span style=\"font-weight: 400;\">shift-left methodology<\/span><\/a><span style=\"font-weight: 400;\"> you could misunderstand \u201cdo more testing early in the project\u201d as \u201clet the testers do their stuff early\u201d. Testing is not only the responsibility of testers. There are many testing tasks that could and should be performed by programmers. Unit testing should be part of the development process and developers have to take responsibility of their own code by \u201cassuring\u201d that it\u2019s working as expected. This way, testers can work on more complex test cases with a high level perspective, testing business flows. Also, they could also have more time to test other aspects of the system like its performance, security, accessibility, etc.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E2%80%9CWe_have_integration_tests_so_we_dont_need_unit_tests%E2%80%9D\"><\/span><strong><span style=\"color: #3056a2;\">&#8220;We have integration tests, so we don&#8217;t need unit tests.&#8221;<\/span><\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">We tend to believe that if we test the system as a whole, we are testing the units as well. In fact, this is not true. Jerry Weinberg claims the idea that <\/span><span style=\"font-weight: 400;\">testing a whole system will simultaneously test its constituent parts <\/span><span style=\"font-weight: 400;\">is a fallacy of decomposition<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\"> What happens if you want to use one of your units (which are supposedly tested) in a very different scenario? What should you think about your code\u2019s reliability if it doesn\u2019t work in other environment? These are questions you can answer via unit tests. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">In some cases, it\u2019s difficult to mock the classes or services that a unit uses, and if so, it\u2019s ok to test everything together, but at least try to apply <\/span><a href=\"http:\/\/softwaretestingfundamentals.com\/white-box-testing\/\"><span style=\"font-weight: 400;\">white box testing techniques<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Final_Thoughts\"><\/span><strong><span style=\"color: #00b674;\">Final Thoughts<\/span><\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">It\u2019s important to note that unit testing (as with any type of testing) is optional, not a requirement. When you are developing a product, it\u2019s up to you to decide whether you want it to be of a certain standard of quality or not. If you <\/span><i><span style=\"font-weight: 400;\">are <\/span><\/i><span style=\"font-weight: 400;\">concerned about quality, you should start by verifying and improving your software\u2019s units and components. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">Think about testing when you want to create a robust, secure, efficient, and stable system that users will love. Making sure that the quality of your products is high is an ongoing process that evolves over time. The amount of effort you put into it tells a lot about your engagement with clients and the responsibility you take for offering high caliber products. Unit testing is just a small piece of the journey. Nonetheless, the tremendous benefits it offers are too good not to consider!<\/span><\/p>\n<hr \/>\n<h2><span class=\"ez-toc-section\" id=\"Recommended_for_You\"><\/span><strong>Recommended for You<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><a href=\"http:\/\/abstracta.us\/blog\/test-automation\/the-true-roi-of-test-automation\/\"><span style=\"font-weight: 400;\">The True ROI of Test Automation<\/span><\/a><br \/>\n<a href=\"http:\/\/Best Practices The Automation Pyramid\">Best Testing Practices for Agile Teams: The Test Automation Pyramid<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Why you shouldn&#8217;t skip unit testing for building high-quality software If you\u2019re a developer or work in the world of software development, you might have heard some misconceptions about unit testing. We\u2019ll go debunking some of them one by one in this post, and maybe&#8230;<\/p>\n","protected":false},"author":27,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[636],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v14.0.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Devs, You Have Unit Testing All Wrong | Abstracta Blog<\/title>\n<meta name=\"description\" content=\"If you work in software development, you might have heard some misconceptions about unit testing. We\u2019ll go debunking some of them one by one in this post!\" \/>\n<meta name=\"robots\" content=\"index, follow\" \/>\n<meta name=\"googlebot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta name=\"bingbot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/abstracta.us\/blog\/testing-strategy\/devs-unit-testing-wrong\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Devs, You Have Unit Testing All Wrong | Abstracta Blog\" \/>\n<meta property=\"og:description\" content=\"If you work in software development, you might have heard some misconceptions about unit testing. We\u2019ll go debunking some of them one by one in this post!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/abstracta.us\/blog\/testing-strategy\/devs-unit-testing-wrong\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog about AI-powered quality engineering for teams building complex software | Abstracta\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/AbstractaQA\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-04-24T16:36:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-05-05T21:23:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/abstracta.us\/wp-content\/uploads\/2018\/04\/Unit-Testing.png\" \/>\n\t<meta property=\"og:image:width\" content=\"560\" \/>\n\t<meta property=\"og:image:height\" content=\"315\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@AbstractaUS\" \/>\n<meta name=\"twitter:site\" content=\"@AbstractaUS\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/abstracta.us\/blog\/#website\",\"url\":\"https:\/\/abstracta.us\/blog\/\",\"name\":\"Blog about AI-powered quality engineering for teams building complex software | Abstracta\",\"description\":\"AI-powered quality engineering\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/abstracta.us\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/abstracta.us\/blog\/testing-strategy\/devs-unit-testing-wrong\/#webpage\",\"url\":\"https:\/\/abstracta.us\/blog\/testing-strategy\/devs-unit-testing-wrong\/\",\"name\":\"Devs, You Have Unit Testing All Wrong | Abstracta Blog\",\"isPartOf\":{\"@id\":\"https:\/\/abstracta.us\/blog\/#website\"},\"datePublished\":\"2018-04-24T16:36:32+00:00\",\"dateModified\":\"2025-05-05T21:23:48+00:00\",\"author\":{\"@id\":\"https:\/\/abstracta.us\/blog\/#\/schema\/person\/6c90ede2f87134671cfdfa75e82f3982\"},\"description\":\"If you work in software development, you might have heard some misconceptions about unit testing. We\\u2019ll go debunking some of them one by one in this post!\",\"breadcrumb\":{\"@id\":\"https:\/\/abstracta.us\/blog\/testing-strategy\/devs-unit-testing-wrong\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/abstracta.us\/blog\/testing-strategy\/devs-unit-testing-wrong\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/abstracta.us\/blog\/testing-strategy\/devs-unit-testing-wrong\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/abstracta.us\/blog\/\",\"url\":\"https:\/\/abstracta.us\/blog\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/abstracta.us\/blog\/testing-strategy\/\",\"url\":\"https:\/\/abstracta.us\/blog\/testing-strategy\/\",\"name\":\"Testing Strategy\"}},{\"@type\":\"ListItem\",\"position\":3,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/abstracta.us\/blog\/testing-strategy\/devs-unit-testing-wrong\/\",\"url\":\"https:\/\/abstracta.us\/blog\/testing-strategy\/devs-unit-testing-wrong\/\",\"name\":\"Devs, You Have Unit Testing All Wrong\"}}]},{\"@type\":[\"Person\"],\"@id\":\"https:\/\/abstracta.us\/blog\/#\/schema\/person\/6c90ede2f87134671cfdfa75e82f3982\",\"name\":\"Fernanda Sesto\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/abstracta.us\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3191a1d49d5c9b1c255a6fd7b055a593?s=96&d=blank&r=g\",\"caption\":\"Fernanda Sesto\"},\"description\":\"Software Tester, Abstracta\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/posts\/9888"}],"collection":[{"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/users\/27"}],"replies":[{"embeddable":true,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/comments?post=9888"}],"version-history":[{"count":7,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/posts\/9888\/revisions"}],"predecessor-version":[{"id":12056,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/posts\/9888\/revisions\/12056"}],"wp:attachment":[{"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/media?parent=9888"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/categories?post=9888"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/tags?post=9888"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}