R018: testcase重复

Detect duplicate testcase names within the same describe block in ArkTS/TypeScript/JavaScript test files.

31|6|Updated Jan 29, 2026
One-click install
npx skills add https://github.com/openharmonyinsight/openharmony-skills --skill r018-testcase
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: R018: testcase重复
Source: https://github.com/openharmonyinsight/openharmony-skills/tree/main/skills/check-test-code-quality/rules/R018
Command: npx skills add https://github.com/openharmonyinsight/openharmony-skills --skill r018-testcase

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you eliminate ambiguous or conflicting testcases by detecting duplicate testcase names inside the same describe block, so test runs can uniquely identify each case.

Core Features & Use Cases

  • Detects duplicate testcase names: Finds repeated it() testcase names and @tc.name values within the same describe block only.
  • Correct scope handling: Does not compare across different files or across different describe blocks.
  • Actionable remediation: Keeps the first occurrence unchanged and recommends appending an Adapt{三位数字} suffix to later duplicates, updating @tc.name accordingly.

Quick Start

Use this rule to scan a specific .test.ets/.test.ts/.test.js file and get a report listing duplicate testcase names with the first offending line and all duplicate line numbers.

Frequently Asked Questions about R018: testcase重复

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I detect duplicate testcase names within a describe block in TypeScript?

To detect duplicate testcase names within a describe block, scan your .test.ets, .test.ts, or .test.js files to find repeated it() or @tc.name values that cause test execution ambiguity. The analysis reports only the first occurrence per duplicate group.

Why does my unit test execution fail when duplicate it() names exist in the same scope?

Duplicate it() names within the same describe block create unit test execution ambiguity because the runner cannot uniquely identify each case. Enforcing testcase uniqueness inside the describe scope ensures test runs execute without conflicts.

Can I check for duplicate @tc.name values across multiple different test files?

No, duplicate testcase detection applies only within the same describe block scope. It does not compare @tc.name or it() values across different files or across different describe blocks to prevent cross-scope false positives.

What is the best way to fix duplicate testcase names found during static analysis?

To fix duplicate testcase names found during static analysis, keep the first occurrence unchanged and append an Adapt{three-digit-number} suffix to later duplicates, ensuring you update the @tc.name values accordingly for unique identification.

Does this duplicate testcase detection rule work with ArkTS test files?

Yes, the duplicate testcase detection rule works with ArkTS test files. It applies filename and scope constraints to scan .test.ets, .test.ts, and .test.js files where testcase uniqueness must be enforced.