且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Android单元测试中创建位置?

更新时间:2023-11-17 08:36:52

在您模块中的 build.gradle :

apply plugin: 'com.android.application'

android {
    ...
    testOptions {
        unitTests.returnDefaultValues = true
    }
}

dependencies {

    testImplementation 'junit:junit:4.13.2'
    testImplementation "org.robolectric:robolectric:4.2.1"
    ...
}

您的测试类必须包含以下内容:

Your test class has to contain the following:

@RunWith(RobolectricTestRunner.class)
public class LocationTest {
    ...
}

应该就是这样.