Saltar al contenido
Skillpedia
Pruebas12 mil · #11504

fprime-unit-testing

Qué hace

Lleva a la IA paso a paso por la creación de archivos de pruebas unitarias para un componente de F Prime, incluidas su clase de prueba, sus casos y su registro en la compilación. Está pensada para ingenieros que prueban software de vuelo de F Prime.

Cuándo usarla

  • ✓Cuando necesitas pruebas unitarias para un componente de F Prime nuevo o modificado.
  • ✓Cuando quieres que se cree la estructura de pruebas unitarias de un componente.
  • ✓Cuando necesitas registrar una prueba unitaria en la compilación de CMake.

Link de la skill

https://github.com/nasa/fprime/blob/devel/.github/skills/fprime-unit-testing/SKILL.md

Cópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.

Cómo usar

La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.

Mensaje listo para pegar

Usa esta skill para ayudarme: https://github.com/nasa/fprime/blob/devel/.github/skills/fprime-unit-testing/SKILL.md Lee el archivo SKILL.md de ese link y sigue sus instrucciones en mi tarea.
¿Quieres que tu IA encuentre skills como esta por sí sola?Instala el MCP gratis de Skillpedia: una línea, y busca entre 15.000+ skills antes de cada tarea.Instalar en 1 minuto →

Ejemplo de qué pedirle a la IA

“Por favor, prepara la estructura de pruebas unitarias de este componente de F Prime y añade pruebas para sus comandos.”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

La IA genera la estructura de pruebas, escribe la clase de prueba y los casos, registra las pruebas en la compilación y luego las ejecuta.

Contenido técnico (SKILL.md original)

Texto original del autor, en inglés, directo de 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
Preguntas frecuentes

¿Necesito compilar el componente primero?

Sí. La skill indica como requisitos previos un modelo FPP compilado y una implementación funcional.

¿Qué son las pruebas basadas en reglas?

Es un estilo de prueba que la skill recomienda cuando es posible, porque cubre más terreno que las comprobaciones individuales escritas a mano.

¿Cubre las funciones auxiliares de las pruebas?

Sí. Explica cómo diseñar funciones auxiliares como parte de la estructura de pruebas.

Detalles

Descripción original del 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

Popularidad

Estrellas en GitHub
12 mil
Posición en el ranking
#11504
Licencia
Apache-2.0
Actualizada
2/11/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas