android - 使用 Activity 在 Androidx 上进行 Koin 测试
问题描述
在将样板代码迁移到 AndroidX 后,我正在尝试对其进行一些检测测试。请注意,在迁移之前,它们都有效,但在只有单元测试有效之后,检测的测试在 Null Pointer 异常上崩溃,它不应该。
这是错误:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'io.reactivex.Flowable io.reactivex.Flowable.subscribeOn(io.reactivex.Scheduler)' on a null object reference
02:55:31 V/InstrumentationResultParser: at org.buffer.android.boilerplate.data.interactor.FlowableUseCase.execute(FlowableUseCase.kt:26)
02:55:31 V/InstrumentationResultParser: at org.buffer.android.boilerplate.ui.browse.BrowseBufferoosViewModel.fetchBufferoos(BrowseBufferoosViewModel.kt:25)
02:55:31 V/InstrumentationResultParser: at org.buffer.android.boilerplate.ui.browse.BrowseActivity.onCreate(BrowseActivity.kt:40)
如您所见,在这种情况下,它在我的“UseCase”声明中,获取bufferoos。作为参考,这是失败的类:
这是失败的测试
这是 koin 的 modules.kt
解决方案
推荐阅读
- java - Gradle 多模块项目编译因子模块中提到的依赖项中的“classNotFoundExceptions”而失败
- javascript - 尝试在不使用 NPM 或 webpack 的情况下使用 Vue js 插件
- python - 将字典列表分组为类对象
- amazon-web-services - AWS EC2 import-image:ClientError:磁盘验证失败[我们无权访问给定资源。原因 403 禁止
- web-crawler - 仅将 Nutch 限制为种子路径及其以下网页
- c# - 如何有效地读取流上 JPEG 图像的大小
- ios - 要拨打“8 800 333 68 48”,使用了 UIApplication.shared.open(, completionHandler:),但它拨打了不同的号码。" +8 80 333 68 48"
- image - 使用 react-native-image-crop-tool 在 React Native 中上传时缓存图像不可读
- typescript - 如何转换数组中的每种类型?
- c - MISRA2004-12_8-3 规则对 RHS 操作数 (32u - n) 有静态分析违规,即使有限制检查