Loading...
Loading...
Universal generation template for OpenHarmony XTS test cases. Supports test case generation for various subsystems, API definition parsing, test coverage analysis, and code specification checking. Trigger keywords: XTS, test generation, case generation, test case.
npx skill4agent add openharmonyinsight/openharmony-skills oh-xts-generator-templateUniversal Generation Template for OpenHarmony XTS Test Cases
| Function | Description |
|---|---|
| API Definition Parsing | Parse |
| Test Coverage Analysis | Analyze existing test files, identify covered and uncovered APIs |
| Intelligent Test Generation | Automatically generate test cases compliant with XTS specifications based on test strategies |
| Test Design Document Generation | Simultaneously generate structured test design documents, including test case descriptions, expected results, etc. |
| ArkTS Static Language Syntax Specification Validation | Validate ArkTS static language syntax specifications, including type annotations, field initialization, syntax compatibility, etc. |
| Code Specification Checking | Ensure generated code complies with XTS test specifications |
| Compilation Issue Resolution | Use subagent to execute compilation, automatically fix syntax errors, and monitor compilation completion status |
📖 Detailed Usage: docs/USAGE.md
| Method | Applicable Scenario | Link |
|---|---|---|
| Method 1: General Template | Beginners, simple tasks | USAGE.md |
| Method 2: Subsystem Configuration | Most tasks (Recommended) | USAGE.md |
| Method 3: Custom Configuration | Advanced users, special requirements | USAGE.md |
1. Determine Subsystem Configuration
├─ Check if subsystem configuration file exists
├─ Load general configuration (_common.md)
└─ Load subsystem configuration ({Subsystem}/_common.md)
2. Parse API Definitions (.d.ts + Documentation)
├─ Read API declaration files (.d.ts)
├─ Find and parse API documentation
└─ Comprehensive analysis
3. Reference Existing Cases (Mandatory)
├─ Scan specified paths for existing test files
├─ Analyze code style and specifications
└─ Extract common patterns
4. Analyze Existing Tests (Optional)
├─ Scan test files
├─ Identify covered APIs
└─ Calculate test coverage
5. Generate Test Cases
├─ Apply subsystem-specific rules
├─ Use subsystem-specific templates
└─ Apply code style from existing cases
6. Synchronously Generate Test Design Documents (Mandatory)
├─ Generate detailed design descriptions for each test case
├─ Include test scenarios, test steps, and expected results
├─ Generate structured Markdown documents
└─ Use corresponding naming with test case files
7. Add @tc Comment Block (Mandatory)
├─ @tc.name: camelCase naming, consistent with the it() parameter
├─ @tc.number: {describe_name}_{sequence_number}
├─ @tc.desc: {API_name} {error_code/scenario} test.
└─ Verify consistency between field values and it() parameters
8. Formatting and Validation
├─ Apply code templates
├─ Check syntax specifications
│ ├─ 8.1 Dynamic Syntax Check (when generating dynamic XTS cases)
│ │ └─ Reference specification document: `references/ArkTS_Dynamic_Syntax_Rules.md`
│ └─ 8.2 Static Syntax Check (when generating static XTS cases)
│ └─ Reference specification document: `references/arkts-static-spec/`
├─ Validate assertion methods
└─ Output validation results and modification suggestions
9. Register Test Suite (Mandatory for New Files)
├─ Find List.test.ets file
├─ Add import statement
└─ Call in testsuite() function
10. Compilation Validation (Important)
├─ Detect runtime environment (Linux/Windows)
├─ Select compilation scheme based on environment
├─ Linux environment: Use subagent to execute compilation, monitor process, automatically fix syntax errors
├─ Windows environment: Automatically select dynamic or static compilation mode based on keywords
└─ **Detailed Compilation Process**: See Note 7 "Compilation Environment Detection"
11. Output updated file list, test design documents, and coverage comparison
> 📖 **Detailed Workflow Description**: [docs/ARCHITECTURE.md](./docs/ARCHITECTURE.md)
## Configuration Extension
> 📖 **Detailed Configuration Instructions**: [docs/CONFIG.md](./docs/CONFIG.md)
### Configuration Priority
## Output Specifications
### Test Case Number(`@tc.number`)
### Test Design Document Specifications (Mandatory)
**File Naming Rule**:
**Document Templates and Generation Rules**:
- Standard Template: `modules/L3_Generation/design_doc_generator.md`
- Simplified Template: `modules/L3_Generation/design_doc_templates.md`
### Test Design Document Generation Rules
**1. Synchronous Generation Principle**
- When generating each test case, must synchronously generate corresponding test design document
- Test design documents correspond one-to-one with test cases
- Document content must be consistent with test case implementation
**2. Document Content Completeness**
- Must include detailed descriptions of all test scenarios
- Must include test steps and expected results
- Must explain test environment and preconditions
- Must record change history
**3. Document Format Standardization**
- Use Markdown format
- Follow unified template structure
- Use tables to organize key information
- Keep version information updated
**4. Document Update Mechanism**
- When modifying test cases, must synchronously update test design documents
- Document version number must be incremented
- Changes must be recorded in the change log
### Task Completion Output
After each task is completed, **must** output:
```markdown
## Task Completion Summary
### New Test Files
- `path/to/file1.test.ets` - File description
### New Test Design Documents
- `path/to/file1.test.design.md` - Design document description
### Modified Files
- `path/to/file2.ets` - Modification description
### Test Coverage Statistics
- Number of new test cases: XX
- Number of new test design documents: XX
- Covered APIs: XX📖 Complete Usage Guide: docs/USAGE.md
it()@tc@tc.nameit()@tc.number{describe_name}_{sequence_number}@tc.desc{API_name} {error_code/scenario} test.. @tc.type@tc.size@tc.levelit()describe, it, expectTestType, Level, SizebeforeAll, afterAllentry/src/ohosTest/ets/test/cd {OH_ROOT}/test/xts/acts/testfwk/{test_suite}
pwd # Must confirm current directory./# ✅ Correct: Use explicit relative path
rm -rf ./.hvigor ./build ./entry/build ./oh_modules
rm -f ./oh-package-lock.json5 ./local.properties
# ❌ Incorrect: No path prefix (may accidentally delete OH_ROOT/build)
rm -rf buildrm -rf buildmodules/L4_Build/linux_prebuild_cleanup.md@since.d.tsbuild-profile.json5arkTSVersionreferences/arkts-static-spec/build.shhvigorwuname -scleanup_group.sh"6.0.0-arkts1.2-ohosTest-25072102"hvigorw.batBuild → Build OhosTest Hap(s)modules/L4_Build/build_workflow_windows.mdarkts-staArkTS staticarkts staticArkTS staticstatic xtsstatic XTSstatic arktsstatic xtscompile staticstatic compilationstatic project compilationWindows static compilationhvigorw.batmodules/L4_Build/build_workflow_windows.md⚠️ Important Note:
- Dynamic compilation mode is used by default
- Static compilation mode is only enabled when user explicitly mentions static-related keywords
- Static compilation requires configuring Java environment variable (JAVA_HOME)
📖 Detailed Compilation Documents: modules/L4_Build/
📖 Detailed Troubleshooting Guide: docs/TROUBLESHOOTING.md