android
android copied to clipboard
[New arch] Increase test coverage
We are working on the new architecture, and meanwhile we are creating tests. This way, it will be easier to debug and find potential bugs before merging a PR, or releasing a new version.
Android Studio let us know how many test coverage we have. But only for unit tests. We can check this coverage performing next action:
Once all tests finish, a new tab appears and shows the test coverage in that module. For example, this would be the test coverage for domain module at the moment.
Domain module
This module can be tested completely using unit tests. Coverage Result: 82% lines and 50% classes We have around 100% use cases test coverage and we can improve this general coverage testing those exceptions.
Mobile module
Since this module is where old architecture resides, and most of the tests here are instrumented, the test coverage is pretty low yet.
But if we move to the package where we have started working on new architecture, we can see that those new viewModels have a good test coverage.
Data module
This module is a little bit tricky for test coverage. Since here we have some tests that are instrumented. Result: 16% lines and 38% classes coverage
But we can move to shares package for example. There, we can see that excluding db package where instrumented tests are, unit tests coverage for repository and datasources is around 100%.
To sum up
We have a decent unit test coverage for the new architecture modules but we can easily detect where we can increase it. The goal would be to have around 100% test coverage with unit tests.