C API Test Naming Verifier Skill
This skill verifies that all C API unit test names follow the standardized naming convention methodNameTestScenario. It scans all C API test files (excluding generated tests) and validates compliance with the established naming pattern.
Naming Convention
Primary Pattern: methodNameTestScenario
- methodName: Method name being tested, preserving original casing and underscores
- camelCase methods:
setEnableHapticFeedback
- Underscored methods:
set_onChangeEvent_selected (preserve underscores!)
- Test: Literal "Test" with capital T
- Scenario: Descriptive scenario in PascalCase (e.g.,
InvalidValues, DefaultValues)
Special Cases
- DISABLED tests:
DISABLED_methodNameTestScenario
- Utility tests: Simple names with "Test" suffix (e.g.,
SimpleTypesTest, ArrayTypesTest)
- Conditional compilation: Tests in
#ifdef blocks should have differentiated names (e.g., WithSupport, WithoutSupport)
- Methods containing "Test": When method name contains "Test" (e.g.,
setHitTestBehavior, setOnChildTouchTest), the separator "Test" is still added, resulting in double "Test" - this is acceptable:
setHitTestBehaviorTestValidInput ✅ (double "Test" is OK)
setOnChildTouchTestTestValidCallback ✅ (triple "Test" is OK)
- Underscored method names: Methods with underscores must preserve them:
set_onChangeEvent_selectedTestValidCallback ✅
setOnChangeEventSelectedTestValidCallback ❌ (don't convert underscores)
Usage
Basic Verification
claude-code skill capi-test-naming-verifier --verify
Generate Detailed Report
claude-code skill capi-test-naming-verifier --report
Scan Specific Directory
claude-code skill capi-test-naming-verifier --directory test/unittest/capi/modifiers
Check Specific File
claude-code skill capi-test-naming-verifier --file test/unittest/capi/modifiers/common_method_modifier_test2.cpp
Validation Rules
- Method Name Format:
- camelCase methods: lowercase start (e.g.,
setWidth)
- Underscored methods: preserve underscores (e.g.,
set_onChangeEvent_selected)
- CRITICAL: Never convert underscored method names to camelCase
- "Test" Placement: Appears between method name and scenario
- Usually once:
setWidthTestValidValue
- Multiple times OK if method contains "Test":
setHitTestBehaviorTestValidInput
- Scenario Format: PascalCase, descriptive, non-empty (e.g.,
ValidInput, DefaultValues)
- Length Constraints: Warning if > 100 characters
- DISABLED Prefix: Must be uppercase
DISABLED_
- Method Name Verification: Method name in test name must correspond to actual method calls in test body (e.g.,
accessor_->methodName or modifier_->methodName)
- Preserving underscores is required for match:
set_onChangeEvent_selected matches accessor_->set_onChangeEvent_selected()
- DefaultValues Exception: Tests ending in
DefaultValues don't require method calls (they verify default state)
Excluded Directories
test/unittest/capi/modifiers/generated/ - Auto-generated tests
- Any other generated test directories
Implementation
The skill performs automated verification through:
- File Discovery: Recursively find all
.cpp test files in C API directories
- Pattern Extraction: Extract test names from
HWTEST_F macros
- Validation: Check each test name against naming rules
- Reporting: Generate compliance report with violations and suggestions
Integration with Existing Skills
- capi-test-fixer: Can be used to fix naming violations
- tdd: Provides test writing guidelines
- openharmony-build: Build verification after naming fixes
Common Violations
- Empty scenario: Test name ends with "Test" (e.g.,
setWidthTest should be setWidthTestDefaultValues)
- Missing "Test": No "Test" separator (e.g.,
setWidthValidValues should be setWidthTestValidValues)
- Case violations: Scenario starts with lowercase (e.g.,
setWidthTestvalidValues should be setWidthTestValidValues)
- Name length: Test names longer than 100 characters
- @tc.name mismatch: Documentation tag doesn't match test name
- Method name mismatch: Method name in test doesn't match methods called in test body
- Wrong:
setOnChangeEventSelectedTestValidCallback when test calls set_onChangeEvent_selected()
- Right:
set_onChangeEvent_selectedTestValidCallback matches set_onChangeEvent_selected()
- Underscore conversion: Converting underscored method names to camelCase
- Wrong:
setOnChangeEventSelected (converted from set_onChangeEvent_selected)
- Right:
set_onChangeEvent_selected (preserved original)
- Variant type in method name: Extra descriptors should be in scenario, not method name
- Wrong:
setStyleCapsuleTestValidBorderRadiusValues (treats "Capsule" as part of method name)
- Right:
setStyleTestCapsuleValidBorderRadiusValues ("Capsule" describes the variant being tested)
- Explanation: When method accepts union types, the variant descriptor belongs in scenario
Acceptable Patterns (NOT Violations)
- Double/triple "Test": When method name contains "Test", multiple occurrences are OK
setHitTestBehaviorTestValidInput ✅
setOnChildTouchTestTestValidCallback ✅
- Underscored method names: Must be preserved exactly as in C API
set_onChangeEvent_selectedTestValidCallback ✅
- DefaultValues tests without method calls: Tests verifying default state don't need method invocations
Output Examples
Compliance Report
C API Test Naming Compliance Report
===================================
Scanned files: 317
Total tests: 934
Compliant tests: 934 (100%)
Violations: 0
Violation Report
Violations found in test/unittest/capi/modifiers/common_method_modifier_test2.cpp:
Line 123: setResponseRegionTest → Should be setResponseRegionTestDefaultValues
Line 145: SetEnableHapticFeedbackTestInvalidValues → Should be setEnableHapticFeedbackTestInvalidValues
Violations found in test/unittest/capi/modifiers/progress_modifier_test.cpp:
Line 620: ProgressModifierTest::setStyleCapsuleTestValidBorderRadiusValues
❌ Method name mismatch: Test name has 'setStyleCapsule' but test body calls 'setStyle'
❌ Suggested test name: 'setStyleTestCapsuleValidBorderRadiusValues'
Best Practices
- Run verification after adding new tests: Ensure new tests follow naming convention
- Use during code reviews: Check naming compliance before merging
- Integrate with CI: Add naming verification to continuous integration pipeline
- Regular audits: Periodically verify existing test names
Limitations
- Cannot automatically fix naming violations (use capi-test-fixer for fixes)
- Requires manual review for scenario appropriateness
- Does not verify test logic or implementation
- May flag valid tests with no method calls (e.g., default value checks)
- Cannot detect method calls that don't use
accessor_-> or modifier_-> patterns
1---2name: capi-test-naming-verifier3description: This skill should be used when the user asks to "verify C API test naming", "check test naming convention", "validate test names", "C API test naming compliance", "test naming verification", "ensure test naming consistency", "audit test names", "review test naming", or mentions verifying that C API unit test names follow the standardized naming convention methodNameTestScenario.4---5
6# C API Test Naming Verifier Skill
7
8This skill verifies that all C API unit test names follow the standardized naming convention `methodNameTestScenario`. It scans all C API test files (excluding generated tests) and validates compliance with the established naming pattern.
9
10## Naming Convention
11
12### Primary Pattern: `methodNameTestScenario`
13
14- **methodName**: Method name being tested, preserving original casing and underscores
15 - camelCase methods: `setEnableHapticFeedback`
16 - Underscored methods: `set_onChangeEvent_selected` (preserve underscores!)
17- **Test**: Literal "Test" with capital T
18- **Scenario**: Descriptive scenario in PascalCase (e.g., `InvalidValues`, `DefaultValues`)
19
20### Special Cases
21
221. **DISABLED tests**: `DISABLED_methodNameTestScenario`
232. **Utility tests**: Simple names with "Test" suffix (e.g., `SimpleTypesTest`, `ArrayTypesTest`)
243. **Conditional compilation**: Tests in `#ifdef` blocks should have differentiated names (e.g., `WithSupport`, `WithoutSupport`)
254. **Methods containing "Test"**: When method name contains "Test" (e.g., `setHitTestBehavior`, `setOnChildTouchTest`), the separator "Test" is still added, resulting in double "Test" - this is acceptable:
26 - `setHitTestBehaviorTestValidInput` ✅ (double "Test" is OK)
27 - `setOnChildTouchTestTestValidCallback` ✅ (triple "Test" is OK)
285. **Underscored method names**: Methods with underscores must preserve them:
29 - `set_onChangeEvent_selectedTestValidCallback` ✅
30 - `setOnChangeEventSelectedTestValidCallback` ❌ (don't convert underscores)
31
32## Usage
33
34### Basic Verification
35
36```bash
37claude-code skill capi-test-naming-verifier --verify
38```
39
40### Generate Detailed Report
41
42```bash
43claude-code skill capi-test-naming-verifier --report
44```
45
46### Scan Specific Directory
47
48```bash
49claude-code skill capi-test-naming-verifier --directory test/unittest/capi/modifiers
50```
51
52### Check Specific File
53
54```bash
55claude-code skill capi-test-naming-verifier --file test/unittest/capi/modifiers/common_method_modifier_test2.cpp
56```
57
58## Validation Rules
59
601. **Method Name Format**:
61 - camelCase methods: lowercase start (e.g., `setWidth`)
62 - Underscored methods: preserve underscores (e.g., `set_onChangeEvent_selected`)
63 - **CRITICAL**: Never convert underscored method names to camelCase
642. **"Test" Placement**: Appears between method name and scenario
65 - Usually once: `setWidthTestValidValue`
66 - Multiple times OK if method contains "Test": `setHitTestBehaviorTestValidInput`
673. **Scenario Format**: PascalCase, descriptive, non-empty (e.g., `ValidInput`, `DefaultValues`)
684. **Length Constraints**: Warning if > 100 characters
695. **DISABLED Prefix**: Must be uppercase `DISABLED_`
706. **Method Name Verification**: Method name in test name must correspond to actual method calls in test body (e.g., `accessor_->methodName` or `modifier_->methodName`)
71 - Preserving underscores is required for match: `set_onChangeEvent_selected` matches `accessor_->set_onChangeEvent_selected()`
727. **DefaultValues Exception**: Tests ending in `DefaultValues` don't require method calls (they verify default state)
73
74## Excluded Directories
75
76- `test/unittest/capi/modifiers/generated/` - Auto-generated tests
77- Any other generated test directories
78
79## Implementation
80
81The skill performs automated verification through:
82
831. **File Discovery**: Recursively find all `.cpp` test files in C API directories
842. **Pattern Extraction**: Extract test names from `HWTEST_F` macros
853. **Validation**: Check each test name against naming rules
864. **Reporting**: Generate compliance report with violations and suggestions
87
88## Integration with Existing Skills
89
90- **capi-test-fixer**: Can be used to fix naming violations
91- **tdd**: Provides test writing guidelines
92- **openharmony-build**: Build verification after naming fixes
93
94## Common Violations
95
96- **Empty scenario**: Test name ends with "Test" (e.g., `setWidthTest` should be `setWidthTestDefaultValues`)
97- **Missing "Test"**: No "Test" separator (e.g., `setWidthValidValues` should be `setWidthTestValidValues`)
98- **Case violations**: Scenario starts with lowercase (e.g., `setWidthTestvalidValues` should be `setWidthTestValidValues`)
99- **Name length**: Test names longer than 100 characters
100- **@tc.name mismatch**: Documentation tag doesn't match test name
101- **Method name mismatch**: Method name in test doesn't match methods called in test body
102 - Wrong: `setOnChangeEventSelectedTestValidCallback` when test calls `set_onChangeEvent_selected()`
103 - Right: `set_onChangeEvent_selectedTestValidCallback` matches `set_onChangeEvent_selected()`
104- **Underscore conversion**: Converting underscored method names to camelCase
105 - Wrong: `setOnChangeEventSelected` (converted from `set_onChangeEvent_selected`)
106 - Right: `set_onChangeEvent_selected` (preserved original)
107- **Variant type in method name**: Extra descriptors should be in scenario, not method name
108 - Wrong: `setStyleCapsuleTestValidBorderRadiusValues` (treats "Capsule" as part of method name)
109 - Right: `setStyleTestCapsuleValidBorderRadiusValues` ("Capsule" describes the variant being tested)
110 - **Explanation**: When method accepts union types, the variant descriptor belongs in scenario
111
112## Acceptable Patterns (NOT Violations)
113
114- **Double/triple "Test"**: When method name contains "Test", multiple occurrences are OK
115 - `setHitTestBehaviorTestValidInput` ✅
116 - `setOnChildTouchTestTestValidCallback` ✅
117- **Underscored method names**: Must be preserved exactly as in C API
118 - `set_onChangeEvent_selectedTestValidCallback` ✅
119- **DefaultValues tests without method calls**: Tests verifying default state don't need method invocations
120
121## Output Examples
122
123### Compliance Report
124```
125C API Test Naming Compliance Report
126===================================
127Scanned files: 317
128Total tests: 934
129Compliant tests: 934 (100%)
130Violations: 0
131```
132
133### Violation Report
134```
135Violations found in test/unittest/capi/modifiers/common_method_modifier_test2.cpp:
136 Line 123: setResponseRegionTest → Should be setResponseRegionTestDefaultValues
137 Line 145: SetEnableHapticFeedbackTestInvalidValues → Should be setEnableHapticFeedbackTestInvalidValues
138
139Violations found in test/unittest/capi/modifiers/progress_modifier_test.cpp:
140 Line 620: ProgressModifierTest::setStyleCapsuleTestValidBorderRadiusValues
141 ❌ Method name mismatch: Test name has 'setStyleCapsule' but test body calls 'setStyle'
142 ❌ Suggested test name: 'setStyleTestCapsuleValidBorderRadiusValues'
143```
144
145## Best Practices
146
1471. **Run verification after adding new tests**: Ensure new tests follow naming convention
1482. **Use during code reviews**: Check naming compliance before merging
1493. **Integrate with CI**: Add naming verification to continuous integration pipeline
1504. **Regular audits**: Periodically verify existing test names
151
152## Limitations
153
154- Cannot automatically fix naming violations (use capi-test-fixer for fixes)
155- Requires manual review for scenario appropriateness
156- Does not verify test logic or implementation
157- May flag valid tests with no method calls (e.g., default value checks)
158- Cannot detect method calls that don't use `accessor_->` or `modifier_->` patterns