Testing 标志

Testing

社区
notque
testing

Testing: TDD, E2E, preferred patterns, test-value audits, verification, agent testing.

概览

发布者notque
代码仓库vexjoy-agent
技能名称testing
星标数
443
复刻数
50
附带文件
19
许可协议MIT
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 19 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 notque 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Testing AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/notque/vexjoy-agent/tree/main/skills/process/testing
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/notque/vexjoy-agent.git /tmp/vexjoy-agent
mkdir -p .claude/skills
cp -r /tmp/vexjoy-agent/skills/process/testing .claude/skills/testing
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Testing,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Testing。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Testing 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Testing

Seven modes. Match the request to one mode and follow its section. Read repository CLAUDE.md first -- project conventions override defaults here.

Mode Selection

Request matchesGo to
Write tests first, TDD, red-green-refactorTDD
Flaky, brittle, test smell, over-mocking, slow testsPattern Quality
Audit or prune low-value, duplicate, or implementation-coupled testsTest Audit
Test an agent, subagent testing, validate agentAgent Testing
Run vitest, JavaScript/TypeScript testsVitest Runner
Playwright, E2E, end-to-end, browser testE2E (Playwright)
Verify completion, final check, defense in depthVerification

TDD

RED-GREEN-REFACTOR cycle with strict phase gates. Each feature gets its own cycle. Do not batch multiple features into one cycle.

Phase 1: RED -- Write a Failing Test

Write a test describing desired behavior before implementation exists. Use Arrange-Act-Assert, descriptive names, one concept per test. Run the test and show full output.

Every new or changed test, in any mode, must first pass the authoring gate in references/audit-test-value.md.

Gate -- proceed only when all true:

  • Test file created and saved
  • Test executed
  • Output shows FAILURE (not syntax/import error)
  • Failure indicates missing implementation

If test passes before implementation: assertions are too weak, or the feature already exists. If test fails for wrong reason (syntax, import, setup): fix those first, then re-run until it fails for the right reason.

Phase 2: GREEN -- Minimum Implementation

Write ONLY enough code to make the failing test pass. No extra features. Hardcoded values are acceptable initially. Run the test and the full suite; show complete output.

Gate -- proceed only when all true:

  • New test passes
  • Full suite executed
  • No other tests broken

Phase 3: REFACTOR

Improve code quality without changing behavior. Establish a green baseline, refactor incrementally, run tests after every step. Test behavior, not internals.

Gate -- proceed only when all true:

  • Full suite passes
  • Code quality evaluated

Phase 4: Commit

Commit test and implementation as an atomic unit. Run the full suite first.

TDD Error Recovery

SymptomCauseFix
Test passes in RED phaseWeak assertions or feature existsStrengthen assertions; check for existing implementation
Wrong failure reasonSetup incomplete, missing depsFix syntax/imports first, re-run
Tests green but feature brokenTests miss actual usageAdd integration tests; test with real data
Refactoring breaks testsTests coupled to internalsTest behavior not implementation; refactor in smaller steps

Pattern Quality

Identify and fix testing mistakes across unit, integration, and E2E suites. Test behavior, be reliable, run fast, fail for the right reasons.

Phase 1: SCAN

Locate test files (*_test.go, test_*.py, *.test.ts, *.spec.js). Scan for these 10 failure modes:

#PatternDetection Signal
1Testing implementation detailsAsserts on private fields, spy on private methods
2Over-mocking / brittle selectorsMock setup > 50% of test code, CSS nth-child
3Order-dependent testsShared mutable state, numbered test names
4Incomplete assertions!= nil, > 0, toBeTruthy(), no value checks
5Over-specificationExact timestamps, hardcoded IDs, asserting defaults
6Ignored failures@skip, .skip, xit, empty catch, _ = err
7Poor namingtestFunc2, it('works'), it('handles case')
8Missing edge casesOnly happy path, no empty/null/boundary/error tests
9Slow test suitesFull DB reset per test, no parallelization
10Flaky testssleep(), time.Sleep(), unsynchronized goroutines

Document each finding with file:line, severity, issue, and impact.

Gate: At least one quality issue identified with file:line reference.

Phase 2: PRIORITIZE

  1. HIGH -- Flaky, order-dependent, ignored failures (erode trust)
  2. MEDIUM -- Over-mocking, incomplete assertions, missing edges (false confidence)
  3. LOW -- Poor naming, over-specification, slow suites (maintenance burden)

