Oh Ut Generator logo

Oh Ut Generator

Organization
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.

Overview

Publisheropenharmonyinsight
Repositoryopenharmony-skills
Skill nameoh-ut-generator
Stars
36
Forks
7
Bundled files
13
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 13 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by openharmonyinsight on GitHub. Read the source before you install it.

Installation

Install the Oh Ut Generator AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/openharmonyinsight/openharmony-skills/tree/main/skills/oh-ut-generator
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

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
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Oh Ut Generator in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Oh Ut Generator on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Oh Ut Generator is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Oh Ut Generator AI skill do?

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.

Why use Oh Ut Generator on TypingMind?

Because you install it once and use it with any model. Oh Ut Generator is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Oh Ut Generator in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/openharmonyinsight/openharmony-skills/tree/main/skills/oh-ut-generator. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Oh Ut Generator?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Oh Ut Generator?

As many as you like. As long as a model supports skills, you can use Oh Ut Generator with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Oh Ut Generator AI skill free?

It is published on GitHub by openharmonyinsight. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