Generate characterization tests to capture and verify existing behavior before migration
Generates characterization tests to capture and verify existing behavior before migration.
npx claudepluginhub a5c-ai/babysitterThis skill is limited to using the following tools:
README.mdGenerates characterization tests (also known as golden master tests or approval tests) to capture existing system behavior before migration, ensuring functional equivalence after changes.
Enable behavior preservation during migration through:
This skill can leverage the following external tools when available:
| Tool | Purpose | Integration Method |
|---|---|---|
| ApprovalTests | Approval testing framework | Library |
| Jest snapshots | JavaScript snapshot testing | Framework |
| pytest-snapshot | Python snapshot testing | Plugin |
| TextTest | Golden master testing | CLI |
| Verify | .NET approval testing | Library |
| Scientist | Safe refactoring library | Library |
| AI Testing MCP | AI-powered test generation | MCP Server |
# Invoke skill for characterization test generation
# The skill will analyze code and generate tests
# Expected inputs:
# - targetPath: Path to code to characterize
# - testFramework: 'jest' | 'pytest' | 'junit' | 'nunit' | 'auto'
# - outputDir: Directory for generated tests
# - captureMode: 'snapshot' | 'approval' | 'recording'
Analysis Phase
Input Discovery Phase
Capture Phase
Test Generation Phase
{
"generationId": "string",
"timestamp": "ISO8601",
"target": {
"path": "string",
"language": "string",
"framework": "string",
"unitsAnalyzed": "number"
},
"testsGenerated": {
"total": "number",
"byType": {
"snapshot": "number",
"approval": "number",
"recording": "number"
},
"coverage": {
"functions": "number",
"branches": "number",
"lines": "number"
}
},
"characterizations": [
{
"unit": "string",
"type": "function|method|endpoint|class",
"inputs": [
{
"name": "string",
"type": "string",
"values": ["any"],
"source": "existing|generated|boundary"
}
],
"outputs": {
"type": "string",
"goldenMasterPath": "string",
"checksum": "string"
},
"testFile": "string",
"baselineApproved": "boolean"
}
],
"edgeCases": [
{
"unit": "string",
"case": "string",
"input": "any",
"expectedBehavior": "string",
"covered": "boolean"
}
],
"dependencies": {
"external": ["string"],
"mocked": ["string"],
"recorded": ["string"]
},
"artifacts": {
"testSuite": "string",
"goldenMasters": "string",
"recordings": "string",
"coverageReport": "string"
}
}
This skill integrates with the following Code Migration/Modernization processes:
Create .characterization-tests.json in the project root:
{
"testFramework": "auto",
"outputDir": "./tests/characterization",
"captureMode": "snapshot",
"goldenMasterDir": "./tests/golden-masters",
"inputGeneration": {
"boundary": true,
"combinatorial": true,
"maxCombinations": 100,
"includeNulls": true,
"includeEmpty": true
},
"outputCapture": {
"format": "json",
"normalizeWhitespace": true,
"ignorePaths": ["$.timestamp", "$.requestId"],
"tolerance": {
"numeric": 0.001,
"dateTime": "1s"
}
},
"dependencies": {
"mockExternal": true,
"recordMode": false,
"replayMode": true
},
"approval": {
"requireApproval": true,
"approvalDir": "./tests/approvals",
"reportFormat": "markdown"
},
"ci": {
"failOnNewTests": false,
"updateGoldenOnPass": false,
"generateCoverageReport": true
}
}
When AI Testing MCP Server is available:
// Example AI-powered test generation
{
"tool": "ai_testing_generate",
"arguments": {
"target": "./src/services/user.ts",
"framework": "jest",
"style": "characterization"
}
}
// Generated characterization test
describe('UserService', () => {
describe('calculateDiscount', () => {
it('should match snapshot for standard customer', () => {
const result = userService.calculateDiscount({
customerId: 'C001',
purchaseAmount: 100,
loyaltyPoints: 500
});
expect(result).toMatchSnapshot();
});
it('should match snapshot for premium customer', () => {
const result = userService.calculateDiscount({
customerId: 'C002',
purchaseAmount: 100,
loyaltyPoints: 5000,
isPremium: true
});
expect(result).toMatchSnapshot();
});
// Edge cases
it('should match snapshot for zero amount', () => {
const result = userService.calculateDiscount({
customerId: 'C001',
purchaseAmount: 0,
loyaltyPoints: 0
});
expect(result).toMatchSnapshot();
});
});
});
// Generated approval test
public class UserServiceCharacterizationTest {
@Test
public void calculateDiscount_standardCustomer() {
UserService service = new UserService();
DiscountResult result = service.calculateDiscount(
new DiscountRequest("C001", 100.0, 500)
);
Approvals.verify(result);
}
@Test
public void calculateDiscount_boundaryValues() {
UserService service = new UserService();
// Boundary: minimum values
Approvals.verify(service.calculateDiscount(
new DiscountRequest("C001", 0.01, 0)
), "minimum");
// Boundary: maximum values
Approvals.verify(service.calculateDiscount(
new DiscountRequest("C001", 999999.99, 999999)
), "maximum");
}
}
# Generated recording-based test
import pytest
from tests.recordings import PlaybackRecorder
class TestUserServiceCharacterization:
@pytest.fixture
def recorder(self):
return PlaybackRecorder('tests/recordings/user_service')
def test_get_user_profile_recorded(self, recorder):
"""Replay recorded external API interactions"""
with recorder.playback('get_user_profile_c001'):
service = UserService()
result = service.get_user_profile('C001')
assert result == recorder.expected_output()
def test_update_user_settings_recorded(self, recorder):
"""Verify database interactions match recording"""
with recorder.playback('update_settings_c001'):
service = UserService()
result = service.update_settings('C001', {'theme': 'dark'})
recorder.verify_database_calls()
assert result == recorder.expected_output()
test-coverage-analyzer: Analyze coverage gapsmigration-validator: Validate migration resultsstatic-code-analyzer: Identify testable code pathsmigration-testing-strategist: Uses this skill for test strategyregression-detector: Uses this skill for regression detectionparallel-run-validator: Uses this skill for comparison testingActivates when the user asks about AI prompts, needs prompt templates, wants to search for prompts, or mentions prompts.chat. Use for discovering, retrieving, and improving prompts.
Search, retrieve, and install Agent Skills from the prompts.chat registry using MCP tools. Use when the user asks to find skills, browse skill catalogs, install a skill for Claude, or extend Claude's capabilities with reusable AI agent components.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.