levibostian / AndroidBlanky

Create a new Android app fast. Comes pre-installed with libraries you already use.
7 stars 0 forks source link

Robolectric #61

Closed levibostian closed 4 years ago

levibostian commented 4 years ago

Tests can be run with Robolectric for Android tests.

Todo:

I am thinking that: Robolectric tests are great for unit tests. We test the UI of our code as unit tests (does X view exist?) kind of stuff. With this in mind, we want to decide to change the way we are running these tests (which will fix the problems we are currently facing). Instead of trying to use Teller initialization, for example, we save that only for the Android UI tests code that tests the UI with screenshots while we mock the ViewModel layer for robolectric unit tests?

This idea came from iOS where I write unit tests for the Views of the app and View controllers (fragments/activities essentially) and I mock the ViewModel for the unit tests just to test that certain views are shown and others are not. I concentrate my tests on just the 1 View class. True Android integration tests should run on the device because it's as close to the real thing as possible by running on the device. Also, we don't need to deal with the whole mess of robolectric. These tests can take screenshots, can test E2E fully, and can run on the device. Having this separation would be great for many benefits that I personally see when I do iOS dev. The UI tests and unit tests on Views in iOS is very slick and has many benefits. Duplicating that here would work well and use the tools that we have to the best of their ability.

Resources: