Test Code Generator
Generates Vitest test code from JSON specifications using boundary value analysis and equivalence partitioning.
Test Code Generator MCP Server
An MCP server that generates Vitest test code based on boundary value analysis and equivalence partitioning from JSON specifications.
Features
- Boundary Value Analysis: Automatically generates boundary values and their adjacent values for continuous ranges
- Multiple Range Support: Handles discontinuous valid ranges (e.g., 0-10, 20-30, 40-50)
- Equivalence Partitioning: Includes all valid and invalid values from categorical data
- Pairwise Testing: Generates efficient test combinations using pairwise method
- Vitest Format: Generates clean test code using
test.eachpattern - Specification Guide: Provides prompts to help create JSON specifications
- Language-Optimized: All processing and output in English for optimal LLM performance
Quick Start
Using npx (No installation required)
# Run directly with npx
npx testing-mcp-vitest
# Configure Claude Desktop as shown below
See QUICKSTART.md for detailed setup instructions.
Installation
Using npx (Recommended)
npx testing-mcp-vitest
Local Installation
# Clone repository
git clone <repository-url>
cd test-code-generator-mcp
# Install dependencies
npm install
# Build
npm run build
Usage
Claude Desktop Configuration
Add to your claude_desktop_config.json:
{
"mcpServers": {
"test-generator": {
"command": "npx",
"args": ["testing-mcp-vitest"]
}
}
}
Config file locations:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
Available Tools
1. generate-test-code
Generates test code from JSON specification.
2. Prompts
create-test-spec: Explains how to create test specificationsboundary-value-example: Provides boundary value analysis examplesequivalence-class-example: Provides equivalence partitioning examples
Specification Format
Basic structure with single range:
{
"type": "model",
"name": "UserRegistration",
"columns": [
{
"name": "age",
"type": "number",
"valueType": "continues",
"values": {
"min": 18,
"max": 120
}
},
{
"name": "userType",
"type": "string",
"valueType": "category",
"values": {
"valid": ["admin", "user", "guest"],
"invalid": ["superuser", "root", ""]
}
}
]
}
Multiple ranges example:
{
"name": "workHours",
"type": "number",
"valueType": "continues",
"values": {
"ranges": [
{ "min": 9, "max": 12 }, // Morning shift
{ "min": 14, "max": 18 } // Afternoon shift
]
}
}
Generated Test Code Example
import { describe, test, expect } from 'vitest';
describe('Tests for UserRegistration', () => {
// Valid cases
test.each([
{ inputs: { age: 18, userType: "admin" }, description: 'Combination 1: Valid case' },
{ inputs: { age: 69, userType: "user" }, description: 'Combination 2: Valid case' },
{ inputs: { age: 120, userType: "guest" }, description: 'Combination 3: Valid case' },
// ... more test cases
])('Valid case: $description', ({ inputs }) => {
// TODO: Import the function or model to test
// import { UserRegistration } from './path/to/UserRegistration';
// TODO: Execute the test subject
// const result = UserRegistration(inputs);
// TODO: Check expected values
// expect(result).toBeDefined();
// expect(result.error).toBeUndefined();
});
// Invalid cases
test.each([
{ inputs: { age: 17, userType: "admin" }, description: 'Combination 4: Invalid case' },
{ inputs: { age: 121, userType: "user" }, description: 'Combination 5: Invalid case' },
{ inputs: { age: 50, userType: "superuser" }, description: 'Combination 6: Invalid case' },
{ inputs: { age: 50, userType: "root" }, description: 'Combination 7: Invalid case' },
{ inputs: { age: 50, userType: "" }, description: 'Combination 8: Invalid case' },
// ... more test cases
])('Invalid case: $description', ({ inputs }) => {
// TODO: Import the function or model to test
// import { UserRegistration } from './path/to/UserRegistration';
// TODO: Verify that an error occurs
// expect(() => UserRegistration(inputs)).toThrow();
// or
// const result = UserRegistration(inputs);
// expect(result.error).toBeDefined();
});
});
Key Features
Full Coverage
- All valid and invalid equivalence class values are included in test cases
- Boundary values include: min-1, min, min+1, middle, max-1, max, max+1
- For multiple ranges, includes gap values between ranges
Efficient Combinations
- 3 or fewer parameters: generates all combinations
- 4 or more parameters: uses pairwise method for efficiency
Multiple Range Support
Useful for:
- Working hours (9-12, 14-18)
- Valid scores (0-40 passing, 60-100 honors)
- Temperature ranges (different valid ranges for different conditions)
- Time slots (morning, afternoon, evening sessions)
Examples
See the examples/ directory for more specification examples:
user-registration.json- Basic model validationcalculate-discount.json- Business logic with multiple parametersmulti-range-validation.json- Complex scheduling with multiple rangesjapanese-postal-code.json- Regional validation patterns
Development
# Development mode
npm run dev
# Build
npm run build
# Production mode
npm start
# Debug mode
DEBUG=1 npm start
Publishing to npm
# Build and publish
npm publish
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
MIT - see LICENSE for details
Support
- GitHub Issues: [Report bugs or request features](/issues)
- Discussions: [Ask questions or share ideas](/discussions)
관련 서버
Scout Monitoring MCP
스폰서Put performance and error data directly in the hands of your AI assistant.
Alpha Vantage MCP Server
스폰서Access financial market data: realtime & historical stock, ETF, options, forex, crypto, commodities, fundamentals, technical indicators, & more
android-mcp-toolkit
A growing collection of MCP tools for Android Development. Currently features a deterministic Figma-SVG-to-Android-XML converter, with plans for Gradle analysis, Resource management, and ADB integration tools.
OpenAI GPT Image
Generate and edit images using OpenAI's GPT-4o image generation and editing APIs with advanced prompt control.
Cloudflare MCP Server
An example MCP server designed for easy deployment on Cloudflare Workers, operating without authentication.
MCP Toolhouse
Provides access to a wide range of tools from the Toolhouse platform.
Remote MCP Server (Authless)
A remote MCP server deployable on Cloudflare Workers without authentication.
AutoProvisioner
A server for automated provisioning, supporting both local and remote communication protocols.
SysPlant
Your Windows syscall hooking factory - feat Canterlot's Gate - All accessible over MCP
Omega Memory
Persistent memory for AI coding agents with semantic search, contradiction detection, memory decay, and cross-session learning. 25 MCP tools, local-first, #1 on LongMemEval (95.4%).
Bucket
Flag features, manage company data, and control feature access using Bucket.
YFinance Trader
Provides stock market data and trading capabilities using the yfinance library.