Fix one pattern at a time. Preserve test intent. Prevent over-engineering.

Gate: Findings ranked. User agrees on fix scope.

Phase 3: FIX

For each issue (highest priority first): show current code, show fixed code, apply fix, run tests. Guide toward behavior testing:

  • Asserts on private fields -> test the public behavior those fields enable
  • Spies on _getUser() -> test what happens when a user exists or not
  • Checks exact regex -> test that validation succeeds/fails for representative inputs

Run the specific fixed test first, then the full file or package. If a fix breaks a previously-passing test, investigate before proceeding.

Gate: Each fix verified. Tests pass after each change.

Phase 4: VERIFY

Run full suite. Verify flaky tests are now deterministic (run 3x). Confirm no no tests were accidentally removed or disabled. Report: bad patterns fixed, files modified, tests affected, suite status.

Gate: Full suite passes. Summary delivered.

Pattern Error Recovery

ProblemFix
Cannot determine if pattern is a quality issueCheck comments, consider test layer, flag MEDIUM with trade-offs
Fix changes test behaviorIdentify original intent, write correct assertion, note as separate finding
Suite has hundreds of quality issuesFix HIGH severity first, recommend TDD going forward, suggest fix-on-touch

Test Audit

Find and remove tests that do not earn their maintenance cost, and the test-only production seams they keep alive. Load references/audit-test-value.md and follow it; it holds the authoring gate, junk patterns, retention bar, evidence fields, validation, and handoff.

Use Pattern Quality to fix a test that guards real behavior badly. Use Test Audit to decide whether a test should exist at all.

ScopeSub-mode
Writing or changing a testAuthoring gate
Focused sweep of a few candidatesAudit
Every test one subsystem ownsCampaign

Gate: Every deletion has all candidate evidence fields recorded. Owner and full suites pass. Production and test LOC reported separately.

To find hook or validator tests that miss real bugs, run python3 scripts/mutation-check.py --hook hooks/<name>.py. It plants small AST bugs, runs the tests, and lists surviving mutants. Use --all for every hook (about 30 minutes) and --json for machine output. Run it on demand, not in CI.


Agent Testing

TDD methodology applied to agent development. Test what the agent DOES, not what the prompt SAYS. Each test runs in a fresh subagent to avoid context pollution.

Minimum Test Counts

Agent TypeMin TestsCoverage
Reviewer62 real issues, 2 clean, 1 edge, 1 ambiguous
Implementation52 typical, 1 complex, 1 minimal, 1 error
Analysis42 standard, 1 edge, 1 malformed
Routing/orchestration42 correct route, 1 ambiguous, 1 invalid

No agent is simple enough to skip testing.

Phase 1: RED -- Observe Current Behavior

Read the agent file and referenced skills. Extract testable claims (inputs, output structure, routing triggers, error conditions). Write a test plan to a file. Dispatch subagent via Task tool with test inputs. Capture results verbatim. Identify failure patterns.

Gate: All cases executed. Outputs captured. Failures documented.

Phase 2: GREEN -- Fix Agent Definition

Prioritize failures by severity. Make one fix at a time. Re-run ALL test cases after each fix. If a fix causes regression, revert and try a different approach.

Gate: All cases pass. No regressions.

Phase 3: REFACTOR -- Edge Cases and Robustness

Add edge case tests (empty, large, unusual, ambiguous inputs). Run consistency tests (same input 3x; outputs should have same structure and key findings). Run full regression suite.

Gate: Edge cases handled. Consistency verified. Full suite green.


Vitest Runner

Run existing Vitest tests and report results. A check-only request does not authorize changing tests, assertions, dependencies, or configuration.

Check package.json, vitest.config.*, and vite.config.* to confirm Vitest. Use the installed project version; avoid implicit npx downloads. If Vitest is unavailable, report setup needed rather than installing it. Always use run; bare vitest enters watch mode.

ScopeCommand
Full suitenpx vitest run --reporter=verbose 2>&1
File or directorynpx vitest run path/to/test.ts 2>&1
Test-name patternnpx vitest run -t "pattern" 2>&1
Coveragenpx vitest run --coverage 2>&1

