R003: 禁止恒真断言
OfficialPrevent useless test cases that always pass.
System Documentation
What problem does it solve?
It prevents test cases from containing恒真断言 (tautological assertions) like expect(true).assertTrue() that always succeed and therefore provide no real verification of the system behavior.
Core Features & Use Cases
- Tautology detection in test assertions: Flags expect(true).assertTrue(), expect(true).assertEqual(true), and expect(false).assertFalse() patterns to avoid ineffective tests.
- Precise issue reporting: Produces file, line number, and the surrounding test case name (it() block) so failures can be fixed quickly.
- Actionable remediation guidance: Suggests replacing tautological assertions with assertions on actual values returned by the code under test.
Use case example: When reviewing ArkTS/Javascript unit tests for OpenHarmony, quickly locate and fix thousands of tests that currently “pass” without validating real API outputs, then improve meaningful coverage.
Quick Start
Use the R003 rule to scan your test source files for恒真断言 and output a report listing each violation with its test case name and a suggested replacement.
Dependency Matrix
Required Modules
None requiredComponents
💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: R003: 禁止恒真断言 Download link: https://github.com/openharmonyinsight/openharmony-skills/archive/main.zip#r003 Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.