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
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
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. Use when this capability is needed.4---56# C API Test Naming Verifier Skill78This 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.910## Naming Convention1112### Primary Pattern: `methodNameTestScenario`1314- **methodName**: Method name being tested, preserving original casing and underscores15 - camelCase methods: `setEnableHapticFeedback`16 - Underscored methods: `set_onChangeEvent_selected` (preserve underscores!)17- **Test**: Literal "Test" with capital T18- **Scenario**: Descriptive scenario in PascalCase (e.g., `InvalidValues`, `DefaultValues`)1920### Special Cases21221. **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)3132## Usage3334### Basic Verification3536```bash37claude-code skill capi-test-naming-verifier --verify38```3940### Generate Detailed Report4142```bash43claude-code skill capi-test-naming-verifier --report44```4546### Scan Specific Directory4748```bash49claude-code skill capi-test-naming-verifier --directory test/unittest/capi/modifiers50```5152### Check Specific File5354```bash55claude-code skill capi-test-naming-verifier --file test/unittest/capi/modifiers/common_method_modifier_test2.cpp56```5758## Validation Rules59601. **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 camelCase642. **"Test" Placement**: Appears between method name and scenario65 - 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 characters695. **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)7374## Excluded Directories7576- `test/unittest/capi/modifiers/generated/` - Auto-generated tests77- Any other generated test directories7879## Implementation8081The skill performs automated verification through:82831. **File Discovery**: Recursively find all `.cpp` test files in C API directories842. **Pattern Extraction**: Extract test names from `HWTEST_F` macros853. **Validation**: Check each test name against naming rules864. **Reporting**: Generate compliance report with violations and suggestions8788## Integration with Existing Skills8990- **capi-test-fixer**: Can be used to fix naming violations91- **tdd**: Provides test writing guidelines92- **openharmony-build**: Build verification after naming fixes9394## Common Violations9596- **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 characters100- **@tc.name mismatch**: Documentation tag doesn't match test name101- **Method name mismatch**: Method name in test doesn't match methods called in test body102 - 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 camelCase105 - 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 name108 - 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 scenario111112## Acceptable Patterns (NOT Violations)113114- **Double/triple "Test"**: When method name contains "Test", multiple occurrences are OK115 - `setHitTestBehaviorTestValidInput` ✅116 - `setOnChildTouchTestTestValidCallback` ✅117- **Underscored method names**: Must be preserved exactly as in C API118 - `set_onChangeEvent_selectedTestValidCallback` ✅119- **DefaultValues tests without method calls**: Tests verifying default state don't need method invocations120121## Output Examples122123### Compliance Report124```125C API Test Naming Compliance Report126===================================127Scanned files: 317128Total tests: 934129Compliant tests: 934 (100%)130Violations: 0131```132133### Violation Report134```135Violations found in test/unittest/capi/modifiers/common_method_modifier_test2.cpp:136 Line 123: setResponseRegionTest → Should be setResponseRegionTestDefaultValues137 Line 145: SetEnableHapticFeedbackTestInvalidValues → Should be setEnableHapticFeedbackTestInvalidValues138139Violations found in test/unittest/capi/modifiers/progress_modifier_test.cpp:140 Line 620: ProgressModifierTest::setStyleCapsuleTestValidBorderRadiusValues141 ❌ Method name mismatch: Test name has 'setStyleCapsule' but test body calls 'setStyle'142 ❌ Suggested test name: 'setStyleTestCapsuleValidBorderRadiusValues'143```144145## Best Practices1461471. **Run verification after adding new tests**: Ensure new tests follow naming convention1482. **Use during code reviews**: Check naming compliance before merging1493. **Integrate with CI**: Add naming verification to continuous integration pipeline1504. **Regular audits**: Periodically verify existing test names151152## Limitations153154- Cannot automatically fix naming violations (use capi-test-fixer for fixes)155- Requires manual review for scenario appropriateness156- Does not verify test logic or implementation157- 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_->` patterns159160---161> Converted and distributed by [TomeVault](https://tomevault.io/claim/eclipse-oniro-mirrors) — claim your Tome and manage your conversions.162<!-- tomevault:4.0:skill_md:2026-04-14 -->