Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`RenamingDelegatingContext` is deprecated. How do we test SQLite db now?

As per https://stackoverflow.com/a/13556184/3286489, we could use RenamingDelegatingContext for aiding the SQLite DB unit test for Android development.

However in beginning API level 24, android doc announced that this is now deprecated. So what is the new approach of testing we could do in replacing RenamingDelegatingContext?

like image 694
Elye Avatar asked Oct 11 '16 22:10

Elye


1 Answers

If targetSdkVersion 28, you must add the following to your module's build.gradle:

android {
    ...

    // Gradle automatically adds 'android.test.runner' as a dependency.
    useLibrary 'android.test.runner'

    useLibrary 'android.test.base'
    useLibrary 'android.test.mock'
}

By doing this, RenamingDelegatingContext and other missing classes will be available again.

Source: https://developer.android.com/training/testing/set-up-project

like image 180
MoGa Avatar answered Sep 23 '22 15:09

MoGa