मुख्य सामग्री पर जाएँ
Skillpedia
टेस्टिंग12k · #11504

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 पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/nasa/fprime/blob/devel/.github/skills/fprime-unit-testing/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

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

  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
अक्सर पूछे जाने वाले सवाल

क्या पहले कंपोनेंट को कंपाइल करना होगा?

हाँ। स्किल कंपाइल किए हुए 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

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

fprime-cmake-build-system

12k

यह आपके एजेंट को F Prime फ़्लाइट सॉफ़्टवेयर प्रोजेक्ट की CMake लेयर के ज़रिए मॉड्यूल, बिल्ड टार्गेट और प्लेटफ़ॉर्म सेटिंग जोड़ने में मदद करती है।

कोडिंगसामान्य कोडिंग

fprime-component-design-fpp

12k

यह आपके एजेंट को स्वीकृत F Prime कंपोनेंट की आवश्यकताओं को उसके पोर्ट, कमांड, इवेंट और टेलीमेट्री के FPP मॉडल में बदलने में मदद करती है।

कोडिंगAPI और सर्वर (backend)

fprime-component-development

12k

यह आपके एजेंट को F Prime कंपोनेंट को आवश्यकताओं से लेकर इंटीग्रेशन टेस्टिंग तक हर विकास चरण में आगे बढ़ाने में मदद करती है।

कोडिंगAPI और सर्वर (backend)

fprime-component-implementation

12k

यह आपके एजेंट को F Prime कंपोनेंट के जनरेट हुए हैंडलर फ़ंक्शन के पीछे का C++ कोड प्रोजेक्ट के नियमों के अनुसार लिखने में मदद करती है।

कोडिंगAPI और सर्वर (backend)

मिलती-जुलती skills