fprime-unit-testing
O que ela faz
Ele guia a IA na criação de arquivos de teste unitário para um componente F Prime, incluindo a classe de teste, os casos de teste e o registro no build. É para engenheiros que testam software de voo F Prime.
Quando usar
- ✓Quando você precisa de testes unitários para um componente F Prime novo ou alterado.
- ✓Quando você quer que a estrutura de testes unitários seja criada para um componente.
- ✓Quando precisa registrar um teste unitário no build CMake.
Link da skill
https://github.com/nasa/fprime/blob/devel/.github/skills/fprime-unit-testing/SKILL.mdCopie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.
Como usar
O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.
Mensagem pronta para colar
Para Claude Code, Codex ou Cursor: rode na pasta do projeto e a skill fica instalada.
Baixe o SKILL.md e coloque na pasta de skills do seu agente.
Exemplo do que pedir para a IA
“Por favor, prepare a estrutura de testes unitários para este componente F Prime e adicione testes para os comandos dele.”
5 skills novas por semana. 1 minuto de leitura.
Como funciona
A IA gera a estrutura de teste, escreve a classe de teste e os casos, registra os testes no build e os executa.
Conteúdo técnico (SKILL.md original)
Texto original do autor, em inglês, direto do 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
Perguntas frequentes
Preciso compilar o componente antes?
Sim. A skill lista um modelo FPP compilado e uma implementação funcional como pré-requisitos.
O que é teste baseado em regras?
É um estilo de teste que a skill recomenda sempre que possível, porque cobre mais terreno do que verificações individuais escritas à mão.
Ele cobre as funções auxiliares de teste?
Sim. Cobre como projetar funções auxiliares como parte da estrutura de teste.
Detalhes
Descrição original do autor
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
Popularidade
- Estrelas no GitHub
- 12 mil
- Posição no ranking
- #11504
- Licença
- Apache-2.0
- Atualizada em
- 02/11/2026
Comentários
- …
Mais skills deste repositório
fprime-cmake-build-system
12 milAjuda seu agente a adicionar módulos, alvos de build e configurações de plataforma a um projeto de software de voo F Prime pela sua camada CMake.
fprime-component-design-fpp
12 milAjuda seu agente a transformar requisitos aprovados de um componente F Prime em um modelo FPP de suas portas, comandos, eventos e telemetria.
fprime-component-development
12 milAjuda seu agente a conduzir um componente F Prime por cada fase de desenvolvimento, desde os requisitos até os testes de integração.
fprime-component-implementation
12 milAjuda seu agente a escrever o código C++ por trás das funções de tratamento geradas de um componente F Prime, seguindo as regras do projeto.
Skills parecidas
test-driven-development
311 milEnsina seu agente a escrever primeiro um teste que falha, ver a falha e depois escrever o menor código que passa, antes de criar qualquer funcionalidade ou correção.
verification-before-completion
311 milEnsina seu agente a rodar verificações reais e ler a saída antes de afirmar que uma tarefa, correção ou build está concluído ou passando.
migrate-to-shoehorn
310 milSubstitui conversões de tipo arriscadas nos seus arquivos de teste pela biblioteca shoehorn, para que os testes usem dados parciais e ainda passem na checagem de tipos.