본문으로 건너뛰기
Skillpedia
테스트12k · #11504

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가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/nasa/fprime/blob/devel/.github/skills/fprime-unit-testing/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

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

  1. Scaffold: fprime-util impl --ut — rename .template files, delete auto-generated *Ac.* / *GTestBase.*.
  2. Tester class: inherit <Component>GTestBase, add test methods and helper functions. See Tester class structure and helper functions.
  3. TestMain: TEST() macros with COMMENT(...) / REQUIREMENT(...), seed STest::Random. See TestMain.
  4. CMakeLists.txt: register_fprime_ut(...) with UT_AUTO_HELPERS and DEPENDS STest. See CMakeLists.txt registration.
  5. Build & run: fprime-util build --ut, fprime-util check, fprime-util check --coverage.
  6. 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 check to confirm nothing regressed.

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::Pick for 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.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