شعار Oh Ut Generator

Oh Ut Generator

مؤسسة
openharmonyinsight
oh-ut-generator

Generate OpenHarmony C++ unit tests following HWTEST_F framework conventions. Supports Mock strategies, BUILD.gn configuration, NDK/NAPI interfaces, and maintains 75%+ coverage requirements with strict code style consistency. Use when generating unit tests for OpenHarmony C++ source files.

نظرة عامة

الناشرopenharmonyinsight
المستودعopenharmony-skills
اسم المهارةoh-ut-generator
النجوم
36
التفريعات
7
الملفات المرفقة
13
الروابط
  • تعليمات بصيغة Markdown

    ملف SKILL.md يُحمّله النموذج عند الحاجة، فلا يستهلك توكنات إلا عندما يَرِد طلب ذو صلة فعلًا.

  • تعمل مع أي نموذج لغوي كبير

    مهارات الذكاء الاصطناعي مكتوبة بصيغة Markdown وليست شيفرة خاصة بمزوّد معيّن، لذا تعمل مع GPT أو Claude أو Gemini أو Grok أو نموذج محلي.

  • الملفات المرفقة: 13

    نصوص برمجية وقوالب ومراجع يمكن للنموذج قراءتها أثناء عمله. الملفات للقراءة فقط ولا تُنفّذ أبدًا.

  • مفتوحة المصدر

    نشرها openharmonyinsight على GitHub. اطّلع على المصدر قبل تثبيتها.

التثبيت

ثبّت مهارة الذكاء الاصطناعي Oh Ut Generator في TypingMind لاستخدامها مع أي نموذج لغوي كبير، أو أضفها إلى وكيل ذكاء اصطناعي آخر يقرأ SKILL.md.

1

التثبيت في TypingMind

يُثبّت TypingMind المهارة مباشرةً من مجلدها على GitHub — فيقرأ SKILL.md، ويجمع ملفات الموارد في حزمة، ويحفظ النتيجة محليًا.

  1. افتح التطبيق وانتقل إلى «الإضافات» ثم «المهارات».
  2. اختر «تثبيت من GitHub».
  3. الصق رابط مجلد المهارة الموضّح أدناه وأكّد التثبيت.
    https://github.com/openharmonyinsight/openharmony-skills/tree/main/skills/oh-ut-generator
  4. فعّل المهارة في كل محادثة تريد إتاحتها فيها.
الإضافات ← المهارات ← إضافة مهارة ← من رابط GitHub، ثم الصق رابط المجلد واضغط على «متابعة».
2

التثبيت في وكيل ذكاء اصطناعي آخر

يمكن لأي وكيل ذكاء اصطناعي يقرأ تنسيق Agent Skills استخدام هذه المهارة — انسخ المجلد إلى مجلد المهارات الخاص بذلك الوكيل.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/openharmonyinsight/openharmony-skills.git /tmp/openharmony-skills
mkdir -p .claude/skills
cp -r /tmp/openharmony-skills/skills/oh-ut-generator .claude/skills/oh-ut-generator
أعد تشغيل Claude Code بعد النسخ ليتعرّف على المهارة الجديدة.

استخدمها في TypingMind

فعّل Oh Ut Generator في أي محادثة على TypingMind وسيتولى النموذج الباقي. تتضمن مطالبة النظام اسمها ووصفها، وبمجرد ورود طلب ذي صلة، يُحمّل النموذج التعليمات الكاملة تلقائيًا — فلا تحتاج إلى استدعائها يدويًا، ولا تستهلك أي توكنات حتى تُستخدم فعليًا.

يُحمّل النموذج مهارة Oh Ut Generator تلقائيًا بمجرد ورود طلب ذي صلة بها.

تعمل مع أي نموذج ذكاء اصطناعي

