SimpleTestCursor robolectric 3.0— compilation issu

2019-02-27 15:49发布

问题:

I am trying to test the cursor in my app.

But for the following import I get the error message-- cannot resolve symbol tester. I am using Robolectric 3.0. Why the import is not resolving, am I missing some dependency? I have looked internet but no support. Please help.

I am trying to use:this API and following is the import

import org.robolectric.tester.android.database.SimpleTestCursor;

These are my dependencies:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile "org.robolectric:robolectric:3.0"

    testCompile "org.robolectric:shadows-support-v4:3.0"
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.google.code.gson:gson:2.3'
    compile 'com.android.support:support-v4:22.1.0'
    compile 'com.google.android.gms:play-services:7.5.0'
}

回答1:

SimpleTestCursor has been replaced by RoboCursor in version 3 of Robolectric.

Have a look at robolectric/robolectric-shadows/shadows-core/src/main/java/org/robolectric/fakes/RoboCursor.java and robolectric/robolectric/src/test/java/org/robolectric/fakes/RoboCursorTest.java.