Capture exit code and full output. Report pass/fail, scope, counts, duration. For failures: retain file, test name, assertion diff, relevant stack. Nonzero exit is failure; partial output is not a passing run.

Vitest Recovery

ProblemFix
Vitest missing / no node_modulesnpm install or npm install -D vitest
No test files foundCheck naming (*.test.ts, *.spec.ts) and include/exclude globs
Missing DOM environmentCheck for jsdom/happy-dom in config; suggest devDependency
Out of memoryBatch by directory, use --pool=forks or --shard=1/N
Failing assertionsReport mismatch; if fixing authorized, determine whether implementation or test is wrong

E2E (Playwright)

Playwright-based E2E testing: Scaffold, Build, Run, Validate. Each phase produces an artifact and must pass its gate.

Phase 1: SCAFFOLD

  1. Verify @playwright/test installed: npx playwright --version. If missing: npm install -D @playwright/test && npx playwright install.
  2. Create directory structure: tests/e2e/{auth,features,api}/, pages/, artifacts/{screenshots,traces,videos}/.
  3. Write playwright.config.ts. Bake in failure diagnostics: screenshot: 'only-on-failure', trace: 'on-first-retry', video: 'retain-on-failure'. CI retries: retries: process.env.CI ? 2 : 0.
  4. Verify: npx tsc --noEmit.

Gate: playwright.config.ts exists AND tests/e2e/ exists.

Phase 2: BUILD

Write POM classes in pages/ for each feature area. All locators use data-testid via page.getByTestId(). No inline locators in spec files. Write spec files in tests/e2e/<area>/. Verify: npx tsc --noEmit.

Gate: At least one .spec.ts under tests/e2e/ AND npx tsc --noEmit exits 0.

Phase 3: RUN

  1. Ensure app is running (or document BASE_URL).
  2. Run: npx playwright test.
  3. If failures, isolate with --repeat-each=5 to distinguish flaky from broken.
  4. Quarantine confirmed flaky tests with test.fixme() and a tracking TODO. Never delete a failing test. Use test.skip() only for environment guards.

Gate: playwright-results.json exists and parses as valid JSON.

Phase 4: VALIDATE

  1. Deterministic checks first: parse JSON, extract counts, identify unexpected and flaky entries.
  2. LLM triage: classify each failure as (a) broken assertion, (b) selector mismatch, (c) timing/async, or (d) application bug.
  3. Write e2e-report.md.

Gate: e2e-report.md exists.

E2E Error Recovery

SymptomFix
npx tsc --noEmit failsCheck @playwright/test in devDeps, verify tsconfig includes test dir
Pass locally, fail CInpx playwright install --with-deps in CI; verify BASE_URL
Results JSON missingCheck JSON reporter in config; check for OOM/process kill
Locator timeout on existing elementawait expect(locator).toBeVisible() before interaction; check overlays
fill() appendslocator.clear() then locator.fill()
Flaky (4/5 pass)Quarantine with test.fixme(), reproduce with --repeat-each=10, check missing waitFor

Confirm flaky vs. broken: --repeat-each=5 --retries=0. If fails at least once in 5, it is flaky. Fix if root cause is clear; quarantine otherwise. Verify fix with --repeat-each=10 --retries=0 (must pass 10/10).


Verification

Defense-in-depth verification before declaring any task complete. Match checks to affected behavior and repository requirements.

Steps

  1. Inspect changes. git status --short and git diff. Read changed code; check imports, error handling, compatibility, unintended edits.
  2. Run required checks. Tests, build, lint, format per repository config. Start with relevant tests; run full affected suite when shared behavior changed. Do not substitute syntax checks for behavior tests.
  3. Verify artifacts. Check generated artifacts at expected paths. For integrations, verify four levels: EXISTS on disk, SUBSTANTIVE implementation, WIRED into callers, real DATA FLOWS through it. An unused file or hardcoded empty result is not a working feature.
  4. Inspect diff for problems. Debug code, secrets, placeholders, unfinished work. Review in context: an intentional pass is not automatically a stub.
  5. Fix and rerun. Fix failures within authorized scope; rerun affected checks. A failed required build or test blocks a success claim.
  6. Report. Commands, observed status, counts, limitations. Retain full logs; show actionable excerpts. Distinguish automated, manual, and unrun checks.

Default Commands

