{"id":5732,"date":"2017-11-17T20:59:41","date_gmt":"2017-11-17T20:59:41","guid":{"rendered":"https:\/\/cheesecakelabs.com\/blog\/?p=5732\/"},"modified":"2022-07-01T17:24:57","modified_gmt":"2022-07-01T17:24:57","slug":"android-automated-ui-tests-baby-steps-2","status":"publish","type":"post","link":"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/","title":{"rendered":"Android automated UI tests: the baby steps"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">Since I started building apps I was sure of only two things: one is that I love seeing users enjoying my apps; and the second is that I hate seeing users clicking everywhere and crashing them. So how can I be sure that my users will be able to have a joyful experience (even with those features that are hidden 15 clicks away and that I don&#8217;t even remember they exist anymore)? By testing them all!<\/span><\/p>\n<p><!--more--><\/p>\n<h2><span style=\"font-weight: 400;\">What is UI testing and why to automate it?<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">UI testing is nothing more than simulating the user&#8217;s environment, performing the available actions and verifying if everything is behaving correctly.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Of course anyone can test features by simply having a human doing this job, but how time-consuming, boring and error-prone can it be? By having automated UI tests we assure that all the features will be tested reliably and quickly. We also become more confident to create or refactor features by being sure that if something gets broken we will know what and where the problem is, leading to faster development, less bugs, and better design decisions.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">If it&#8217;s not clear yet, by using UI automated tests a specific user&#8217;s action or input can be simulated and we can check if it returns the correct UI behavior. Besides that, interactions between our app and a third-one can also be tested to be sure that features like content-sharing are working perfectly. All of it can be achieved by using testing frameworks like Espresso or UI Automator.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Do not get fooled by your data!<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">It&#8217;s also important to use a framework to mock the data while testing the app, like Mockito, for example, since by relying on real APIs during testing we cannot control the scenario, exposing tests to failures in the external APIs. It&#8217;s also good to mention that by relying on external APIs we are essentially writing integration tests, which is not our objective here.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Another important point to think about is to choose a <\/span><span style=\"font-weight: 400;\">test-friendly architecture <\/span><span style=\"font-weight: 400;\">(aka modular ones) that will allow us to change from mock data during tests to real data during production.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">When to stop testing?<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">A particular point of testing is that it&#8217;s endless and it&#8217;s very important to decide when and where to stop it, mostly because software has a huge testing scope and, even though it&#8217;s possible to cover all the problematic points it can have, it will take like forever. So, it&#8217;s needed to get into a point where we can say that the existent tests are enough to prove that the app does work as intended, serving to its proposal.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Conclusion<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">To wrap it up, keep in mind that automating UI testing is a great way to ensure that actions available in the app will have the expected behavior,&nbsp;which can lead to better user experience, also a more free and enjoyable programming time.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">TL;DR<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">By automating UI testing we simulate the user actions and assure that everything is how we expect. Use testing frameworks to make it easier, like Espresso or UI Automator as well as Mockito to mock your data and not get fooled by unpredictable external APIs content. Embrace the reliability that it can offer and be more confident to do changes in your code. Enjoy! <\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Since I started building apps I was sure of only two things: one is that I love seeing users enjoying my apps; and the second is that I hate seeing users clicking everywhere and crashing them. So how can I be sure that my users will be able to have a joyful experience (even with [&hellip;]<\/p>\n","protected":false},"author":65,"featured_media":5718,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[432,1162],"tags":[],"class_list":["post-5732","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-engineering","category-process"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Android automated UI tests | Cheesecake Labs<\/title>\n<meta name=\"description\" content=\"I hate seeing users clicking everywhere and crashing them. So how can I be sure that my users will be able to have a joyful experience? By testing them!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Android automated UI tests | Cheesecake Labs\" \/>\n<meta property=\"og:description\" content=\"I hate seeing users clicking everywhere and crashing them. So how can I be sure that my users will be able to have a joyful experience? By testing them!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Cheesecake Labs\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/cheesecakelabs\" \/>\n<meta property=\"article:published_time\" content=\"2017-11-17T20:59:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-01T17:24:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2017\/11\/banner_fran.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2000\" \/>\n\t<meta property=\"og:image:height\" content=\"710\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Cheesecake Labs\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@cheesecakelabs\" \/>\n<meta name=\"twitter:site\" content=\"@cheesecakelabs\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/\"},\"author\":{\"name\":\"Francieli Lima\"},\"headline\":\"Android automated UI tests: the baby steps\",\"datePublished\":\"2017-11-17T20:59:41+00:00\",\"dateModified\":\"2022-07-01T17:24:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/\"},\"wordCount\":562,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2017\/11\/banner_fran.png\",\"articleSection\":[\"Engineering\",\"Process\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/\",\"url\":\"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/\",\"name\":\"Android automated UI tests | Cheesecake Labs\",\"isPartOf\":{\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2017\/11\/banner_fran.png\",\"datePublished\":\"2017-11-17T20:59:41+00:00\",\"dateModified\":\"2022-07-01T17:24:57+00:00\",\"author\":{\"@type\":\"person\",\"name\":\"Francieli Lima\"},\"description\":\"I hate seeing users clicking everywhere and crashing them. So how can I be sure that my users will be able to have a joyful experience? By testing them!\",\"breadcrumb\":{\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/#primaryimage\",\"url\":\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2017\/11\/banner_fran.png\",\"contentUrl\":\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2017\/11\/banner_fran.png\",\"width\":2000,\"height\":710,\"caption\":\"automated UI tests\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cheesecakelabs.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Android automated UI tests: the baby steps\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/#website\",\"url\":\"https:\/\/cheesecakelabs.com\/blog\/\",\"name\":\"Cheesecake Labs\",\"description\":\"Nearshore outsourcing company for Web and Mobile design and engineering services, and staff augmentation for startups and enterprises..\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cheesecakelabs.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"name\":\"Francieli Lima\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cheesecakelabs.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2017\/01\/francieli1-300x300.jpg\",\"contentUrl\":\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2017\/01\/francieli1-300x300.jpg\",\"caption\":\"Francieli Lima\"},\"description\":\"10 years of experience in Marketing and Sales in the Technology sector. My main purpose is help, support and structure efficient operations and also develop independent and multidisciplinary teams.\",\"url\":\"https:\/\/cheesecakelabs.com\/blog\/autor\/francieli-2\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Android automated UI tests | Cheesecake Labs","description":"I hate seeing users clicking everywhere and crashing them. So how can I be sure that my users will be able to have a joyful experience? By testing them!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/","og_locale":"en_US","og_type":"article","og_title":"Android automated UI tests | Cheesecake Labs","og_description":"I hate seeing users clicking everywhere and crashing them. So how can I be sure that my users will be able to have a joyful experience? By testing them!","og_url":"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/","og_site_name":"Cheesecake Labs","article_publisher":"https:\/\/www.facebook.com\/cheesecakelabs","article_published_time":"2017-11-17T20:59:41+00:00","article_modified_time":"2022-07-01T17:24:57+00:00","og_image":[{"width":2000,"height":710,"url":"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2017\/11\/banner_fran.png","type":"image\/png"}],"author":"Cheesecake Labs","twitter_card":"summary_large_image","twitter_creator":"@cheesecakelabs","twitter_site":"@cheesecakelabs","twitter_misc":{"Written by":null,"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/#article","isPartOf":{"@id":"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/"},"author":{"name":"Francieli Lima"},"headline":"Android automated UI tests: the baby steps","datePublished":"2017-11-17T20:59:41+00:00","dateModified":"2022-07-01T17:24:57+00:00","mainEntityOfPage":{"@id":"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/"},"wordCount":562,"commentCount":0,"image":{"@id":"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/#primaryimage"},"thumbnailUrl":"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2017\/11\/banner_fran.png","articleSection":["Engineering","Process"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/","url":"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/","name":"Android automated UI tests | Cheesecake Labs","isPartOf":{"@id":"https:\/\/cheesecakelabs.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/#primaryimage"},"image":{"@id":"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/#primaryimage"},"thumbnailUrl":"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2017\/11\/banner_fran.png","datePublished":"2017-11-17T20:59:41+00:00","dateModified":"2022-07-01T17:24:57+00:00","author":{"@type":"person","name":"Francieli Lima"},"description":"I hate seeing users clicking everywhere and crashing them. So how can I be sure that my users will be able to have a joyful experience? By testing them!","breadcrumb":{"@id":"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/#primaryimage","url":"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2017\/11\/banner_fran.png","contentUrl":"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2017\/11\/banner_fran.png","width":2000,"height":710,"caption":"automated UI tests"},{"@type":"BreadcrumbList","@id":"https:\/\/cheesecakelabs.com\/blog\/android-automated-ui-tests-baby-steps-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cheesecakelabs.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Android automated UI tests: the baby steps"}]},{"@type":"WebSite","@id":"https:\/\/cheesecakelabs.com\/blog\/#website","url":"https:\/\/cheesecakelabs.com\/blog\/","name":"Cheesecake Labs","description":"Nearshore outsourcing company for Web and Mobile design and engineering services, and staff augmentation for startups and enterprises..","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cheesecakelabs.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","name":"Francieli Lima","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cheesecakelabs.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2017\/01\/francieli1-300x300.jpg","contentUrl":"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2017\/01\/francieli1-300x300.jpg","caption":"Francieli Lima"},"description":"10 years of experience in Marketing and Sales in the Technology sector. My main purpose is help, support and structure efficient operations and also develop independent and multidisciplinary teams.","url":"https:\/\/cheesecakelabs.com\/blog\/autor\/francieli-2\/"}]}},"_links":{"self":[{"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/posts\/5732","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/users\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/comments?post=5732"}],"version-history":[{"count":1,"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/posts\/5732\/revisions"}],"predecessor-version":[{"id":10254,"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/posts\/5732\/revisions\/10254"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/media\/5718"}],"wp:attachment":[{"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/media?parent=5732"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/categories?post=5732"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cheesecakelabs.com\/blog\/wp-json\/wp\/v2\/tags?post=5732"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}