I know it is a tedious topic for all android developers. But what exactly is the correct approach to Android Testing?
This is what I can picture.
70% Unit testing (JUnit to test all business logic, network layer, database layer etc...)
20% Integration test (Perhaps testing against mock server? mainly testing API results?)
10% UI testing(mock anything else other than the UI interactions, most likely Mockito+Espresso)
Is this what everyone else is following or there is another pattern?
Thanks in advance!
Unit tests can be performed manually or automated. Those employing a manual method may have an instinctual document made detailing each step in the process; however, automated testing is the more common method to unit tests. Automated approaches commonly use a testing framework to develop test cases.
Unit tests or small tests only verify a very small portion of the app, such as a method or class. End-to-end tests or big tests verify larger parts of the app at the same time, such as a whole screen or user flow. Medium tests are in between and check the integration between two or more units.
By separating the code into different layers and clearly defining borders with abstractions between them, it is possible to test parts of an Android application independently. It is even possible to completely abstract Android SDK from the application's use cases, so they could be reused for a different platform.
In general, Appium and Calabash are good cross-platform frameworks in testing both your Android and iOS versions at the same time. Espresso is a good choice if you are purely testing Android apps.
This question and my answer, doesn't have anything to do with Android specifically but that is a good thing.
I've slightly modified your assumptions, but the principle is the same.
70% Unit testing (JUnit to test all business logic.)
20% Integration test (network layer, database layer etc, real server)
10% UI testing(UI workflow + manual testing)
Should it be 70%? 80%? 85%? It doesn't matter. The key is the ratio. You want the majority of your tests to be fast, isolated in memory tests. If you do interact with a database you simply want to know your queries work. Does the update query actually update the correct entity? Finally you check your UI works as expected. It doesn't matter at this level what you display. As long as the login screen is displayed when the user isn't logged in your fine.
This is often referred to as the Test Pyramid and is what you have described, just minus the explict ratios.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With