Token导航 LogoToken导航TokenDH.com
前端设计需要联网github未标认证来源可访问许可证需确认审计未展示

ring%3adev-unit-testingRing%3adev 单元测试

Agent Skill

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

总安装

727

周安装

30

GitHub Stars

180

下载量

238
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:ring%3adev-unit-testing(Ring%3adev 单元测试)
来源仓库:https://github.com/lerianstudio/ring
仓库路径:skills/ring%3Adev-unit-testing
安装命令:
npx skills add https://github.com/lerianstudio/ring --skill ring:dev-unit-testing
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/lerianstudio/ring --skill ring:dev-unit-testing

简介

用于辅助测试设计、自动化测试、用例整理和回归验证,适合编写单元测试用例。

  • 支持基于函数输入输出生成测试夹具。
  • 需确认项目测试框架与运行命令后再执行。
  • 通过 GitHub 仓库获取技能定义,需结合原始 README 确认具体用法。
  • ring%3adev-unit-testing 属于前端设计类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Dev Unit Testing (Gate 3)

Overview

Ensure every acceptance criterion has at least one unit test proving it works. Follow TDD methodology: RED (failing test) -> GREEN (implementation) -> REFACTOR.

Core principle: Untested acceptance criteria are unverified claims. Each criterion MUST map to at least one executable unit test.

<block_condition>

  • Coverage below 85% = FAIL
  • Any acceptance criterion without test = FAIL </block_condition>

Coverage threshold: 85% minimum (Ring standard). PROJECT_RULES.md can raise, not lower.

CRITICAL: Role Clarification

This skill ORCHESTRATES. QA Analyst Agent EXECUTES.

WhoResponsibility
This SkillGather requirements, dispatch agent, track iterations
QA Analyst AgentWrite tests, run coverage, report results

Step 1: Validate Input

REQUIRED INPUT (from ring:dev-cycle orchestrator):
<verify_before_proceed>
- unit_id exists
- acceptance_criteria is not empty
- implementation_files is not empty
- language is valid (go|typescript|python)
</verify_before_proceed>
  • unit_id: [task/subtask being tested]
  • acceptance_criteria: [list of ACs to test]
  • implementation_files: [files from Gate 0]
  • language: [go|typescript|python]

OPTIONAL INPUT:

  • coverage_threshold: [default 85.0, cannot be lower]
  • gate0_handoff: [full Gate 0 output]
  • existing_tests: [existing test files]

if any REQUIRED input is missing: → STOP and report: "Missing required input: [field]" → Return to orchestrator with error

if coverage_threshold < 85: → STOP and report: "Coverage threshold cannot be below Ring minimum (85%)" → Use 85% as threshold


## Step 2: Initialize Testing State

