fprime-component-unit-test
它能做什么
它指导 AI 为组件的需求、端口、事件和命令规划并编写单元测试。适用于验证 F Prime 飞行软件的工程师。
适用场景
- ✓当 F Prime 组件的实现已就绪,需要单元测试时。
- ✓当你希望遵循测试先行的做法,先编写单元测试时。
- ✓当你希望 F Prime 组件达到较高的代码覆盖率时。
技能链接
https://github.com/nasa/fprime/blob/devel/.github/skills/fprime-component-unit-test/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请为这个 F Prime 组件编写单元测试,覆盖每一项需求。”
每周 5 个新技能,1 分钟读完。
工作原理
AI 会设置测试框架,为每项需求和接口编写测试,运行测试并争取较高的覆盖率;在适合的地方使用基于规则的测试。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Skill: F Prime Component Unit Testing
Unit tests verify each component requirement in isolation using the
autocoded test harness. This skill provides lifecycle context and
goals; for scaffolding, assertion macros, code patterns, and the full
implementation procedure, see fprime-unit-testing and the
unit testing guide.
Goals
- Verify all requirements with unit tests if possible.
- Verify all interfaces: ports, events, telemetry, commands.
- Prefer rule-based testing where possible — it provides broader
coverage than traditional tests. See
fprime-unit-testing§3 for criteria and constructs, and the rules-based testing guide for the full walkthrough. - Target 95% code coverage.
- You should be able to do most of this without user input, since requirements and the FPP model are already defined. However, ask the user for help with predicting edge cases you may have missed or for clarification on expected behavior.
Process
Follow fprime-unit-testing for the step-by-step procedure:
scaffold → implement → register → run. That skill covers Tester
class structure, TestMain layout, CMakeLists registration, assertion
macros, helper functions, and rules-based testing.
Key decisions within the lifecycle:
- Traditional vs. rule-based: Use the criteria table in
fprime-unit-testing§3. Default to rule-based for components with multiple ports or stateful behavior. - TDD: If following test-driven development (tests before implementation), see TDD guide. The FPP model is sufficient to write tests — implementation is not required.
- Coverage: Run
fprime-util check --coverageand review*_gcov.txt. Target 95%.
Anti-Patterns
- Testing only happy paths — off-nominal coverage is critical
- Forgetting
doDispatch()for async commands/ports - Asserting only on count (
SIZE) without checking values - Modifying component internals directly (test through the interface only)
- Guessing expected values — derive from requirements
常见问题
它设定的覆盖率目标是多少?
目标是 95% 的代码覆盖率。
什么是基于规则的测试?
这是该技能在可能时优先采用的一种方法,因为它比传统的手写检查覆盖范围更广。
它需要我的输入吗?
大部分情况不需要,但在预期行为和它可能遗漏的边界情况上,它会请你提供帮助。
详情
作者的原始描述
Unit testing phase of F Prime component development. Provides lifecycle context, goals, and decision criteria for the unit testing phase. Defers to fprime-unit-testing for implementation details. Trigger when implementation is ready for testing or when following TDD (tests before implementation). Keywords: F Prime, unit test, GTest, TesterBase, GTestBase, Tester, fprime-util check, STest, rule-based testing.
repo: nasa/fprime
热度
- GitHub 星标
- 12k
- 排名
- #11499
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
fprime-cmake-build-system
12k帮你的智能体通过 F Prime 项目的 CMake 层,为飞行软件项目添加模块、构建目标和平台设置。
fprime-component-design-fpp
12k帮你的智能体把已批准的 F Prime 组件需求,转化为一个描述其端口、命令、事件和遥测的 FPP 模型。
fprime-component-development
12k帮你的智能体引导 F Prime 组件经历每个开发阶段,从需求一直到集成测试。
fprime-component-implementation
12k帮你的智能体按照项目规则,编写 F Prime 组件自动生成的处理函数背后的 C++ 代码。