A
A
Alexander Vasilenko2016-02-10 05:54:56
Android
Alexander Vasilenko, 2016-02-10 05:54:56

How do you write unit tests for an Android app?

Particularly interested in database testing techniques. How do you mock bases, how do you mock content, etc. etc.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Ilya Pavlovsky, 2016-02-29
@SanchelliosProg

Previously, I used Robolectric when testing ORMLight, more than enough functionality.
With the release of AndroidStudio Beta 2.0, I abandoned libs (there were problems with Realm integration for Robolectric - using native libs) and I use only boxed methods. + Now there are no star dances with the introduction of jacoco for CodeCoverage, it is already in the box. In general, as needed, I switched to TDD development and it pays for itself very much. And with the new goodies in AndoridStudio, this is done in 2 clicks and with greater simplicity.
If in 2 words about tests. There are 2 folders in your project directory - androidTest and test. androidTest - those tests that need to be run only on the phone (emulator) and nothing else, test - those that do not require mandatory android emulation, but with the help of robolectric, robotium auxiliary utilities ... this can make life very easy. In general, for myself, I was convinced of one thing - if you do not have the task of deploying continuous integration, then you can safely dare androidTest, if there is such a task, then you should immediately go to the test directory and run all the tests there (although the migration of tests will not take a lot of time, crutches with robolectric integration will be enough)
I made sure for myself that you need to write tests, because if you support a product without tests, you will die sooner or later)

K
Konstantin Dovnar, 2016-02-10
@SolidlSnake

Roboelectric
The book Android Best Practices (Godfrey Nolan, Onur Cinar, David Truxall) has an entire chapter on TDD, which also covers working with unit tests.

T
Tiberal, 2016-02-10
@Tiberal

No way =D

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question