Langsung ke konten
Skillpedia
Testing12k Β· #11504

fprime-unit-testing

Fungsinya

Skill ini memandu AI membuat berkas tes unit untuk komponen F Prime, termasuk kelas tes, kasus tes, dan pendaftaran build. Skill ini untuk insinyur yang menguji perangkat lunak penerbangan F Prime.

Kapan dipakai

  • βœ“Saat Anda memerlukan tes unit untuk komponen F Prime yang baru atau yang diubah.
  • βœ“Saat Anda ingin kerangka tes unit dibuat untuk sebuah komponen.
  • βœ“Saat Anda perlu tes unit didaftarkan di build CMake.

Link skill

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

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/nasa/fprime/blob/devel/.github/skills/fprime-unit-testing/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit β†’

Contoh permintaan ke AI

β€œTolong siapkan kerangka tes unit untuk komponen F Prime ini dan tambahkan tes untuk perintahnya.”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

AI membuat kerangka tes, menulis kelas tes dan kasus tes, mendaftarkan tes di build, lalu menjalankannya.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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
Pertanyaan umum

Apakah saya perlu mengompilasi komponen terlebih dahulu?

Ya. Skill ini mencantumkan model FPP yang sudah dikompilasi dan implementasi yang berfungsi sebagai prasyarat.

Apa itu tes berbasis aturan?

Itu adalah gaya pengujian yang direkomendasikan skill ini jika memungkinkan, karena cakupannya lebih luas daripada pemeriksaan manual satu per satu.

Apakah skill ini mencakup fungsi bantu tes?

Ya, skill ini mencakup cara merancang fungsi bantu sebagai bagian dari struktur tes.

Detail

Deskripsi asli dari pembuat

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

Popularitas

Bintang GitHub
12k
Peringkat
#11504
Lisensi
Apache-2.0
Diperbarui
2/11/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa