fprime-unit-testing
하는 일
테스트 클래스, 테스트 사례, 빌드 등록을 포함해 F Prime 컴포넌트의 단위 테스트 파일을 만드는 과정을 AI가 진행하도록 안내합니다. F Prime 비행 소프트웨어를 테스트하는 엔지니어를 위한 스킬입니다.
사용하는 경우
- ✓새 또는 변경된 F Prime 컴포넌트에 단위 테스트가 필요할 때.
- ✓컴포넌트를 위한 단위 테스트 골격을 만들고 싶을 때.
- ✓단위 테스트를 CMake 빌드에 등록해야 할 때.
스킬 링크
https://github.com/nasa/fprime/blob/devel/.github/skills/fprime-unit-testing/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 Unit Testing
Step-by-step procedure for writing high-quality unit tests for an F Prime component. The full reference for scaffolding, assertion macros, helper functions, TestMain structure, and CMakeLists registration is in the unit testing guide. Follow the guide for implementation details; this skill adds the workflow order and quality criteria.
0 — Prerequisites
| Item | Required |
|---|---|
| Component FPP model compiled | Yes |
Build cache generated (fprime-util generate --ut) |
Yes |
| Component implementation compiles | Yes |
1 — Scaffold, implement, register, run
- Scaffold:
fprime-util impl --ut— rename.templatefiles, delete auto-generated*Ac.*/*GTestBase.*. - Tester class: inherit
<Component>GTestBase, add test methods and helper functions. See Tester class structure and helper functions. - TestMain:
TEST()macros withCOMMENT(...)/REQUIREMENT(...), seedSTest::Random. See TestMain. - CMakeLists.txt:
register_fprime_ut(...)withUT_AUTO_HELPERSandDEPENDS STest. See CMakeLists.txt registration. - Build & run:
fprime-util build --ut,fprime-util check,fprime-util check --coverage. - Consolidate: once the new tests pass, re-read the test diff as
a reviewer would and refactor before opening the PR:
- fold repeated invoke → assert sequences shared by two or more
tests into a Tester helper, or into an existing rule when the
component already has
test/ut/Rules/; - reuse existing helpers and rules before adding new ones;
- drop tests that do not verify the behavior the task added or changed (note remaining coverage gaps as future work);
- re-run
fprime-util checkto confirm nothing regressed.
- fold repeated invoke → assert sequences shared by two or more
tests into a Tester helper, or into an existing rule when the
component already has
2 — Key patterns to enforce
clearHistory()at the start of every test action.component.doDispatch()after every async invocation on active/queued components.- Helper functions for all port invocations and assertion groups —
no raw
invoke_to_*+ASSERT_*in test methods. STest::Pick::any()for port numbers, IDs, sizes where the specific value does not matter.
3 — Rules-based testing (preferred for complex components)
| Criteria | Simple tests | Rules-based |
|---|---|---|
| Few ports, no state machine | Preferred | Overkill |
| Multiple interacting ports | Possible | Preferred |
| Stateful behavior (counters, modes) | Difficult | Preferred |
| Need random / fuzzing coverage | Not possible | Required |
Core constructs (all from TestUtils/RuleBasedTesting.hpp):
FW_RBT_DEFINE_RULE(TesterClass, Group, Rule)— declares a precondition/action pair and a rule struct on the Tester.- Shadow state — a Tester member mirroring observable component state; queried in preconditions, updated in actions.
- Scenarios —
RandomScenario(picks applicable rule at random),BoundedScenario(wraps another, stops after N steps),SequenceScenario(fixed order).
Scaffold with fprime-util new --rule-based-test. For file layout,
implementation patterns, and full examples see the
rules-based testing guide
and the Svc/Ccsds/ApidManager exemplar.
Build note: add every Rules/<GroupName>.cpp and
TestState/TestState.cpp to the SOURCES list in CMakeLists.txt
and include DEPENDS STest.
4 — Quality checklist
- Every input port has at least one test
- Every command has nominal + error-path tests
- Every event asserted (emitted and not-emitted)
- Every telemetry channel asserted after its update action
-
clearHistory()at start of each test action -
doDispatch()after every async invocation on active/queued components - Helper functions used — no raw
invoke_to_*+ASSERT_*in test methods -
STest::Pickfor port numbers, IDs, sizes where specific
자주 묻는 질문
컴포넌트를 먼저 컴파일해야 하나요?
네. 스킬은 컴파일된 FPP 모델과 작동하는 구현을 전제 조건으로 나열합니다.
규칙 기반 테스트가 무엇인가요?
가능하면 스킬이 권장하는 테스트 방식으로, 개별 수작업 검사보다 더 넓은 범위를 다룬다고 설명합니다.
테스트 도우미 함수도 다루나요?
네. 테스트 구조의 일부로 도우미 함수를 설계하는 방법을 다룹니다.
상세 정보
작성자의 원본 설명
Write F Prime component unit tests. Covers scaffold generation via `fprime-util impl --ut`, the Tester / TestMain / GTestBase pattern, rules-based testing with STest, helper-function design, and the CMakeLists.txt registration. Use whenever creating or extending unit tests for an F Prime component.
repo: nasa/fprime
인기도
- GitHub 스타
- 12k
- 순위
- #11504
- 라이선스
- 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++ 코드를 프로젝트 규칙에 맞춰 작성하도록 돕습니다.
비슷한 스킬
test-driven-development
311k에이전트가 기능이나 수정을 만들기 전에 실패하는 테스트를 먼저 쓰고, 그것을 통과시키는 가장 작은 코드를 작성하도록 가르칩니다.
verification-before-completion
311k에이전트가 작업, 수정, 빌드가 완료되었거나 통과했다고 말하기 전에 실제 점검을 실행하고 결과를 읽도록 가르칩니다.
migrate-to-shoehorn
310k테스트 파일의 위험한 타입 캐스팅을 shoehorn 라이브러리로 바꿔, 테스트가 일부 데이터만 써도 타입 검사를 통과하도록 돕습니다.