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に貼り付けるだけ。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エージェントが、CMakeの層を通じて、F Primeの飛行ソフトウェアのプロジェクトにモジュール、ビルドのターゲット、プラットフォームの設定を追加できるよう支援します。
fprime-component-design-fpp
12kエージェントが、承認されたF Primeのコンポーネント要件を、ポート、コマンド、イベント、テレメトリのFPPモデルに変換できるよう支援します。
fprime-component-development
12kエージェントが、要件からインテグレーションテストまで、F Primeのコンポーネントを各開発フェーズで進められるよう支援します。
fprime-component-implementation
12kエージェントが、プロジェクトのルールに従って、F Primeのコンポーネントの自動生成されたハンドラー関数の裏にあるC++のコードを書けるよう支援します。
似ているスキル
test-driven-development
311k機能や修正を作る前に、まず失敗するテストを書き、それが失敗するのを確認してから、合格させる最小のコードを書くようエージェントに教えます。
verification-before-completion
311kタスク、修正、ビルドが完了した、または合格したと主張する前に、実際のチェックを実行し、その出力を読むようエージェントに教えます。
migrate-to-shoehorn
310kテストファイル内の危険な型キャストを、shoehornライブラリに置き換え、テストが部分的なデータを使いつつ型チェックを通るようにします。