{"id":10181,"date":"2018-09-27T16:46:45","date_gmt":"2018-09-27T16:46:45","guid":{"rendered":"http:\/\/abstracta.us\/blog\/?p=10181"},"modified":"2025-05-05T21:23:38","modified_gmt":"2025-05-05T21:23:38","slug":"test-automation-patterns-good-practices","status":"publish","type":"post","link":"https:\/\/abstracta.us\/blog\/software-testing\/test-automation-patterns-good-practices\/","title":{"rendered":"Test Automation Patterns and Good Practices"},"content":{"rendered":"<h1><span style=\"font-weight: 400;\">How to make sure your test automation not only makes your team move faster, but in the right direction.<\/span><\/h1>\n<p><a href=\"http:\/\/abstracta.us\/wp-content\/uploads\/2018\/09\/deva-darshan-649737-unsplash-2-min.jpg\"><img decoding=\"async\" class=\"aligncenter size-large wp-image-10183\" src=\"http:\/\/abstracta.us\/wp-content\/uploads\/2018\/09\/deva-darshan-649737-unsplash-2-min-1024x576.jpg\" alt=\"move testing in the right direction\" width=\"1024\" height=\"576\" \/><\/a><\/p>\n<p><em>By <a href=\"https:\/\/www.linkedin.com\/in\/matias-fornara-ernst-396075a8\/\" target=\"_blank\" rel=\"noopener\">Matias Fornara<\/a> and <a href=\"https:\/\/www.linkedin.com\/in\/alejandro-berardinelli-5a83b323\/\" target=\"_blank\" rel=\"noopener\">Alejandro Berardinelli<\/a><\/em><\/p>\n<p><span style=\"font-weight: 400;\">Test automation, or automating the execution of your tests, provides several advantages: it saves your team time, resources, and the headache of having to do everything manually. However, test automation alone doesn\u2019t guarantee success. If you don\u2019t set up tests in the right way, you end up with the same bad results (just delivered a whole lot faster!). <\/span><\/p>\n<p><span style=\"font-weight: 400;\">Here are some patterns and best practices for test automation, so you can be sure your team is getting maximum value from your automation efforts.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Test_Code_Review\"><\/span><strong><span style=\"color: #00b674;\">Test Code Review<\/span><\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Tests (at the unit, API, UI, and performance level) should be reviewed to analyze their quality and to find mismatches or bad practices. For example, a set of tests could be fulfilling their coverage criteria, sufficiently invoking the intended code sections, but if proper assertions aren\u2019t written, the tests will be useless in identifying problems (that is, they will only execute the code, and not analyze whether what it does is good or not).<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The practice of test code review also allows another person with a fresh perspective to add more tests that evaluate other aspects of the system, as well as verify that system requirements are clear and met.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Apply_Assertions\"><\/span><strong><span style=\"color: #00b674;\">Apply Assertions<\/span><\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">As mentioned, assertions make the difference between a test that only tries out the code and one that really identifies problems. Each test automation tool verifies responses by providing a way to determine if a test has failed.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">On the other hand, it\u2019s also best to pay special attention in the definition of assertions to avoid false negatives and false positives, since an overly generic assertion can result in incorrectly valid or invalid tests.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Behavior-Driven_Development_BDD\"><\/span><strong><span style=\"color: #00b674;\">Behavior-Driven Development (BDD)<\/span><\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">BDD refers to Behavior-Driven Development. As the name implies, this isn\u2019t a testing technique, but rather a development strategy (like TDD, test-driven development). A common language should be established for the business and engineers to be used as a starting point for development and testing. Typically, user stories are defined and later used as an input for test cases creation. Beyond the possibility of automation, the focus should be on using certain business requirements that can later be translated into acceptance tests.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">One obvious advantage of BDD is that developers have clear specifications, so they can focus on what needs to be done<\/span><span style=\"font-weight: 400;\">\u2014<\/span><span style=\"font-weight: 400;\">and in what way<\/span><span style=\"font-weight: 400;\">\u2014<\/span><span style=\"font-weight: 400;\">at the business level. Like TDD where you have a method along with its tests, with BDD you already have an &#8220;acceptance test&#8221; at a business level.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Another advantage of the BDD approach is that it brings testability to the system. Thinking about functionalities in an independent way (as complete and involving all the layers of the system) guides a type of development that facilitates testing.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Page_Object_Pattern_for_UI_Testing\"><\/span><strong><span style=\"color: #00b674;\">Page Object Pattern for UI Testing<\/span><\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">When working with automation at any level, it\u2019s essential to focus on a solution\u2019s scalability and maintainability. That is, it shouldn\u2019t take more time to resolve conflicts or update an automation framework than the time saved by the automatic execution. To achieve this, the correct use of design patterns is fundamental.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">When writing automated tests, one begins to generate code that contains a lot of knowledge about the structure of the application, like the IDs of fields, buttons, and links, etc. Over time, the application will scale and be modified, so it\u2019s important that tests can be maintained with minimal effort.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The Page Objects pattern allows you to reuse this knowledge of the application while making each change in the pattern have minimal impact on tests. It consists of completely decoupling what concerns the structure of the user interface from the test code, and encapsulating this information in objects that represent application interface elements. In this way, the Page Object pattern strengthens tests.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">By following a BDD approach, these types of patterns should also be applied, since they are complementary practices. This also applies to any automatic verification at the graphic interface level, regardless of whether Selenium (for web), Appium (for mobile) or any other tool is used.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Data-Driven_Testing\"><\/span><strong><span style=\"color: #00b674;\">Data-Driven Testing<\/span><\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">While data-driven testing goes beyond a design pattern and involves a whole testing approach, we include it in this post as part of good programming practices.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Essentially, automated tests are parameterized so that the same steps can be executed with diverse amounts of test data. That way, simply adding data to the data file creates new test cases.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The greatest benefit of doing this comes when the same sequence of steps is executed with different data sets, parameterizing both the input data and the expected output data.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Parallel_Execution_of_Tests\"><\/span><strong><span style=\"color: #00b674;\">Parallel Execution of Tests<\/span><\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Unit tests and API-level tests generally run faster than UI tests. On the other hand, automated tests at the graphic interface level require access to the end-to-end system and handling of interface elements so, they require more execution time. This is why different strategies like parallel execution have become really useful. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">If you work on a web application and automate with Selenium (the most commonly used option) it\u2019s a good practice to use Selenium Grid. With its multiple nodes, Selenium Grid has the advantage of easily combining operating systems with several browsers accessing the application. This leads to running several tests in parallel using the Grid reducing testing time.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">When combining Selenium Grid with any integration tool as Jenkins, tests are triggered by connecting to the Grid and run on each node. Results are stored in association with the task (Job in Jenkins terminology) keeping track of the executions. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">These are just some of the patterns and best practices you can use to improve your test automation. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">With the right combination of tools and practices, you can move forward knowing test automation is propelling your team in the right direction.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">What are some test automation practices you\u2019ve found helpful? Any advice? <\/span><\/p>\n<p><span style=\"font-weight: 400;\">Leave a comment below!<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><em>Thank you to Feedspot for recently naming Abstracta as one of the <a href=\"https:\/\/blog.feedspot.com\/automation_testing_blogs\/\" target=\"_blank\" rel=\"noopener\">top blogs<\/a>\u00a0for test automation!\u00a0<\/em><\/p>\n<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","protected":false},"excerpt":{"rendered":"<p>How to make sure your test automation not only makes your team move faster, but in the right direction. By Matias Fornara and Alejandro Berardinelli Test automation, or automating the execution of your tests, provides several advantages: it saves your team time, resources, and the&#8230;<\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,60],"tags":[99],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v14.0.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Test Automation Patterns and Good Practices | Abstracta<\/title>\n<meta name=\"description\" content=\"Here are some test automation patterns and good practices to get your automation efforts started the right way!\" \/>\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\/test-automation\/test-automation-patterns-good-practices\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Test Automation Patterns and Good Practices | Abstracta\" \/>\n<meta property=\"og:description\" content=\"Here are some test automation patterns and good practices to get your automation efforts started the right way!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/abstracta.us\/blog\/test-automation\/test-automation-patterns-good-practices\/\" \/>\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-09-27T16:46:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-05-05T21:23:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/abstracta.us\/wp-content\/uploads\/2018\/09\/Patterns-and-Good-Practices-min.jpg\" \/>\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\":\"ImageObject\",\"@id\":\"https:\/\/abstracta.us\/blog\/test-automation\/test-automation-patterns-good-practices\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"http:\/\/abstracta.us\/wp-content\/uploads\/2018\/09\/deva-darshan-649737-unsplash-2-min-1024x576.jpg\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/abstracta.us\/blog\/test-automation\/test-automation-patterns-good-practices\/#webpage\",\"url\":\"https:\/\/abstracta.us\/blog\/test-automation\/test-automation-patterns-good-practices\/\",\"name\":\"Test Automation Patterns and Good Practices | Abstracta\",\"isPartOf\":{\"@id\":\"https:\/\/abstracta.us\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/abstracta.us\/blog\/test-automation\/test-automation-patterns-good-practices\/#primaryimage\"},\"datePublished\":\"2018-09-27T16:46:45+00:00\",\"dateModified\":\"2025-05-05T21:23:38+00:00\",\"author\":{\"@id\":\"https:\/\/abstracta.us\/blog\/#\/schema\/person\/c68426aae266fb10c7db3f3d6af2a321\"},\"description\":\"Here are some test automation patterns and good practices to get your automation efforts started the right way!\",\"breadcrumb\":{\"@id\":\"https:\/\/abstracta.us\/blog\/test-automation\/test-automation-patterns-good-practices\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/abstracta.us\/blog\/test-automation\/test-automation-patterns-good-practices\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/abstracta.us\/blog\/test-automation\/test-automation-patterns-good-practices\/#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\/test-automation\/\",\"url\":\"https:\/\/abstracta.us\/blog\/test-automation\/\",\"name\":\"Test Automation\"}},{\"@type\":\"ListItem\",\"position\":3,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/abstracta.us\/blog\/test-automation\/test-automation-patterns-good-practices\/\",\"url\":\"https:\/\/abstracta.us\/blog\/test-automation\/test-automation-patterns-good-practices\/\",\"name\":\"Test Automation Patterns and Good Practices\"}}]},{\"@type\":[\"Person\"],\"@id\":\"https:\/\/abstracta.us\/blog\/#\/schema\/person\/c68426aae266fb10c7db3f3d6af2a321\",\"name\":\"Mat\\u00edas Fornara, Operation Manager at Abstracta\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/abstracta.us\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e3720307097a99a3775478ad6bd51352?s=96&d=blank&r=g\",\"caption\":\"Mat\\u00edas Fornara, Operation Manager at Abstracta\"},\"description\":\"Tech Lead &amp; Performance Engineer, Abstracta\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/posts\/10181"}],"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\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/comments?post=10181"}],"version-history":[{"count":7,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/posts\/10181\/revisions"}],"predecessor-version":[{"id":17550,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/posts\/10181\/revisions\/17550"}],"wp:attachment":[{"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/media?parent=10181"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/categories?post=10181"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/tags?post=10181"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}