Test Code Generator

by fyuuki0jp

Not rated
GitHub

About

Generates Vitest test code from JSON specifications using boundary value analysis and equivalence partitioning.

Details

Author
fyuuki0jp
Categories
Developer Tools

Setup

Install Test Code Generator in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/fyuuki0jp/testing-mcp-vitest

Follow the installation instructions in the repository README, then restart your MCP client.

Generates Vitest test code from JSON specifications using boundary value analysis and equivalence partitioning.

An MCP server that generates Vitest test code based on boundary value analysis and equivalence partitioning from JSON specifications.

- 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 usingtest.eachpattern
- Specification Guide: Provides prompts to help create JSON specifications
- Language-Optimized: All processing and output in English for optimal LLM performance

# Run directly with npx npx testing-mcp-vitest # Configure Claude Desktop as shown below

SeeQUICKSTART.mdfor detailed setup instructions.

# Clone repository git clone <repository-url> cd test-code-generator-mcp # Install dependencies npm install # Build npm run build

Add to yourclaude_desktop_config.json:

{ "mcpServers": { "test-generator": { "command": "npx", "args": ["testing-mcp-vitest"] } } }

- macOS:~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:%APPDATA%\Claude\claude_desktop_config.json

Generates test code from JSON specification.

- create-test-spec: Explains how to create test specifications
- boundary-value-example: Provides boundary value analysis examples
- equivalence-class-example: Provides equivalence partitioning examples

{ "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", ""] } } ] }
{ "name": "workHours", "type": "number", "valueType": "continues", "values": { "ranges": [ { "min": 9, "max": 12 }, // Morning shift { "min": 14, "max": 18 } // Afternoon shift ] } }
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(); }); });

- 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

- 3 or fewer parameters: generates all combinations
- 4 or more parameters: uses pairwise method for efficiency

- 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)

See theexamples/directory for more specification examples:

- user-registration.json- Basic model validation
- calculate-discount.json- Business logic with multiple parameters
- multi-range-validation.json- Complex scheduling with multiple ranges
- japanese-postal-code.json- Regional validation patterns

# Development mode npm run dev # Build npm run build # Production mode npm start # Debug mode DEBUG=1 npm start

- 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

- GitHub Issues: Report bugs or request features
- Discussions: Ask questions or share ideas

This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases.

Help agents automatically write and test stories for your UI components

Six read-only decision tools for coding agents to assess GitHub bounties, audit agent instructions, diagnose GitHub Actions failures and flakes, and detect MCP tool drift. Remote Streamable HTTP

AI-Safe Code Analysis with 113+ MCP tools for guard validation, memory, workflow, and testing.

fable-discipline is a Claude Code plugin that makes agentic software work follow repeatable working patterns: design before code, verify after edits, separate author from reviewer, preserve verified state between sessions, and report uncertainty honestly.

MCP server that generates production-grade engineering standards (SOLID, testing, architecture, CI/CD) for AI coding assistants

Execute JavaScript code in a modern runtime environment with support for various built-in modules.

Provides a secure JavaScript execution environment for running code snippets.

A server for JavaScript/TypeScript development with intelligent project tooling and testing capabilities.

Execute code securely in isolated sandbox environments using the E2B API.

A powerful Model Context Protocol (MCP) server that supercharges your Python development workflow with AI-powered code review, intelligent test generation, and comprehensive test execution.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.