ワンクリックで
test
Generate unit tests, integration tests, and test data. Use when writing tests, improving test coverage, or creating test scenarios.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Generate unit tests, integration tests, and test data. Use when writing tests, improving test coverage, or creating test scenarios.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Work with Excel spreadsheets (XLSX/XLS/CSV) - read data, create spreadsheets, convert formats, analyze data, and generate reports. Use when the user asks to work with Excel files or spreadsheet data.
Write SQL queries, optimize database performance, design schemas, and debug SQL issues. Use for database operations, query optimization, and schema design.
Refactor code to improve quality, apply SOLID principles, remove code smells, and suggest better patterns. Use when improving code structure or modernizing legacy code.
Work with PowerPoint presentations (PPTX/PPT) - read slides, extract content, create presentations, convert formats, and generate slide decks. Use when the user asks to work with PowerPoint files or presentations.
Work with PDF files - read, extract text/images/tables, create PDFs, merge, split, and convert PDFs. Use when the user asks to read, create, modify, or analyze PDF documents.
Parse, validate, transform, and manipulate JSON data. Use for JSON operations, schema validation, and data transformation.
| name | test |
| description | Generate unit tests, integration tests, and test data. Use when writing tests, improving test coverage, or creating test scenarios. |
| allowed-tools | Read, Write, Bash, Grep |
Generate comprehensive tests for your code.
Python (pytest):
import pytest
from mymodule import function_to_test
class TestFunctionName:
def test_normal_case(self):
result = function_to_test("input")
assert result == "expected"
def test_edge_case_empty(self):
result = function_to_test("")
assert result == ""
def test_edge_case_none(self):
with pytest.raises(TypeError):
function_to_test(None)
def test_large_input(self):
large_input = "x" * 10000
result = function_to_test(large_input)
assert len(result) > 0
@pytest.mark.parametrize("input,expected", [
("test", "TEST"),
("hello", "HELLO"),
("123", "123"),
])
def test_multiple_cases(self, input, expected):
assert function_to_test(input) == expected
JavaScript (Jest):
describe('functionToTest', () => {
test('handles normal input', () => {
const result = functionToTest('input');
expect(result).toBe('expected');
});
test('handles empty string', () => {
const result = functionToTest('');
expect(result).toBe('');
});
test('throws on null', () => {
expect(() => functionToTest(null)).toThrow(TypeError);
});
test.each([
['test', 'TEST'],
['hello', 'HELLO'],
['123', '123'],
])('transforms %s to %s', (input, expected) => {
expect(functionToTest(input)).toBe(expected);
});
});
API Integration Tests:
import pytest
import requests
class TestAPI:
BASE_URL = "http://localhost:8000/api"
def test_create_user(self):
response = requests.post(
f"{self.BASE_URL}/users",
json={"name": "Test User", "email": "test@example.com"}
)
assert response.status_code == 201
assert response.json()["name"] == "Test User"
def test_get_user(self):
response = requests.get(f"{self.BASE_URL}/users/1")
assert response.status_code == 200
assert "name" in response.json()
def test_update_user(self):
response = requests.put(
f"{self.BASE_URL}/users/1",
json={"name": "Updated Name"}
)
assert response.status_code == 200
def test_delete_user(self):
response = requests.delete(f"{self.BASE_URL}/users/1")
assert response.status_code == 204
Database Integration Tests:
import pytest
from sqlalchemy import create_engine
from myapp.models import User, db
@pytest.fixture
def test_db():
engine = create_engine('sqlite:///:memory:')
db.create_all()
yield db
db.drop_all()
def test_user_creation(test_db):
user = User(name="Test", email="test@example.com")
test_db.session.add(user)
test_db.session.commit()
assert user.id is not None
assert User.query.count() == 1
Python Mocks:
from unittest.mock import Mock, patch, MagicMock
def test_with_mock():
# Mock object
mock_api = Mock()
mock_api.get_data.return_value = {"status": "success"}
result = function_that_uses_api(mock_api)
mock_api.get_data.assert_called_once()
def test_with_patch():
with patch('mymodule.external_api_call') as mock_call:
mock_call.return_value = {"data": "mocked"}
result = function_that_calls_api()
assert result == "mocked"
JavaScript Mocks:
const mockFn = jest.fn();
mockFn.mockReturnValue('mocked value');
jest.mock('./api', () => ({
getData: jest.fn(() => Promise.resolve({ status: 'success' }))
}));
test('calls API correctly', async () => {
const result = await functionThatUsesAPI();
expect(api.getData).toHaveBeenCalledTimes(1);
expect(result).toEqual({ status: 'success' });
});
Check Coverage:
# Python
pytest --cov=myapp --cov-report=html tests/
coverage run -m pytest
coverage report
coverage html
# JavaScript
jest --coverage
npm test -- --coverage
# View coverage
open htmlcov/index.html # Python
open coverage/index.html # JavaScript
Playwright/Selenium:
from playwright.sync_api import sync_playwright
def test_login_flow():
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page()
page.goto('http://localhost:3000/login')
page.fill('[name="email"]', 'test@example.com')
page.fill('[name="password"]', 'password123')
page.click('button[type="submit"]')
page.wait_for_url('**/dashboard')
assert page.title() == 'Dashboard'
browser.close()
Python Factory:
import factory
from myapp.models import User
class UserFactory(factory.Factory):
class Meta:
model = User
name = factory.Faker('name')
email = factory.Faker('email')
age = factory.Faker('random_int', min=18, max=100)
# Usage
user = UserFactory()
users = UserFactory.create_batch(10)
Setup and Teardown:
import pytest
@pytest.fixture(scope="function")
def setup_database():
# Setup
db.create_all()
yield db
# Teardown
db.session.remove()
db.drop_all()
@pytest.fixture(scope="module")
def app_client():
app.config['TESTING'] = True
with app.test_client() as client:
yield client
Generate tests for:
Use /test when: