testing-helper
Generates unit tests, integration tests, and test strategies. Use for test creation, mocking, and coverage improvement.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Generates unit tests, integration tests, and test strategies. Use for test creation, mocking, and coverage improvement.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Helps with code explanation, refactoring, debugging, and optimization. Use when working with programming tasks.
Generates documentation for code, APIs, and projects. Use for README files, docstrings, API docs, and technical writing.
| name | testing-helper |
| description | Generates unit tests, integration tests, and test strategies. Use for test creation, mocking, and coverage improvement. |
| triggers | ["test","unit test","integration test","mock","coverage","pytest","jest","junit","testing","test case","assertion"] |
| priority | 8 |
| category | testing |
A specialized skill for creating comprehensive and maintainable tests.
When creating unit tests:
When creating integration tests:
When creating mocks:
When improving coverage:
import pytest
from unittest.mock import Mock, patch
class TestUserService:
"""Tests for UserService class."""
@pytest.fixture
def user_service(self):
"""Create a UserService with mocked dependencies."""
db = Mock()
return UserService(db)
def test_create_user_with_valid_data_returns_user(self, user_service):
"""Test that creating a user with valid data succeeds."""
# Arrange
user_data = {"name": "John", "email": "john@example.com"}
# Act
result = user_service.create_user(user_data)
# Assert
assert result.name == "John"
assert result.email == "john@example.com"
def test_create_user_with_invalid_email_raises_error(self, user_service):
"""Test that invalid email raises ValidationError."""
# Arrange
user_data = {"name": "John", "email": "invalid"}
# Act & Assert
with pytest.raises(ValidationError):
user_service.create_user(user_data)
@pytest.mark.parametrize("email", [
"",
"no-at-sign",
"@no-local.com",
"no-domain@",
])
def test_create_user_rejects_invalid_emails(self, user_service, email):
"""Test various invalid email formats are rejected."""
user_data = {"name": "John", "email": email}
with pytest.raises(ValidationError):
user_service.create_user(user_data)
describe('UserService', () => {
let userService;
let mockDb;
beforeEach(() => {
mockDb = {
save: jest.fn(),
find: jest.fn(),
};
userService = new UserService(mockDb);
});
describe('createUser', () => {
it('should create user with valid data', async () => {
// Arrange
const userData = { name: 'John', email: 'john@example.com' };
mockDb.save.mockResolvedValue({ id: 1, ...userData });
// Act
const result = await userService.createUser(userData);
// Assert
expect(result.name).toBe('John');
expect(mockDb.save).toHaveBeenCalledWith(userData);
});
it('should throw error for invalid email', async () => {
// Arrange
const userData = { name: 'John', email: 'invalid' };
// Act & Assert
await expect(userService.createUser(userData))
.rejects.toThrow('Invalid email');
});
});
});
Use one of these patterns for test names:
Should/When Pattern
should_return_user_when_valid_id_providedshould_throw_error_when_email_is_invalidGiven/When/Then Pattern
given_valid_user_when_save_then_returns_idgiven_duplicate_email_when_create_then_throwsDescriptive Pattern
test_create_user_with_valid_data_succeedstest_login_with_wrong_password_failsWhen generating tests, provide:
## Test Strategy
[Brief explanation of testing approach]
## Test Cases
[List of test scenarios to cover]
## Generated Tests
[Actual test code]
## Running Instructions
[How to run the tests]
## Coverage Notes
[What's covered and any gaps]