مهارات الذكاء الاصطناعي هي تعليمات بصيغة Markdown وليست شيفرة خاصة بمزوّد معيّن، لذا لا ترتبط Oh Ut Generator بالنموذج الذي كُتبت له. ثبّتها مرة واحدة في TypingMind واستخدمها مع GPT-5 أو Claude أو Gemini أو Grok أو DeepSeek أو Mistral أو Llama أو نموذج محلي تشغّله بنفسك — كل ذلك باستخدام مفاتيح API الخاصة بك.

  • تُحمَّل عند الحاجة فقط

    تتضمن مطالبة النظام الاسم والوصف فقط. وتُجلب التعليمات عند أول طلب ذي صلة، لذا لا تستهلك تعليمات المهارة أي توكنات ما دامت المهارة غير مستخدمة.

  • بدّل النماذج أثناء المحادثة

    لأن المهارة تعليمات وليست شيفرة، فإن تغيير النموذج لا يعطّلها — فالنموذج التالي يقرأ ملف SKILL.md نفسه.

تعليمات المهارة

هذا هو محتوى SKILL.md الذي يُحمّله النموذج. اقرأه قبل التثبيت — فالمهارة عبارة عن تعليمات سيتبعها نموذجك.

OpenHarmony Unit Test Generator

Overview

Generate comprehensive C++ unit tests for OpenHarmony code following HWTEST_F framework conventions.

Key Features

  • Automatic Test Generation: Create test cases for normal/exception/boundary scenarios
  • Mock Object Support: Mock class creation and EXPECT_CALL/ON_CALL setup
  • BUILD.gn Configuration: Automatic dependency matching with source files
  • Coverage Optimization: 75% minimum coverage, targeting 85%+
  • Code Style Consistency: Maintains consistency with existing test patterns (>=70% threshold)
  • NDK/NAPI Support: Special handling for NDK interfaces (7088+ OH_xxx) and NAPI functions (302+ napi_xxx)
  • CJSON Testing: Complete support for CJSON library testing patterns

Usage

Invoke this skill when you need to generate unit tests for OpenHarmony C++ source files.

Supported Scenarios

  1. Single File Testing: Generate tests for all functions in a source file
  2. Specific Function Testing: Generate tests for a specific function only
  3. Test File Extension: Append new test cases to existing test files
  4. Mock Generation: Automatically create mock classes for dependencies

Critical Requirements

Test Implementation Completeness

  • Complete Implementation Only: Every test case must have complete implementation
  • No Comments-Only Tests: Forbidden to generate tests with only comments or empty bodies
  • Mock Usage: If Mock objects are created, they must be used with EXPECT_CALL/ON_CALL
  • Branch-Assertion Correspondence: Branch assertions must match branch logic exactly

Coverage Requirements

  • Minimum: 75% branch and line coverage (mandatory)
  • Target: 85% branch and line coverage (goal)
  • Scope: Boundary conditions, exception paths, normal paths, all conditional branches

Code Style Consistency

When existing test files exist:

  • Smart Pointer Type: Must match existing code (sptr/wptr vs std::shared_ptr)
  • Mock Usage: Must match existing Mock patterns
  • Assertion Style: Must match existing assertion preferences (EXPECT_ vs ASSERT_)
  • Test Structure: Must match existing test fixtures and naming patterns

Consistency Threshold: >=70% for important scenarios

Security Coding

  • Memory Management: Match original function's smart pointer usage pattern
  • Variable Initialization: All variables must be initialized
  • Boundary Checks: Required before array/container access
  • Null Pointer Checks: Required before pointer dereference
  • Return Value Checks: Required for critical functions

Framework Specifications

HWTEST_F Framework

cpp
// Test fixture structure
class YourServiceTest : public testing::Test {
public:
    static void SetUpTestCase(void);
    static void TearDownTestCase(void);
    void SetUp();
    void TearDown();
    std::shared_ptr<YourService> instance_;
};

// Test case format
HWTEST_F(TestClassName, TestCaseName_001, TestSize.Level1)

