Content Preview
--- name: kotlin-testing description: 使用Kotest、MockK、协程测试、基于属性的测试和Kover覆盖率的Kotlin测试模式。遵循TDD方法论和地道的Kotlin实践。 origin: ECC --- # Kotlin 测试模式 遵循 TDD 方法论,使用 Kotest 和 MockK 编写可靠、可维护测试的全面 Kotlin 测试模式。 ## 何时使用 * 编写新的 Kotlin 函数或类 * 为现有 Kotlin 代码添加测试覆盖率 * 实现基于属性的测试 * 在 Kotlin 项目中遵循 TDD 工作流 * 为代码覆盖率配置 Kover ## 工作原理 1. **确定目标代码** — 找到要测试的函数、类或模块 2. **编写 Kotest 规范** — 选择与测试范围匹配的规范样式(StringSpec、FunSpec、BehaviorSpec) 3. **模拟依赖项** — 使用 MockK 来隔离被测单元 4. **运行测试(红色阶段)** — 验证测试是否按预期失败 5. **实现代码(绿色阶段)** — 编写最少
How to Use
Recommended: Install to project (local)
mkdir -p .claude/skills
curl -o .claude/skills/kotlin-testing.md \
https://raw.githubusercontent.com/affaan-m/everything-claude-code/main/docs/zh-CN/skills/kotlin-testing/SKILL.mdSkill is scoped to this project only. Add .claude/skills/ to your .gitignoreif you don't want to commit it.
Alternative: Clone full repo
git clone https://github.com/affaan-m/everything-claude-codeThen reference at docs/zh-CN/skills/kotlin-testing/SKILL.md
Related Skills
kotlin-coroutines-flows
Kotlin协程与Flow在Android和KMP中的模式——结构化并发、Flow操作符、StateFlow、错误处理和测试。
kotlin-coroutines-flowskotlincoroutinesflows
by affaan-m · everything-claude-code
kotlin-patterns
惯用的Kotlin模式、最佳实践和约定,用于构建健壮、高效且可维护的Kotlin应用程序,包括协程、空安全和DSL构建器。
kotlin-patternskotlinpatterns
by affaan-m · everything-claude-code
kotlin-coroutines-expert
Expert patterns for Kotlin Coroutines and Flow, covering structured concurrency, error handling, and testing.
architecturekotlincoroutines
by sickn33 (Antigravity) · antigravity-awesome-skills
kotlin-specialist
Provides idiomatic Kotlin implementation patterns including coroutine concurrency, Flow stream handling, multiplatform architecture, Compose UI construction, Ktor server setup, and type-safe DSL design. Use when building Kotlin applications requiring coroutines, multiplatform development, or Android with Compose. Invoke for Flow API, KMP projects, Ktor servers, DSL design, sealed classes, suspend function, Android Kotlin, Kotlin Multiplatform.
kotlin-specialistkotlinspecialistapi
by Jeffallan · jeffallan-claude-skills