Token导航 LogoToken导航TokenDH.com
开发需要联网github未标认证来源可访问许可证需确认审计通过

test-generator测试发生器

Agent Skill

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

总安装

2,590

周安装

109

GitHub Stars

25

下载量

907
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

请帮我安装这个 Agent Skill:test-generator(测试发生器)
来源仓库:https://github.com/oimiragieo/agent-studio
仓库路径:skills/test-generator
安装命令:
npx skills add https://github.com/oimiragieo/agent-studio --skill test-generator
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/oimiragieo/agent-studio --skill test-generator

简介

用于辅助测试设计、自动化测试、用例整理和回归验证。

  • 适合编写单元测试、端到端测试、测试计划或根据失败日志定位问题。
  • 使用时需确认项目测试框架、运行命令和夹具数据,避免改坏真实逻辑。
  • 涉及浏览器或外部服务时应区分本地模拟、测试环境和生产环境。
  • 安装前建议确认权限范围和维护状态,避免误操作生产系统。

SKILL.md

Mode: Cognitive/Prompt-Driven — No standalone utility script; use via agent context.

Step 1: Identify Test Type

Determine what type of test is needed:

  • Unit Test: Component/function testing
  • Integration Test: Service/API integration
  • E2E Test: Full user flow testing
  • API Test: Endpoint testing

Step 2: Analyze Target Code

Examine code to test (Use Parallel Read/Grep/Glob):

  • Read component/function code
  • Identify test cases
  • Understand dependencies
  • Note edge cases

Step 3: Analyze Test Patterns

Review existing tests:

  • Read similar test files
  • Identify testing patterns
  • Note testing framework usage
  • Understand mocking strategies

Step 4: Generate Test Code

Create test following patterns:

  • Use appropriate testing framework
  • Follow project conventions
  • Include comprehensive coverage
  • Add edge cases and error scenarios

Step 5: Coverage Analysis

After generating tests, analyze coverage:

  1. Check that generated tests cover all requirements:

- Verify all functions/methods are tested - Check all branches are covered (if/else, switch, etc.) - Ensure all edge cases are tested - Validate error scenarios are covered

  1. Validate tests are runnable:

- Check test syntax is valid - Verify imports are correct - Ensure test framework is properly configured - Validate test setup/teardown is correct

  1. Report coverage percentage:

- Calculate line coverage (if possible) - Calculate branch coverage (if possible) - Report uncovered code paths - Suggest additional tests for uncovered areas

  1. Coverage Validation Checklist:

- All public functions/methods have tests - All error paths are tested - All edge cases are covered - Tests are syntactically valid - Tests can be executed successfully - Coverage meets project thresholds (if defined) </execution_process>

import { render, screen, waitFor } from '@testing-library/react'
import { describe, it, expect, vi } from 'vitest'
import { UserProfile } from './user-profile'

describe('UserProfile', () => {
  it('renders user information', async () => {
    const mockUser = { id: '1', name: 'John', email: 'john@example.com' }

    render(<UserProfile user={mockUser} />)

    await waitFor(() => {
      expect(screen.getByText('John')).toBeInTheDocument()
      expect(screen.getByText('john@example.com')).toBeInTheDocument()
    })
  })

  it('handles loading state', () => {
    render(<UserProfile user={null} loading />)
    expect(screen.getByTestId('loading')).toBeInTheDocument()
  })

  it('handles error state', () => {
    render(<UserProfile user={null} error="Failed to load" />)
    expect(screen.getByText('Failed to load')).toBeInTheDocument()
  })
})

</code_example>

<code_example> Integration Test (API)

import { describe, it, expect, beforeAll, afterAll } from 'vitest';
import { createTestClient } from './test-client';

describe('Users API', () => {
  let client: TestClient;

  beforeAll(() => {
    client = createTestClient();
  });

  afterAll(async () => {
    await client.cleanup();
  });

  it('creates a user', async () => {
    const response = await client.post('/api/users', {
      email: 'test@example.com',
      name: 'Test User',
    });

    expect(response.status).toBe(201);
    expect(response.data).toHaveProperty('id');
    expect(response.data.email).toBe('test@example.com');
  });

  it('validates required fields', async () => {
    const response = await client.post('/api/users', {});

    expect(response.status).toBe(400);
    expect(response.data).toHaveProperty('errors');
  });
});

</code_example>

<code_example> E2E Test (Cypress)

describe('User Authentication Flow', () => {
  beforeEach(() => {
    cy.visit('/login');
  });

  it('allows user to login', () => {
    cy.get('[data-testid="email-input"]').type('user@example.com');
    cy.get('[data-testid="password-input"]').type('password123');
    cy.get('[data-testid="login-button"]').click();

    cy.url().should('include', '/dashboard');
    cy.get('[data-testid="user-menu"]').should('be.visible');
  });

  it('shows error for invalid credentials', () => {
    cy.get('[data-testid="email-input"]').type('invalid@example.com');
    cy.get('[data-testid="password-input"]').type('wrong');
    cy.get('[data-testid="login-button"]').click();

    cy.get('[data-testid="error-message"]')
      .should('be.visible')
      .and('contain', 'Invalid credentials');
  });
});

</code_example>

Integration with QA Agent:

  • Creates comprehensive test suites
  • Generates test plans
  • Validates test quality

<best_practices>

  1. Follow Patterns: Match existing test structure
  2. Comprehensive Coverage: Test happy paths and edge cases
  3. Clear Test Names: Descriptive test descriptions
  4. Isolate Tests: Each test should be independent
  5. Mock Dependencies: Use appropriate mocking strategies </best_practices>
# Generate tests for a file
node .claude/skills/test-generator/scripts/main.cjs src/components/UserProfile.tsx

# The tool will analyze the file and generate appropriate tests

</usage_example>

Iron Laws

  1. ALWAYS analyze existing test patterns and framework conventions before generating any test code
  2. NEVER generate tests that inspect implementation details — test only public behavior and outputs
  3. ALWAYS include edge cases: null/undefined inputs, boundary values, and error scenarios for every tested unit
  4. NEVER produce tests with shared mutable state — use beforeEach/afterEach to isolate every test
  5. ALWAYS verify generated tests are syntactically valid and runnable before marking generation complete

Anti-Patterns

Anti-PatternWhy It FailsCorrect Approach
Testing implementation detailsBreaks on refactor even when behavior is unchangedTest public API behavior and observable outputs
No assertions in test bodyTest always passes, catches nothingAdd explicit assertions for every test case
Shared mutable state between testsTests fail depending on execution orderUse beforeEach/afterEach for full isolation
Magic numbers in assertionsUnclear expected values, brittle testsUse named constants or descriptive fixture data
Missing error path testsHalf coverage, silent failures in productionTest both success and failure scenarios

Memory Protocol (MANDATORY)

Before starting: Read .claude/context/memory/learnings.md

After completing:

  • New pattern -> .claude/context/memory/learnings.md
  • Issue found -> .claude/context/memory/issues.md
  • Decision made -> .claude/context/memory/decisions.md
ASSUME INTERRUPTION: If it's not in memory, it didn't happen.

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

展示第三方安全扫描或审计结果

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

平台分布

Codex

33.46%
按下载量换算303

Claude

32.95%
按下载量换算299

Cursor

18.23%
按下载量换算165

Gemini CLI

9.26%
按下载量换算84

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

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

安装前确认

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

来源信息

继续浏览同类 Skills