{"id":1588,"date":"2025-05-02T13:17:00","date_gmt":"2025-05-02T11:17:00","guid":{"rendered":"https:\/\/extendsclass.com\/blog\/?p=1588"},"modified":"2025-01-28T22:49:46","modified_gmt":"2025-01-28T20:49:46","slug":"the-different-types-of-tests","status":"publish","type":"post","link":"https:\/\/extendsclass.com\/blog\/the-different-types-of-tests","title":{"rendered":"Unit, Integration, and E2E Tests: Understanding the different types of tests"},"content":{"rendered":"\n<p>We choose to become developers to write code&#8230; but at the heart of this profession, it&#8217;s tests that really matter, as they are crucial for ensuring the quality, stability, and security of the code. With so many types of tests available, it&#8217;s easy to get lost when you&#8217;re a beginner! The goal of this article is to introduce you to the three most common functional tests: unit tests, integration tests, and E2E (End-to-End) tests.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_47_1 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"ez-toc-toggle-icon-1\"><label for=\"item-69dac95478432\" aria-label=\"Table of Content\"><span style=\"display: flex;align-items: center;width: 35px;height: 30px;justify-content: center;direction:ltr;\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/label><input  type=\"checkbox\" id=\"item-69dac95478432\"><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/extendsclass.com\/blog\/the-different-types-of-tests\/#Why_test\" title=\"Why test?\">Why test?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/extendsclass.com\/blog\/the-different-types-of-tests\/#When_should_you_add_tests\" title=\"When should you add tests?\">When should you add tests?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/extendsclass.com\/blog\/the-different-types-of-tests\/#Types_of_tests\" title=\"Types of tests\">Types of tests<\/a><ul class='ez-toc-list-level-3'><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/extendsclass.com\/blog\/the-different-types-of-tests\/#Static_tests\" title=\"Static tests\">Static tests<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/extendsclass.com\/blog\/the-different-types-of-tests\/#Unit_tests\" title=\"Unit tests\">Unit tests<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/extendsclass.com\/blog\/the-different-types-of-tests\/#Integration_tests\" title=\"Integration tests\">Integration tests<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/extendsclass.com\/blog\/the-different-types-of-tests\/#E2E_tests\" title=\"E2E tests\">E2E tests<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/extendsclass.com\/blog\/the-different-types-of-tests\/#And_the_other_types_of_tests\" title=\"And the other types of tests\">And the other types of tests<\/a><ul class='ez-toc-list-level-4'><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/extendsclass.com\/blog\/the-different-types-of-tests\/#Manual_tests\" title=\"Manual tests\">Manual tests<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/extendsclass.com\/blog\/the-different-types-of-tests\/#Performance_tests\" title=\"Performance tests\">Performance tests<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/extendsclass.com\/blog\/the-different-types-of-tests\/#Security_tests\" title=\"Security tests\">Security tests<\/a><\/li><\/ul><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/extendsclass.com\/blog\/the-different-types-of-tests\/#Conclusion\" title=\"Conclusion\">Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Why_test\"><\/span>Why test?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>I have a saying in mind: &#8220;To test is to doubt&#8221; haha ^^<br>Hmm, as a developer, sometimes it\u2019s good to doubt a little! Adding tests to our code is essential, as it ensures that the implemented features remain reliable over time. It&#8217;s impossible to keep everything in your head, but by adding tests, we ensure that the code works correctly in the long run.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"When_should_you_add_tests\"><\/span>When should you add tests?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>When adding a new feature, there\u2019s no doubt that you need to add a test to validate its proper functioning. The same applies when refactoring the code: even if some classes are removed and new ones are added, it\u2019s crucial to ensure that everything works as expected.<\/p>\n\n\n\n<p>There\u2019s also another situation where adding tests is just as important! When fixing a bug, it can be wise and relevant to add a test to ensure the issue won\u2019t recur. In fact, if a bug has slipped past the existing tests, it likely means an essential test was missing.<br>And be careful, because if a regression happens and an old bug resurfaces, it can seriously annoy the client and damage the trust they had in you&#8230; and it can be hard to regain that trust afterward&#8230;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Types_of_tests\"><\/span>Types of tests<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>There are many types of tests, each suited to specific use cases.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Static_tests\"><\/span>Static tests<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Static tests are performed without executing the code, which allows for quick and cost-effective detection of errors such as typos, incorrect typing, etc.<\/p>\n\n\n\n<p>Personally, these have helped me identify several bugs that slipped through my unit tests. Static tests also help eliminate code that will never be executed&#8230;<\/p>\n\n\n\n<p>For example, you can use <a href=\"https:\/\/phpstan.org\/\">PHPStan<\/a> for PHP.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Unit_tests\"><\/span>Unit tests<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>As the name suggests, unit tests are used to test small portions of code, such as a function, in isolation. They are simple to implement and execute very quickly. Ideally, every branch of your code should be covered by unit tests.<\/p>\n\n\n\n<p>For PHP, you can use <a href=\"https:\/\/phpunit.de\/index.html\">PHPUnit<\/a>, and for C++, <a href=\"https:\/\/google.github.io\/googletest\/\">Google Test<\/a>. I mention these two tools because they are the ones I personally use.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Integration_tests\"><\/span>Integration tests<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Integration tests aim to verify the proper functioning of interactions between several components of an application, ensuring they work together correctly. Unlike unit tests, which focus on isolated pieces of code, integration tests validate how these code units fit into a larger system.<\/p>\n\n\n\n<p>The tools used for integration tests are often the same as those for unit tests, as both aim to automate the verification of the code\u2019s correct functioning. However, their implementation and usage may differ slightly based on the objectives of each type of test.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"E2E_tests\"><\/span>E2E tests<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>E2E (End-to-End) or functional tests go even further: they simulate user actions in a complete environment. These tests validate specific scenarios in the application, such as authentication, balance checking, or form submission.<\/p>\n\n\n\n<p>For a web application or website, E2E tests simulate real user behavior in the browser.<\/p>\n\n\n\n<p>For example, to test an Angular application, you can use <a href=\"https:\/\/www.cypress.io\/\" title=\"\">Cypress<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"And_the_other_types_of_tests\"><\/span>And the other types of tests<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Manual_tests\"><\/span>Manual tests<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>Manual tests, while time-consuming, allow for human validation of a new feature delivery or the prevention of a potential regression.<\/p>\n\n\n\n<p>Although you can\u2019t test everything manually, it\u2019s essential to focus on frequent and critical use cases of your application to ensure they work properly in a real environment.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Performance_tests\"><\/span>Performance tests<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>Performance tests measure an application&#8217;s ability to function under a specific load, evaluating aspects like response time, stability, and scalability. These tests help identify bottlenecks and ensure the application can handle a large number of users or prolonged usage without slowing down.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Security_tests\"><\/span>Security tests<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>Security tests aim to identify vulnerabilities in an application that could be exploited by attackers. They include checks for common vulnerabilities such as SQL injection, XSS (Cross-Site Scripting) attacks, and input validation issues. Security tests may also include penetration testing, where attack simulators try to exploit these vulnerabilities.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>We\u2019ve explored the different types of tests primarily conducted by developers, though some categories require the expertise of other professionals, such as security testers. There are certainly other types of tests depending on the specific needs of each project, but those mentioned here are the most common and essential for ensuring the quality, security, and performance of applications.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We choose to become developers to write code&#8230; but at the heart of this profession, it&#8217;s tests that really matter, as they are crucial for ensuring the quality, stability, and security of the code. With so many types of tests available, it&#8217;s easy to get lost when you&#8217;re a beginner! The goal of this article [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1590,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_sitemap_exclude":false,"_sitemap_priority":"","_sitemap_frequency":""},"categories":[2],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/posts\/1588"}],"collection":[{"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/comments?post=1588"}],"version-history":[{"count":3,"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/posts\/1588\/revisions"}],"predecessor-version":[{"id":1592,"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/posts\/1588\/revisions\/1592"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/media\/1590"}],"wp:attachment":[{"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/media?parent=1588"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/categories?post=1588"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/extendsclass.com\/blog\/wp-json\/wp\/v2\/tags?post=1588"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}