name: capi-test-naming-verifier description: 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. version: 1.0.0
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!)
- camelCase methods:
- 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
#ifdefblocks 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
- camelCase methods: lowercase start (e.g.,
- "Test" Placement: Appears between method name and scenario
- Usually once:
setWidthTestValidValue - Multiple times OK if method contains "Test":
setHitTestBehaviorTestValidInput
- Usually once:
- 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_->methodNameormodifier_->methodName)- Preserving underscores is required for match:
set_onChangeEvent_selectedmatchesaccessor_->set_onChangeEvent_selected()
- Preserving underscores is required for match:
- DefaultValues Exception: Tests ending in
DefaultValuesdon'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
.cpptest files in C API directories - Pattern Extraction: Extract test names from
HWTEST_Fmacros - 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.,
setWidthTestshould besetWidthTestDefaultValues) - Missing "Test": No "Test" separator (e.g.,
setWidthValidValuesshould besetWidthTestValidValues) - Case violations: Scenario starts with lowercase (e.g.,
setWidthTestvalidValuesshould besetWidthTestValidValues) - 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:
setOnChangeEventSelectedTestValidCallbackwhen test callsset_onChangeEvent_selected() - Right:
set_onChangeEvent_selectedTestValidCallbackmatchesset_onChangeEvent_selected()
- Wrong:
- Underscore conversion: Converting underscored method names to camelCase
- Wrong:
setOnChangeEventSelected(converted fromset_onChangeEvent_selected) - Right:
set_onChangeEvent_selected(preserved original)
- Wrong:
- 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
- Wrong:
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_->ormodifier_->patterns