Test Case Naming

  • _001: Normal scenario
  • _002: Exception scenario
  • _003: Boundary scenario
  • _004+: Other special scenarios

Object Management

cpp
// Standard smart pointers
SetUp(): instance_ = std::make_shared<YourService>();
TearDown(): instance_ = nullptr;

// OpenHarmony sptr/wptr
SetUp(): instance_ = MakeSptr<YourService>(); // or instance_ = new YourService();
TearDown(): instance_ = nullptr;

Mock Usage

cpp
auto mock = std::make_shared<MockClass>();
EXPECT_CALL(*mock, Method()).WillOnce(Return(value));

Assertions

cpp
ASSERT_NE(instance_, nullptr);  // Must check
EXPECT_EQ(result, expected);
EXPECT_TRUE(condition);

NDK Interface Testing

For NDK interfaces (OH_xxx), follow these requirements:

  1. Resource Lifecycle: Create/Destroy pairing is mandatory
  2. Test Structure: Normal path (001), Exception path (002), Boundary (003)
  3. Return Value Verification: Test all error codes
  4. Parameter Validation: Test null pointers, invalid values, boundaries

CJSON Testing

For CJSON library operations:

  1. Parse Tests: Normal, null pointer, invalid JSON
  2. Get Item Tests: Normal get, non-existent item, type checks
  3. Create Tests: Object, array, value creation
  4. Memory Management: All cJSON objects must be deleted

BUILD.gn Requirements

ohos_unittest Target

gn
ohos_unittest("{CamelCase}Test") {
    module_out_path = "subsystem/module"
    branch_protector_ret = "pac_ret"
    sanitize = {
        integer_overflow = true
        cfi = true
        cfi_cross_dso = true
        debug = false
    }
    sources = ["test_file.cpp"]  # Alphabetically sorted
    include_dirs = ["//include/path"]
    deps = [":source_target"]
    external_deps = [
        "hilog:libhilog",
        "c_utils:utils",
        "googletest:gtest_main"
    ]
    defines = ["private=public"]
}

Configuration Matching

The system automatically extracts source file's BUILD.gn configuration:

  • deps: Must include all source target dependencies
  • external_deps: Must include all external dependencies
  • include_dirs: Must include all include directories
  • defines: Must match source defines (add private=public if needed)

Reference Files

Detailed specifications are available in the references/ directory:

  • framework-specs.md: HWTEST_F framework conventions and test patterns
  • mock-strategies.md: Mock object creation and usage strategies
  • coverage-requirements.md: Coverage metrics and optimization strategies
  • build-gn-rules.md: BUILD.gn configuration and dependency matching
  • assertion-standards.md: Assertion methods and branch correspondence
  • code-style-consistency.md: Consistency requirements with existing tests
  • smart-pointer-usage.md: sptr/wptr vs standard smart pointer usage
  • ndk-napi-testing.md: NDK/NAPI interface testing specifications
  • cjson-testing.md: CJSON library testing patterns
  • security-coding.md: Memory management and secure coding requirements

Examples

See the examples/ directory for:

  • basic-test-example.cpp: Basic test structure and patterns
  • mock-test-example.cpp: Mock object usage examples
  • ndk-test-example.cpp: NDK interface testing examples

الملفات المرفقة

يقرأ النموذج هذه الملفات عند الحاجة ما دامت المهارة محمّلة. وهي متاحة للقراءة ولا تُنفّذ أبدًا.

الأسئلة الشائعة

ماذا تفعل مهارة الذكاء الاصطناعي Oh Ut Generator؟

Generate OpenHarmony C++ unit tests following HWTEST_F framework conventions. Supports Mock strategies, BUILD.gn configuration, NDK/NAPI interfaces, and maintains 75%+ coverage requirements with strict code style consistency. Use when generating unit tests for OpenHarmony C++ source files.

لماذا تستخدم Oh Ut Generator على TypingMind؟

