dart-test
Run Dart unit tests by executing test files or directories with configurable options to verify code functionality during development.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "dart-test"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | Path to the test file or directory | |
| options | No | Additional test options | |
| workingDir | No | Working directory for the command |
Implementation Reference
- src/tools/test.ts:11-35 (handler)The main handler function for the 'dart-test' tool. It executes the 'dart test' command with the provided path, options, and working directory, handling absolute paths and returning stdout/stderr.
export async function test({ path, options = [], workingDir }: z.infer<typeof testSchema>) { // Convert relative path to absolute path if provided const absolutePath = path ? toAbsolutePath(path, workingDir) : undefined; // If workingDir is provided, ensure it's absolute const absoluteWorkingDir = workingDir ? toAbsolutePath(workingDir) : workingDir; const args = [ ...(absolutePath ? [absolutePath] : []), ...options ]; const { stdout, stderr } = await executeDartCommand('test', args, absoluteWorkingDir); return { content: [ { type: "text" as const, text: stdout || stderr } ], isError: !!stderr }; } - src/tools/test.ts:5-9 (schema)Zod schema defining the input parameters for the 'dart-test' tool: optional path, options array, and workingDir.
export const testSchema = z.object({ path: z.string().optional().describe('Path to the test file or directory'), options: z.array(z.string()).optional().describe('Additional test options'), workingDir: z.string().optional().describe('Working directory for the command') }); - src/index.ts:42-42 (registration)Registers the 'dart-test' tool on the MCP server using the testSchema.shape and the test handler function.
server.tool('dart-test', testSchema.shape, test);