AGENT SKILL

test-generator

Generate comprehensive tests for Python code - use when creating new functions or fixing bugs

使用场景测试与质量
License 许可
MIT
所属仓库
11vated/Nexus
最近更新
2026-06-19
Stars
★ 0
Forks
0

01 前言 Front Matter

name
test-generator
model
qwen2.5-coder:14b
tools
Read, Write, Glob
description
Generate comprehensive tests for Python code - use when creating new functions or fixing bugs

03 SKILL.md 正文

Test Generator Skill

When to Use

  • Creating new Python functions/modules
  • After fixing bugs (add regression tests)
  • Before refactoring

Test Structure

# test_[module].py
import pytest
from module import function

def test_function_success():
    result = function(input)
    assert result == expected

def test_function_edge_case():
    with pytest.raises(Exception):
        function(invalid_input)

Best Practices

  • One assertion per test
  • Test happy path + edge cases
  • Use descriptive names: test_should_return_X_when_Y
  • Mock external dependencies
  • Fixtures for shared setup

Running Tests

pytest                    # All tests
pytest -x                 # Stop on first failure
pytest -k pattern         # Filter by name
pytest --cov=module        # Coverage

04 同仓库更多 Skills