ablake / kotlin-news-for-android

A simple Android app for browsing Kotlin news, meant to demonstrate architectural principles and implement core functionality applicable to most apps.
Apache License 2.0
0 stars 0 forks source link

Add missing instrumented tests #12

Open ablake opened 4 years ago

ablake commented 4 years ago

I took the time to find a way to write instrumented tests for the Kotlin code that's been written so far. Now we need to add more tests to cover all the Activity, Fragment, and Adapter classes that don't have coverage yet.

Some additional background:

Other approaches to using Mockito exist, too, but I've only been using Mockito so far because it's the mocking framework I'm most familiar with. At this point, I decided it would be good to try a framework that's been developed specifically with Kotlin in mind, so I gave MockK a shot. This was much easier to get working! The only caveat is that it requires instrumented tests to run on a device or simulator with Android P (9.0) or above. However, I think that's reasonable enough since it only applies to instrumented tests. It doesn't affect the minSdkVersion of our app.

The upshot of this is that we have a potential strategy for writing instrumented tests. The other variable I'd like to consider is whether or not to use Robolectric, but for now I'd like to see how far we can get without it.