我想使用 JUnit 4 在 android 单元测试中创建一个位置。
和
位置 loc = 新位置(...)
loc 为空。
我如何创建位置?
据我了解,我必须使用以下命令将位置包含在 build.gradle 依赖项中
测试编译'...'
但我找不到要包含的内容。
你能帮我吗?
提前致谢。
在你的模块中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"
...
}
您的测试类必须包含以下内容:
@RunWith(RobolectricTestRunner.class)
public class LocationTest {
...
}
应该就是这样。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)