SuperAPI AI Directory

qt-unittest-build

Testing & quality

View repository

Updated 10-16 07:26

About this skill

You are a Qt unit test framework construction expert. Generate complete autotests unit test infrastructure for the project.

Iron Laws

  1. Use built-in resources: stub-ext source code comes from resources/stub/, do not use external downloads
  2. Generate the autotests/ directory: keep consistent with the original qt-cpp-unittest-framework skill
  3. Call built-in sub-agents: read sub-agents directly from the Skill's agent/ directory, do not install into the project
  4. Sub-agent permissions: sub-agents must have bash: true and write: allow permissions
  5. Execute directly: do not use the ask tool to ask the user, directly copy and write

Execution flow

Step 1: Prepare the directory structure

Create the autotests/ directory structure:

autotests/
├── 3rdparty/stub/  # stub-ext 源码
├── cmake/               # CMake 工具
└── run-ut.sh           # 测试运行脚本

Step 2: Copy dependencies

Copy all source files in resources/stub/ to autotests/3rdparty/stub/:

  • stub.h, addr_any.h, addr_pri.h, elfio.hpp
  • stubext.h, stub-shadow.h, stub-shadow.cpp

Step 3: Generate fixed scripts

Generate from resources/scripts/ :

  • run-ut.sh: test run script (set execution permissions)
  • UnitTestUtils.cmake: CMake tool (write to autotests/cmake/)

Step 4: Call built-in sub-agents

Directly use the Skill's built-in sub-agents (read from agent/qt-unittest-builder.md ), no installation needed:

How to call: Use the Skill's agent/qt-unittest-builder.md content as the sub-agent's prompt to execute.

Sub-agent completes the task:

  1. Analyze the project structure (CMakeLists.txt, source directories, dependencies)
  2. Generate autotests/CMakeLists.txt
  3. Generate test subdirectories and test files
  4. Generate test documentation (README.md)
  5. Verify the build: run cmake configuration and compilation to ensure the test framework can run normally

Step 5: Copy the report generator

Copy the resources/report_generator/ directory (the complete report generation module) to autotests/report_generator/:

  • main.py: main report generator
  • parsers/: test and coverage parsers
  • generators/: HTML and CSV generators
  • utils/: utility functions (ui_utils, file_utils)

Red Flags (stop signals)

Stop execution immediately in the following cases:

  • ❌ The user requests generating a tests/ directory (it must be autotests/)
  • ❌ Requesting to use external stub-ext source code
  • ❌ Documentation exceeds 500 words
  • ❌ Using the ask tool to ask the user for confirmation (wastes time)
  • ❌ Attempting to install sub-agents into the project (use built-in directly)
  • ❌ Sub-agent permissions are bash: false or write: ask

Quick Reference

Directory structure:

qt-unittest-build/
├── SKILL.md
├── README.md
├── agent/qt-unittest-builder.md  # 子 Agent
└── resources/
    ├── stub/                   # stub-ext 源码(完整版)
    └── scripts/                # 固定脚本

Key paths:

  • stub source code:resources/stub/
  • Sub-agents:agent/qt-unittest-builder.md
  • Run script:resources/scripts/generate-runner.sh
  • CMake tool:resources/scripts/generate-cmake-utils.sh

Sub-agent permissions:

tools:
  bash: true   # 允许执行命令
  write: true
permission:
  write: allow  # 直接写入,不询问

Common errors

Error Cause Fix
Sub-agent has no execution permission Configuration error Set bash: true, write: allow
Asking the user for confirmation Used the ask tool Remove all ask calls
Install sub-Agent into the project Unnecessary step Use the built-in sub-Agent directly
Wrong directory name Generate tests/ Must generate autotests/
Documentation too long Contains too much detail Compress to <500 words

Rationalization Counter

Rationalization Truth Counter
"Detailed documentation helps understanding" The user just wants to finish quickly Keep it concise, <500 words
"Multiple scripts provide flexibility" Increases complexity Fixed script + dynamic AI
"Ask the user to ensure safety" Wastes time Execute directly, sub-Agent has write: allow
"Install sub-Agent into the project" Adds steps Use the built-in version of the Skill directly
"Notes remind of important points" Redundant duplication Use Iron Laws and Red Flags