https://kotlinlang.org logo
#android
Title
# android
m

MrNiamh

11/19/2018, 8:56 PM
New to android, what's the preferred way of tesing my UI and database correctly interact? I have tests for my Dao, and I have tests for my UI, but I'm unsure how to test that my UI correctly works with my Dao. E.g. clicking the save button correctly saves something to the database.
stackoverflow 1
j

Jake

11/19/2018, 9:01 PM
We write mocked database code to test how the app handles the responses based on the response code. If we get a 200 then app does x if we get a 404 app does x so on and so forth. Then we write tests covering every scenario with mocked data to see how the application handles them all. Our database side writes the tests for the database itself. Aside from that we do a manual test for saves and deletions
m

MrNiamh

11/19/2018, 10:17 PM
With the first thing you mention, is that still using say espresso to test the UI, and then mocking the database out? How exactly do you mock the database out? I'm guessing using some kind of dependency injectrion?
j

Jake

11/19/2018, 10:21 PM
We use Mockito and Esspresso.
m

MrNiamh

11/19/2018, 11:07 PM
How do you mock the db without any depending injection? What does your activity look like?
d

dawidhyzy

11/20/2018, 12:18 AM
>>
Using Kotlin to build Android applications. Android Studio Integration. Android-specific Gradle. If not related to Kotlin, please consider using StackOverflow and/or http://android-united.community/.