SuperAPI AI 工具集

cometchat-android-v6-testing

测试与质量

查看项目

更新于 10-16 05:48

技能介绍

用途:测试 CometChat UIKit v6 的组件与 ViewModel,覆盖核心模块单元测试、Compose UI 测试、Views 的 Espresso 测试以及 Maestro 端到端测试,并配置对应的 CI 流水线。

主要能力:提供单元测试依赖与配置(JUnit、Kotest、Mockito、kotlinx-coroutines-test、arch core testing),用于测试 chatuikit-core 中共享的 ViewModel/DataSource/Repository/Events;用 kotest 属性测试验证类似 BubbleFactory key 的格式;用 createComposeRule 写 Compose UI 测试,用 ActivityScenarioRule + Espresso 写 Views 测试;用 Maestro YAML 流程做端到端测试;并提供 GitHub Actions 的单元测试与仪器测试示例(./gradlew testDebugUnitTest、./gradlew connectedDebugAndroidTest)。

使用方式:在模块 Gradle 中引入测试依赖;对 Kotest 需在 testOptions 中启用 useJUnitPlatform()。单元测试用 runTest 和 mock 的 DataSource/Repository,不进行真实 SDK 调用,也不初始化 CometChat SDK。Compose 测试的 setContent 必须用 CometChatTheme {} 包裹。Espresso 测试通过 ActivityScenarioRule 启动 Activity 并用 onView 断言。Maestro 测试放在 master-app-jetpack/ai-testing/ 目录,使用 maestro test maestro/login_flow.yaml 运行。

适用场景:修改或新增 ViewModel、Compose 组件、Kotlin Views 组件时编写对应层级的测试;搭建 CI 时区分单元测试与模拟器上的仪器测试。

限制:不用于排查运行时问题(应使用 cometchat-android-v6-troubleshooting),也不用于组件 API 使用(应使用对应 cometchat-*-components 技能)。具体 API 细节、版本号与完整示例请参考资料原文,本文未逐条展开。