Today we will not focus on architecture, but keep in mind that it is an integral part of writing good tests. If you cannot find an easy way to test your code, chances are that your code has some structural flaws. In most cases, writing tests should be straightforward. This will be a very practical article, but before we start, I would like to spend a few moments on a topic that can't be ignored when talking about testing software. Note: We will be using the new Coroutines Test API, which was released in routines 1.6.0. The branch finish contains all the tests that we will write in this article. If you would like to follow along with this article, the repository has a branch start, which doesn't have any tests and will be our starting point. I have used the MVVM design pattern for the app with the following tech stack: The app consists of two screens - an activity screen where the user can generate a random activity and save it to a database and a second screen where the user can see a list of all saved activities and delete them if they wish. This app uses the free BoredAPI to fetch a random activity and allows the user to save this activity to a database as a favorite for later browsing. The project for today's purposes will be a sample app named Boredom Buster. The goal of this article is to create a comprehensive guide to Android testing, which can be studied and referred to as needed. There is too much information for that, especially for junior developers. Since we will be covering all aspects of testing an Android application, this article is not meant to be consumed in one sitting. We will take a small sample project without any tests and, in the end, have a fully tested application. That said, even though we will talk a bit about theory, the main goal of this article is to see how Android testing works in practice. Moreover, tests - or the inability to write them - can shine a light on architectural flaws, inciting developers to step up their game and write better code. Tests can be a safety net and confidence boosters during complicated refactors and rewrites. Tests can act as supplementary documentation that explains the expected behavior of the software. On the other hand, writing tests is an integral part of a project and shouldn't be treated less seriously than the code that makes the wheels turn.Īpart from actually testing the code functionality, there are many other benefits to writing tests. On the one hand, writing tests takes time, and it might not feel as rewarding - you cannot show a test to a client as you can a new feature. Testing is quite a fascinating topic in software development.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |