fprime-unit-testing
What it does
It walks the AI through creating unit test files for an F Prime component, including its test class, test cases and build registration. It is for engineers testing F Prime flight software.
When to use it
- βWhen you need unit tests for a new or changed F Prime component.
- βWhen you want the unit test scaffold created for a component.
- βWhen you need a unit test registered in the CMake build.
Skill link
https://github.com/nasa/fprime/blob/devel/.github/skills/fprime-unit-testing/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βPlease set up the unit test scaffold for this F Prime component and add tests for its commands.β
5 new skills a week. 1 minute to read.
How it works
The AI generates the test scaffold, writes the test class and test cases, registers the tests in the build and runs them.
Technical content (original SKILL.md)
Original text by the author, straight from 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
FAQ
Do I need to compile the component first?
Yes. The skill lists a compiled FPP model and a working implementation as prerequisites.
What is rules-based testing?
It is a testing style the skill recommends where possible, because it covers more ground than individual hand-written checks.
Does it cover the test helper functions?
Yes, it covers how to design helper functions as part of the test structure.
Details
Original description by the author
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
Popularity
- GitHub stars
- 12k
- Ranking position
- #11504
- License
- Apache-2.0
- Updated
- 11/2/2026
Comments
- β¦
More skills from this repository
fprime-cmake-build-system
12kHelps your agent add modules, build targets and platform settings to an F Prime flight software project through its CMake layer.
fprime-component-design-fpp
12kHelps your agent turn approved F Prime component requirements into an FPP model of its ports, commands, events and telemetry.
fprime-component-development
12kHelps your agent guide an F Prime component through each development phase, from requirements to integration testing.
fprime-component-implementation
12kHelps your agent write the C++ code behind an F Prime component's generated handler functions, following the project's rules.
Similar skills
test-driven-development
311kTeaches your agent to write a failing test first, watch it fail, then write the smallest code that passes, before building any feature or fix.
verification-before-completion
311kTeaches your agent to run real checks and read their output before claiming that a task, fix, or build is complete or passing.
migrate-to-shoehorn
310kReplaces risky type casts in your test files with the shoehorn library, so tests can use partial data and still pass type checks.