360 Secure SkillHub
360 安全技能中心

Tests Generator

该 Skill 依据目标行为生成确定性的单元、集成或 E2E 测试:识别可观测行为与边界情况,确定测试边界,创建稳定 fixture,编写正常路径与失败路径用例,并运行测试迭代至稳定。输出新增/修改的测试文件、测试运行方式及 fixture/mock 说明;默认不依赖真实凭据或真实外部服务。

mzfshark
mzfshark
热度 34.63
最近更新 2026-05-11 17:45:41
分类:开发依赖:代码执行 / 读写文件应用场景:代码生成 / 调试排错

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add axodus-test-generator
Metadata
name
test-generator
description
Generate deterministic unit/integration tests for critical behaviors.
metadata
{"author":"RedHat Dev","version":"1.0.0","owner":"RedHat Dev Agent","category":"quality"}

SKILL: test-generator

Purpose

Generate deterministic unit/integration tests that protect behavior and enable safe refactors.

When to Use

  • A feature needs coverage.
  • A bug fix needs a regression test.
  • You want characterization tests before refactoring.

Inputs

  • target (required, string): function/module/endpoint/contract behavior to test.
  • test_type (optional, enum: unit|integration|e2e).
  • framework (optional, string): e.g., pytest, jest, vitest, foundry, hardhat.
  • constraints (optional, string[]): no network, deterministic time, limited mocks, etc.

Steps

  1. Identify observable behaviors and edge cases.
  2. Decide test boundaries:
    • unit: pure logic
    • integration: DB/service boundary
  3. Create fixtures:
    • deterministic data
    • stable clocks/UUIDs (mock only when required)
  4. Write tests:
    • happy path
    • failure paths
    • security/validation checks (where applicable)
  5. Run tests and iterate until they are stable.

Validation

  • Tests are deterministic (no flaky time/network dependencies).
  • Tests fail before the fix (for regressions) and pass after.
  • Coverage targets the acceptance criteria, not implementation details.

Output

  • Test files added/changed
  • How to run tests
  • Notes on fixtures/mocks used

Safety Rules

  • Do not add tests that require real credentials or real external services by default.
  • Avoid snapshot tests for highly variable outputs unless stabilized.

Example

Bug: “User creation accepts invalid email.” Output: a failing test asserting 400 on invalid input, then passes after fix.