fprime-unit-testing
यह क्या करती है
यह AI को F Prime कंपोनेंट के यूनिट टेस्ट फ़ाइलें बनाने के चरणों में ले जाती है, जिनमें टेस्ट क्लास, टेस्ट केस और बिल्ड रजिस्ट्रेशन शामिल हैं। यह F Prime फ़्लाइट सॉफ़्टवेयर का टेस्ट करने वाले इंजीनियरों के लिए है।
कब इस्तेमाल करें
- ✓जब किसी नए या बदले गए F Prime कंपोनेंट के लिए यूनिट टेस्ट चाहिए।
- ✓जब आप किसी कंपोनेंट के लिए यूनिट टेस्ट स्कैफ़ोल्ड बनवाना चाहते हैं।
- ✓जब आपको CMake बिल्ड में यूनिट टेस्ट रजिस्टर करना हो।
Skill का लिंक
https://github.com/nasa/fprime/blob/devel/.github/skills/fprime-unit-testing/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“कृपया इस F Prime कंपोनेंट के लिए यूनिट टेस्ट स्कैफ़ोल्ड सेट कीजिए और उसके कमांड के लिए टेस्ट जोड़िए।”
हर हफ़्ते 5 नई skills, 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
- 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
अक्सर पूछे जाने वाले सवाल
क्या पहले कंपोनेंट को कंपाइल करना होगा?
हाँ। स्किल कंपाइल किए हुए 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
- अपडेट की गई
- 2/11/2026
कमेंट
- …
इस repository की और skills
fprime-cmake-build-system
12kयह आपके एजेंट को F Prime फ़्लाइट सॉफ़्टवेयर प्रोजेक्ट की CMake लेयर के ज़रिए मॉड्यूल, बिल्ड टार्गेट और प्लेटफ़ॉर्म सेटिंग जोड़ने में मदद करती है।
fprime-component-design-fpp
12kयह आपके एजेंट को स्वीकृत F Prime कंपोनेंट की आवश्यकताओं को उसके पोर्ट, कमांड, इवेंट और टेलीमेट्री के FPP मॉडल में बदलने में मदद करती है।
fprime-component-development
12kयह आपके एजेंट को F Prime कंपोनेंट को आवश्यकताओं से लेकर इंटीग्रेशन टेस्टिंग तक हर विकास चरण में आगे बढ़ाने में मदद करती है।
fprime-component-implementation
12kयह आपके एजेंट को F Prime कंपोनेंट के जनरेट हुए हैंडलर फ़ंक्शन के पीछे का C++ कोड प्रोजेक्ट के नियमों के अनुसार लिखने में मदद करती है।
मिलती-जुलती skills
test-driven-development
311kयह आपके एजेंट को किसी भी फ़ीचर या सुधार से पहले पहले असफल होने वाला टेस्ट लिखना, उसे असफल होते देखना, फिर पास करने वाला सबसे छोटा कोड लिखना सिखाती है।
verification-before-completion
311kयह आपके एजेंट को किसी काम, सुधार या build के पूरा या पास होने का दावा करने से पहले असली जांच चलाकर उसका आउटपुट पढ़ना सिखाती है।
migrate-to-shoehorn
310kआपकी टेस्ट फ़ाइलों में जोखिम भरे type casts की जगह shoehorn लाइब्रेरी लगाती है, ताकि टेस्ट अधूरे डेटा से भी type checks पास कर सकें।