跳到正文
Skillpedia
测试12k · #11499

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。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/nasa/fprime/blob/devel/.github/skills/fprime-component-unit-test/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 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:

  1. 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.
  2. TDD: If following test-driven development (tests before implementation), see TDD guide. The FPP model is sufficient to write tests — implementation is not required.
  3. Coverage: Run fprime-util check --coverage and 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

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能