LanguageTestsBuild/syntaxLint
Pythonpytest -vpython -m py_compile {files}ruff check {files}
Gogo test ./... -v -racego build ./...golangci-lint run ./...
JavaScriptnpm testnpm run buildnpm run lint
TypeScriptnpm testnpx tsc --noEmitnpm run lint
Rustcargo testcargo buildcargo clippy

Evidence Reuse

Reuse a passing result when it covers the current task, checked files, dependencies, and environment. Keep its command, scope, state, and log path. After edits, rerun affected checks. Do not claim inherited results as your own. Required CI checks still apply to the delivered commit.

Verification Recovery

ProblemFix
No testsManual checks; state coverage gap; add regression test if warranted
Missing dependenciesUse repo environment; report missing tool; unrun checks are not passes
Build/test failureRetain failing command and diagnostic; identify cause, fix, rerun
Missing wiring or data flowName where integration stops; repair it

Anti-Rationalization

RationalizationRequired Action
"I loaded the patterns, that's enough"Loading is not applying. Check against patterns at each gate.
"This task is simple, full rigor is overkill"Apply proportionate rigor, never zero.
"The gate basically passes"Either it passes with evidence or it does not.

Completion self-check: Did I verify or assume? Did I run tests or just read code? Did I complete everything or just the "important" parts? Can I show evidence?


Deep References

Load when the signal applies.

SignalLoadContent
TDD phase steps, language commandsreferences/tdd-phase-guidance.mdRED-GREEN-REFACTOR steps per language
TDD walkthroughsreferences/tdd-examples.mdGo, Python, JavaScript worked examples
BAD/GOOD code per failure modereferences/patterns-preferred-pattern-catalog.mdCode examples per pattern per language
Failure mode classificationreferences/patterns-quality-catalog.md10 failure mode descriptions
Language-specific fix strategiesreferences/patterns-fix-strategies.mdFix patterns and tooling per language
Test blind spotsreferences/patterns-blind-spot-taxonomy.md6-category gap taxonomy
Load test scenariosreferences/patterns-load-test-scenarios.mdSmoke, stress, spike, soak configs
New-test gate, test audits, pruning campaignsreferences/audit-test-value.mdAuthoring gate, junk patterns, retention bar, evidence, validation
Agent dispatch patternsreferences/agents-testing-patterns.mdDispatch, negative, A/B
Agent testing examplesreferences/agents-examples-and-errors.mdWorked examples and error cases
E2E async patternsreferences/e2e-async.mdPromise.all, race conditions, teardown
E2E auth testingreferences/e2e-auth.mdLogin, storageState, OAuth, SSO, JWT
E2E config templatesreferences/e2e-templates.mdplaywright.config.ts, POM, CI/CD
E2E POM and waitingreferences/e2e-playwright-patterns.mdPOM examples, multi-browser
E2E Web3 walletreferences/e2e-wallet-testing.mdMetaMask testing patterns
E2E financial flowsreferences/e2e-financial-flows.mdPayment flow testing
Stub detectionreferences/verify-adversarial-methodology.mdFour-level checks, goal-backward verification
Domain checklistsreferences/verify-checklist.mdSchema change, compatibility checks
Verification examplesreferences/verify-verification-examples.mdBug fix, refactor, migration walkthroughs

Quick Reference: Red Flags

  • @skip, @ignore, xit, .skip without expiration date
  • time.sleep(), setTimeout() in test code
  • Test names with sequential numbers (test1, test2)
  • Global mutable state accessed by multiple tests
  • Mock setup spanning 20+ lines
  • Empty catch blocks in tests
  • Assertions like != nil, > 0, toBeTruthy() without value checks

Strict TDD prevents most quality issues: RED catches incomplete assertions, GREEN minimum prevents over-specification, watching failure confirms you test behavior not mocks, incremental cycles prevent interdependence, refactor phase reveals implementation coupling.

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Testing AI 技能有什么作用?

Testing: TDD, E2E, preferred patterns, test-value audits, verification, agent testing.

为什么在 TypingMind 中使用 Testing?

因为您只需安装一次,就能搭配任何模型使用。Testing 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Testing?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/notque/vexjoy-agent/tree/main/skills/process/testing。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Testing?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Testing 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Testing 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Testing AI 技能免费吗?

是的。notque 已在 GitHub 上根据 MIT 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