android-testing-unit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAndroid Testing Unit
Android 单元测试
When To Use
适用场景
- Use this skill when the request is about: android unit test strategy, test viewmodel reducer android, repository unit tests android.
- Primary outcome: Write fast, focused Android unit tests for reducers, use cases, repositories, and lifecycle-safe state holders.
- Handoff skills when the scope expands:
android-testing-uiandroid-ui-states-validation
- 当请求涉及以下内容时使用本技能:Android单元测试策略、Android viewmodel reducer测试、Android repository单元测试。
- 核心成果:为reducers、用例、repositories以及生命周期安全的状态持有者编写快速、针对性强的Android单元测试。
- 范围扩大时需移交的技能:
android-testing-uiandroid-ui-states-validation
Workflow
工作流程
- Scope the risk surface: correctness, security, performance, test depth, or release automation.
- Pick the narrowest verification strategy that still catches the likely regressions.
- Instrument the workflow so failures are actionable rather than just red.
- Run the relevant checks on the showcase apps and packaging outputs.
- Capture any residual risk with explicit follow-up work and owner skills.
- 划定风险范围:正确性、安全性、性能、测试深度或发布自动化。
- 选择最精简同时仍能捕获潜在回归问题的验证策略。
- 为工作流程添加检测能力,确保失败时可定位问题,而非仅显示红色报错。
- 在示例应用和打包输出产物上运行相关检查。
- 记录所有残余风险,并明确后续工作内容和对应的负责技能。
Guardrails
准则
- Prefer reproducible checks in CI over one-off local heroics.
- Fail with a precise remediation path instead of a vague quality gate.
- Keep secrets, signing material, and production credentials out of examples and fixtures.
- Treat performance and security work as engineering tasks with evidence, not folklore.
- 优先使用CI中可复现的检查,而非一次性的本地临时操作。
- 失败时给出明确的修复路径,而非模糊的质量门槛提示。
- 禁止在示例和测试夹具中包含密钥、签名材料和生产环境凭证。
- 将性能和安全工作视为需要证据支撑的工程任务,而非经验之谈。
Anti-Patterns
反模式
- Adding more tests without increasing signal.
- Shipping benchmarks or security scans that no one can reproduce.
- Hard-coding release credentials into build logic.
- Using synthetic metrics with no user-impact interpretation.
- 盲目增加测试数量却不提升测试有效性。
- 发布无人可复现的基准测试或安全扫描结果。
- 在构建逻辑中硬编码发布凭证。
- 使用无用户影响解读的合成指标。
Examples
示例
Happy path
正常场景
- Scenario: Cover reducer and formatter logic in both fixture apps with focused local tests.
- Command:
cd examples/orbittasks-compose && ./gradlew :app:testDebugUnitTest && cd ../orbittasks-xml && ./gradlew :app:testDebugUnitTest
- 场景:通过针对性的本地测试覆盖两个示例应用中的reducer和格式化器逻辑。
- 命令:
cd examples/orbittasks-compose && ./gradlew :app:testDebugUnitTest && cd ../orbittasks-xml && ./gradlew :app:testDebugUnitTest
Edge case
边界场景
- Scenario: Mock sync failures and permission-denied branches without instrumentation.
- Command:
cd examples/orbittasks-compose && ./gradlew :app:testDebugUnitTest
- 场景:无需插桩即可模拟同步失败和权限被拒分支。
- 命令:
cd examples/orbittasks-compose && ./gradlew :app:testDebugUnitTest
Failure recovery
故障恢复
- Scenario: Separate unit-testing requests from UI testing or general architecture cleanup.
- Command:
python3 scripts/eval_triggers.py --skill android-testing-unit
- 场景:将单元测试请求与UI测试或通用架构清理需求区分开。
- 命令:
python3 scripts/eval_triggers.py --skill android-testing-unit
Done Checklist
完成检查清单
- The implementation path is explicit, minimal, and tied to the right Android surface.
- Relevant example commands and benchmark prompts have been exercised or updated.
- Handoffs to adjacent skills are documented when the request crosses boundaries.
- Official references cover the chosen pattern and the main migration or troubleshooting path.
- 实现路径清晰、精简,且对应正确的Android场景。
- 相关示例命令和基准测试提示已执行或更新。
- 当请求跨领域时,已记录向相邻技能的移交说明。
- 官方参考资料覆盖所选模式以及主要的迁移或故障排查路径。