Flow-Test-Observer: 简化 Kotlin Flow 测试的实用工具库
Flow-Test-Observer 是一个用于简化 Kotlin Flow 测试的库,其灵感来源于 RxJava 的 TestSubscriber。该库支持冷/有限流和热/无限流的测试。
使用方法
- 添加 JitPack 仓库
在项目的根目录 build.gradle
文件中的 repositories
代码块中添加 JitPack 仓库:
gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
- 添加依赖
在模块的 build.gradle
文件中添加以下依赖:
gradle
dependencies {
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$latest"
testImplementation "com.github.ologe:flow-test-observer:1.6.0"
}
注意: 将 $latest
替换为 kotlinx-coroutines-test 的最新版本号,并将 1.6.0
替换为您需要的 Flow-Test-Observer 版本号。
74.7KB
文件大小:
评论区