testing_state = { unit_id: [from input], coverage_threshold: max(85, [from input]), coverage_actual: null, verdict: null, iterations: 0, max_iterations: 3, traceability_matrix: [], tests_written: 0, # Goroutine leak detection (Go only) goroutine_check: null, # NOT_APPLICABLE | REQUIRED goroutine_files: 0, # Count of files with goroutines goleak_coverage: null, # "X/Y" packages with goleak leaks_detected: 0, # Count of actual leaks goroutine_verdict: null # PASS | NEEDS_ACTION | FAIL }


## Step 3: Dispatch QA Analyst Agent

<dispatch_required agent="ring:qa-analyst"> Write unit tests for all acceptance criteria with 85%+ coverage. </dispatch_required>

Task: subagent_type: "ring:qa-analyst" description: "Write unit tests for [unit_id]" prompt: | ⛔ WRITE UNIT TESTS for All Acceptance Criteria

## Input Context - Unit ID: [unit_id] - Language: [language] - Coverage Threshold: [coverage_threshold]%

## Acceptance Criteria to Test [list acceptance_criteria with AC-1, AC-2, etc.]

## Implementation Files to Test [list implementation_files]

## Standards Source (Cache-First Pattern)

Standards Source (Cache-First Pattern): This sub-skill reads standards from state.cached_standards populated by dev-cycle Step 1.5. If invoked outside a cycle (standalone), it falls back to direct WebFetch with a warning. See shared-patterns/standards-cache-protocol.md for protocol details.

## Standards Reference

For Go: https://raw.githubusercontent.com/LerianStudio/ring/main/dev-team/docs/standards/golang.md For TS: https://raw.githubusercontent.com/LerianStudio/ring/main/dev-team/docs/standards/typescript.md

Cache-first loading protocol: For each required standards URL: IF state.cached_standards[url] exists: → Read content from state.cached_standards[url].content → Log: "Using cached standard: {url} (fetched {state.cached_standards[url].fetched_at})" ELSE: → WebFetch url (fallback — should not happen if orchestrator ran Step 1.5) → Log warning: "Standard {url} was not pre-cached; fetched inline"

Focus on: Testing Patterns section

## Requirements

### Test Coverage - Minimum: [coverage_threshold]% branch coverage - Every AC MUST have at least one test - Edge cases REQUIRED (null, empty, boundary, error conditions)

### Test Naming - Go: Test{Unit}_{Method}_{Scenario} - TS: describe('{Unit}', () => { it('should {scenario}', ...) })

### Test Structure - One behavior per test - Arrange-Act-Assert pattern - Mock all external dependencies - no database/API calls (unit tests only)

### Edge Cases Required per AC Type

<cannot_skip> - Minimum 3 edge cases per AC type - null, empty, boundary conditions required - Error conditions required </cannot_skip>

AC TypeRequired Edge CasesMinimum
Input validationnull, empty, boundary, invalid format3+
CRUD operationsnot found, duplicate, concurrent3+
Business logiczero, negative, overflow, boundary3+
Error handlingtimeout, connection failure, retry2+

### Multi-Tenant Dual-Mode Testing (Go backend only)

Every repository/service test that accesses a resource (PostgreSQL, MongoDB, Redis, S3, RabbitMQ) must verify BOTH modes. The resolvers in lib-commons v5 work transparently — the same code path handles both modes. Tests verify this contract.

Required pattern: Add dual-mode sub-tests for any test that touches a resource:

    func TestCreateAccount(t *testing.T) {
        modes := []struct {
            name         string
            multiTenant  string
        }{
            {"single-tenant", "false"},
            {"multi-tenant", "true"},
        }
        for _, mode := range modes {
            t.Run(mode.name, func(t *testing.T) {
                t.Setenv("MULTI_TENANT_ENABLED", mode.multiTenant)
                // ... same test logic, same assertions
                // Resolvers handle the connection routing transparently
            })
        }
    }

What to verify in multi-tenant mode: - Context contains tenant ID → resolver returns tenant-specific connection - Context WITHOUT tenant ID → resolver returns error (not default connection) - Backward compat: no MULTI_TENANT_* env vars → works as single-tenant

What does NOT need dual-mode tests: - Pure business logic (no resource access) - Utility/helper functions - Frontend/TypeScript tests

## Required Output Format

### Test Files Created

FileTestsLines
[path][count]+N

### Coverage Report Command: [coverage command] Result:

    [paste actual coverage output]
Package/FileCoverage
[name][X%]
TOTAL[X%]

### Traceability Matrix

AC IDCriterionTest FileTest FunctionStatus
AC-1[criterion text][file][function]✅/❌
AC-2[criterion text][file][function]✅/❌

### Quality Checks

CheckStatus
No skipped tests✅/❌
No assertion-less tests✅/❌
Edge cases per AC✅/❌
Test isolation✅/❌

### VERDICT Coverage: [X%] vs Threshold [Y%] VERDICT: PASS / FAIL

If FAIL: - Gap Analysis: [what needs more tests] - Files needing coverage: [list with line numbers]


## Step 3.5: Goroutine Leak Detection (Go only)

**⛔ CONDITIONAL: Only execute if `language == "go"`**

After unit tests pass, detect goroutine usage and verify goleak coverage.

See [ring:dev-goroutine-leak-testing](https://github.com/lerianstudio/ring/blob/HEAD/dev-team/skills/dev-unit-testing/../dev-goroutine-leak-testing/SKILL.md) for full detection patterns and dispatch templates. See [architecture.md](https://github.com/lerianstudio/ring/blob/HEAD/dev-team/skills/dev-unit-testing/../../docs/standards/golang/architecture.md#goroutine-leak-detection-mandatory) for goleak standards.

### Detection Logic

if language != "go": → Skip to Step 4

Detect goroutine patterns: "go func(", "go methodCall("

if no goroutine patterns found: → testing_state.goroutine_check = "NOT_APPLICABLE" → Skip to Step 4

Goroutines detected

→ testing_state.goroutine_check = "REQUIRED" → Dispatch ring:qa-analyst with test_mode="goroutine-leak"


### Dispatch

<dispatch_required agent="ring:qa-analyst" test_mode="goroutine-leak"> MUST dispatch with test_mode="goroutine-leak" to detect leaks and verify goleak coverage. </dispatch_required>

### Parse Output and Handle Verdict

| Verdict | Action |
| --- | --- |
| PASS | Proceed to Step 4 |
| NEEDS_ACTION | Dispatch `ring:backend-engineer-golang` to add goleak tests, re-run |
| FAIL | Dispatch `ring:backend-engineer-golang` to fix leaks, re-run |

---

## Step 4: Parse QA Analyst Output

Parse agent output:

  1. Extract coverage percentage from Coverage Report
  2. Extract traceability matrix
  3. Extract verdict

testing_state.coverage_actual = [extracted coverage] testing_state.traceability_matrix = [extracted matrix] testing_state.tests_written = [count from Test Files Created]

if verdict == "PASS" and coverage_actual >= coverage_threshold: → testing_state.verdict = "PASS" → Proceed to Step 6

if verdict == "FAIL" or coverage_actual < coverage_threshold: → testing_state.verdict = "FAIL" → testing_state.iterations += 1 → if iterations >= max_iterations: Go to Step 7 (Escalate) → Go to Step 5 (Dispatch Fix)


## Step 5: Dispatch Fix to Implementation Agent

**Coverage below threshold → Return to Gate 0 for more tests**

Task: subagent_type: "[implementation_agent from Gate 0]" # e.g., "ring:backend-engineer-golang" description: "Add tests to meet coverage threshold for [unit_id]" prompt: | ⛔ COVERAGE BELOW THRESHOLD - Add More Tests

## Current Status - Coverage Actual: [coverage_actual]% - Coverage Threshold: [coverage_threshold]% - Gap: [threshold - actual]% - Iteration: [iterations] of [max_iterations]

## Gap Analysis (from QA) [paste gap analysis from QA output]

## Files Needing Coverage [paste files list from QA output]

## Requirements 1. Add tests to cover the identified gaps 2. Focus on edge cases and error paths 3. Run coverage after each addition 4. Stop when coverage >= [threshold]%

## Required Output - Tests added: [list] - New coverage: [X%] - Coverage command output


After fix → Go back to Step 3 (Re-dispatch QA Analyst)

## Step 6: Prepare Success Output

Generate skill output:

Testing Summary

Status: PASS Unit ID: [unit_id] Iterations: [testing_state.iterations]

Coverage Report

Threshold: [coverage_threshold]% Actual: [coverage_actual]% Status: ✅ PASS

Package/FileCoverage

[from QA output] | TOTAL | [coverage_actual]% |

Traceability Matrix

AC IDCriterionTestStatus

[from testing_state.traceability_matrix]

Criteria Covered: [X]/[Y] (100%)

Quality Checks

CheckStatus
Coverage ≥ threshold
All ACs tested
No skipped tests
Edge cases present
Goroutine leak check (Go only)[✅/N/A]

Goroutine Leak Report (Go only)

[If language == "go" and goroutines detected]

MetricValue
Goroutines detected[count]
Packages with goleak[X]/[Y]
Leaks found0
Status✅ PASS

[If language != "go" or no goroutines: "N/A - No goroutines detected"]

Handoff to Next Gate

  • Testing status: COMPLETE
  • Coverage: [coverage_actual]% (threshold: [coverage_threshold]%)
  • All criteria tested: ✅
  • Ready for Gate 4 (Review): YES

## Step 7: Escalate - Max Iterations Reached

Generate skill output:

Testing Summary

Status: FAIL Unit ID: [unit_id] Iterations: [max_iterations] (MAX REACHED)

Coverage Report

Threshold: [coverage_threshold]% Actual: [coverage_actual]% Gap: [threshold - actual]% Status: ❌ FAIL

Gap Analysis

[from last QA output]

Files Still Needing Coverage

[from last QA output]

Handoff to Next Gate

  • Testing status: FAILED
  • Ready for Gate 4: no
  • Action Required: User must manually add tests or adjust scope

⛔ ESCALATION: Max iterations (3) reached. Coverage still below threshold. User intervention required.


---

## Severity Calibration

| Severity | Criteria | Examples |
| --- | --- | --- |
| **CRITICAL** | Test infrastructure broken, no coverage possible | Test framework failure, build broken |
| **HIGH** | Coverage below threshold, missing AC tests | 84% coverage (below 85%), untested acceptance criteria |
| **MEDIUM** | Test quality issues, edge case gaps | Missing edge case tests, poor assertion messages |
| **LOW** | Test naming, documentation gaps | Non-standard test names, missing test descriptions |

Report all severities. CRITICAL/HIGH = immediate fix. MEDIUM = fix in iteration. LOW = document for follow-up.

---

## Pressure Resistance

See [shared-patterns/shared-pressure-resistance.md](https://github.com/lerianstudio/ring/blob/HEAD/dev-team/skills/dev-unit-testing/../shared-patterns/shared-pressure-resistance.md) for universal pressure scenarios.

| User Says | Your Response |
| --- | --- |
| "84% is close enough" | "85% is minimum threshold. 84% = FAIL. Adding more tests." |
| "Manual testing covers it" | "Gate 3 requires executable unit tests. Dispatching QA analyst." |
| "Skip testing, deadline" | "Testing is MANDATORY. Untested code = unverified claims." |

---

## Anti-Rationalization Table

See [shared-patterns/shared-anti-rationalization.md](https://github.com/lerianstudio/ring/blob/HEAD/dev-team/skills/dev-unit-testing/../shared-patterns/shared-anti-rationalization.md) for universal anti-rationalizations.

### Gate 3-Specific Anti-Rationalizations

| Rationalization | Why It's WRONG | Required Action |
| --- | --- | --- |
| "Tool shows 83% but real is 90%" | Tool output IS real. Your belief is not. | **Fix issue, re-measure** |
| "Excluding dead code gets us to 85%" | Delete dead code, don't exclude it. | **Delete dead code** |
| "84.5% rounds to 85%" | Rounding is not allowed. 84.5% < 85%. | **Write more tests** |
| "Close enough with all AC tested" | "Close enough" is not passing. | **Meet exact threshold** |
| "Integration tests cover this" | Gate 3 = unit tests only. Different scope. | **Write unit tests** |

## Unit Test vs Integration Test

| Type | Characteristics | Gate 3? |
| --- | --- | --- |
| **Unit** ✅ | Mocks all external deps, tests single function | YES |
| **Integration** ❌ | Hits real database/API/filesystem | no |

---

## Execution Report Format

Testing Summary

Status: [PASS|FAIL] Unit ID: [unit_id] Duration: [Xm Ys] Iterations: [N]

Coverage Report

Threshold: [X%] Actual: [Y%] Status: [✅ PASS | ❌ FAIL]

Traceability Matrix

AC IDCriterionTestStatus
AC-1[text][test]✅/❌

Criteria Covered: [X/Y]

Handoff to Next Gate

  • Testing status: [COMPLETE|FAILED]
  • Coverage: [X%]
  • Ready for Gate 4: [YES|no]

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.1%
按下载量换算81

Claude

28.71%
按下载量换算68

Cursor

19.46%
按下载量换算46

Gemini CLI

10.33%
按下载量换算25

安全审计

暂无安全审计结果可展示。

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills