I’m currently working on a personal Android project using Kotlin and Android Studio, following a basic MVVM architecture:
─main
│ ├───java
│ │ └───com
│ │ └───example
│ │ └───project_name
│ │ ├───data
│ │ ├───db
│ │ ├───repository
│ │ ├───ui
│ │ │ └───adapter
│ │ └───viewmodel
I have worked with Hexagonal architecture and Test-Driven Development (TDD) at work, which makes testing pretty straightforward. However, this is my first time doing Android/Kotlin and MVVM for a personal project. I also did some WPF with C# and LINQ before, but the structure is a bit different and, shamefully, I didn’t do much testing nor develop with a TDD approach back then.
My questions are:
Which classes/components are the most important to test?
I’m guessing the business logic is in the data layer. I also test the ViewModels. Is there anything else worth testing, or is it useless?Is it worth testing UI elements (buttons, adapters) with unit tests, or only with UI/integration tests?
(Not even sure that I’m going to test UI.)
Also, if you wonder why I didn’t do Hexagonal architecture here, it’s because I unfortunately couldn’t get it to fit well in Android Studio, so I followed the basic MVVM pattern to have a working app I can actually use before I die 😆.
Any advice on how to effectively write tests and do TDD in Android MVVM projects is very welcome!
Thanks a lot!