一键导入
unit-test-generator
Generates comprehensive unit tests for functions and classes in multiple languages
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Generates comprehensive unit tests for functions and classes in multiple languages
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Analyze and optimize code performance, identify bottlenecks, and suggest improvements
Automated deployment orchestration with rollback, blue-green, and canary deployment strategies
Manage development environments, configurations, and secrets across local, staging, and production
Technical documentation specialist - create docs, API references, user guides for technical and non-technical audiences
Backend architecture agent for API design, database schema, and microservices
Data engineering agent for ETL pipelines, data warehousing, and analytics
基于 SOC 职业分类
| name | unit-test-generator |
| description | Generates comprehensive unit tests for functions and classes in multiple languages |
| allowed-tools | ["Read","Grep","Write","Bash"] |
| version | 1.0.0 |
| author | GLINCKER Team |
| license | Apache-2.0 |
| keywords | ["testing","unit-tests","tdd","quality-assurance"] |
Automatically generates comprehensive unit tests for your code, supporting multiple programming languages and testing frameworks.
This skill creates high-quality unit tests by:
When asked to generate tests:
Identify target code:
Detect language and framework:
Analyze logic:
Create tests covering:
Happy Path Tests:
Edge Cases:
Error Conditions:
Integration Points:
Follow framework-specific conventions:
Python (pytest):
import pytest
from module import function_to_test
class TestFunctionName:
def test_happy_path(self):
# Arrange
input_data = "valid input"
# Act
result = function_to_test(input_data)
# Assert
assert result == expected_value
def test_edge_case_empty_input(self):
with pytest.raises(ValueError):
function_to_test("")
JavaScript (Jest):
describe('functionName', () => {
test('should handle valid input', () => {
// Arrange
const input = 'test';
// Act
const result = functionName(input);
// Assert
expect(result).toBe(expected);
});
test('should throw error on invalid input', () => {
expect(() => functionName(null)).toThrow();
});
});
Ensure generated tests:
Present the generated tests and:
User Request: "Generate tests for the calculate_discount function"
Source Code:
def calculate_discount(price: float, discount_percent: int) -> float:
if discount_percent < 0 or discount_percent > 100:
raise ValueError("Discount must be between 0 and 100")
return price * (1 - discount_percent / 100)
Generated Tests:
import pytest
from shopping import calculate_discount
class TestCalculateDiscount:
def test_valid_discount(self):
"""Test normal discount calculation"""
result = calculate_discount(100.0, 20)
assert result == 80.0
def test_zero_discount(self):
"""Test with no discount"""
result = calculate_discount(100.0, 0)
assert result == 100.0
def test_full_discount(self):
"""Test with 100% discount"""
result = calculate_discount(100.0, 100)
assert result == 0.0
def test_negative_discount_raises_error(self):
"""Test that negative discount raises ValueError"""
with pytest.raises(ValueError, match="between 0 and 100"):
calculate_discount(100.0, -10)
def test_discount_over_100_raises_error(self):
"""Test that discount > 100 raises ValueError"""
with pytest.raises(ValueError, match="between 0 and 100"):
calculate_discount(100.0, 150)
def test_zero_price(self):
"""Test with price of 0"""
result = calculate_discount(0.0, 50)
assert result == 0.0
User Request: "Create unit tests for the UserValidator class"
Generated Approach:
When using this skill:
Adapts to detected setup:
| Language | Framework | Test File Location |
|---|---|---|
| Python | pytest | tests/test_*.py |
| Python | unittest | tests/test_*.py |
| JavaScript | Jest | __tests__/*.test.js |
| TypeScript | Jest | __tests__/*.test.ts |
| Go | testing | *_test.go (same dir) |
| Rust | built-in | tests/ or inline |
Want to add support for a new language or framework?
Apache License 2.0 - See LICENSE
GLINCKER Team