لأنك تثبّتها مرة واحدة وتستخدمها مع أي نموذج. مهارة Oh Ut Generator عبارة عن نص Markdown وليست شيفرة خاصة بمزود بعينه، لذا تعمل المهارة نفسها مع GPT-5 أو Claude أو Gemini أو Grok أو نموذج محلي، ويمكنك تبديل النموذج أثناء المحادثة دون تعطّل المهارة. يعمل TypingMind بمفاتيح API الخاصة بك، فتدفع للمزودين مباشرةً بدلًا من اشتراك لكل مقعد، وتبقى مهاراتك ومحادثاتك في مساحة التخزين الخاصة بك.

كيف أثبّت Oh Ut Generator في TypingMind؟

في TypingMind، افتح «الإضافات»، ثم «المهارات»، ثم اختر «التثبيت من GitHub» والصق https://github.com/openharmonyinsight/openharmony-skills/tree/main/skills/oh-ut-generator. يقرأ TypingMind ملف SKILL.md الخاص بالمهارة، ويجمع ملفاتها ويثبّتها كمهارة يمكنك تفعيلها لكل محادثة على حدة.

ما نماذج الذكاء الاصطناعي التي يمكنها استخدام Oh Ut Generator؟

أي نموذج تربطه في TypingMind. مهارات الذكاء الاصطناعي عبارة عن تعليمات Markdown وليست شيفرة خاصة بمزود بعينه، لذا يمكن لكل من GPT وClaude وGemini وGrok والنماذج المحلية تحميل هذه المهارة عندما يتوافق الطلب معها.

كم نموذج ذكاء اصطناعي يمكنني استخدامه مع Oh Ut Generator؟

أي عدد تريده. ما دام النموذج يدعم المهارات، يمكنك استخدام Oh Ut Generator معه، سواء كان GPT أو Claude أو Gemini أو Grok أو DeepSeek أو Mistral أو Llama أو غيرها، وكل ذلك على TypingMind باستخدام مفاتيح API الخاصة بك.

هل مهارة الذكاء الاصطناعي Oh Ut Generator مجانية؟

نشرها openharmonyinsight على GitHub. راجع المستودع للاطلاع على شروط الترخيص. لا تدفع إلا لمزود الذكاء الاصطناعي الخاص بك مقابل التوكنات التي تستخدمها.

ما هي مهارات الذكاء الاصطناعي؟

مهارة الذكاء الاصطناعي حزمة تعليمات قابلة لإعادة الاستخدام تعلّم نموذج الذكاء الاصطناعي كيفية تنفيذ مهمة محددة. وتتبع تنسيق Agent Skills المفتوح: ملف SKILL.md يتضمن اسمًا ووصفًا، إلى جانب أي نصوص برمجية أو قوالب أو ملفات مرجعية قد يحتاج إليها النموذج. لا يقرأ النموذج التعليمات إلا عندما يتوافق طلبك مع المهارة، لذا لا تترتب على المهارة المثبتة أي تكلفة حتى تُستخدم.

كيف تختلف مهارات الذكاء الاصطناعي عن الإضافات أو موصلات MCP؟

تمنح الإضافة أو موصل MCP النموذج أدوات جديدة يمكنه استدعاؤها، وهي شيفرة تُنفَّذ في مكان ما وتُرجع نتيجة. أما مهارة الذكاء الاصطناعي فتزوّد النموذج بالمعرفة ومنهجية العمل: كيفية التعامل مع مهمة، والخطوات التي ينبغي اتباعها، وما ينبغي أن تكون عليه المخرجات الجيدة. المهارات عبارة عن نصوص Markdown، لذا لا تحتاج إلى خادم أو مفتاح API أو بيئة تشغيل، وتعمل مع أي نموذج.

عرض الكل

أنشئ مساحة عملك للذكاء الاصطناعي الآن

اشترك في نشرتنا الإخبارية لتصلك أخبار الميزات الجديدة والهدايا القادمة 👇