测试工作流助手

Testmate是一款个人开发工作流助手,可直接在IDE中简化从开发到测试的整个流程,支持AI生成测试用例、功能测试、压力测试和实时性能指标监控。

  • by V3669
  • JavaScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 V3669/testmate

使用说明

测试对象

一个个人开发工作流助手,可以从IDE简化整个开发到测试过程。

特性

  • AI驱动的测试:使用AI代理直接从IDE生成和运行测试用例
  • 功能测试:使用详细的断言和diff视图测试API逻辑
  • 压力测试:使用可配置的并发性和持续时间对端点进行负载测试
  • 实时度量:查看p50、p95、p99延迟指标和吞吐量统计数据
  • MCP集成:连接Cursor、Windsurf、反重力或任何兼容MCP的IDE
  • 热重载:更新测试配置时,测试会自动运行

快速开始

# Install dependencies
npm install

# Start the server
npm start

服务器运行于 http://localhost:3000

MCP设置

用于光标/风帆/VCode

添加到MCP配置中(通常 ~/.cursor/mcp.json 或项目 .mcp.json):

{
  "mcpServers": {
    "testmate": {
      "command": "node",
      "args": ["/path/to/testmate/gateway.js"]
    }
  }
}

可用的MCP工具

工具 说明
run_functional_tests 从tests.json运行功能测试
run_stress_simulation 对特定场景进行压力测试
get_test_results 使用指标获取最新测试结果

配置

编辑 tests.json 定义您的测试场景:

{
  "config": {
    "baseUrl": "http://localhost:8080",
    "globalHeaders": { "Authorization": "Bearer {{env.API_KEY}}" },
    "timeout": 5000
  },
  "scenarios": [
    {
      "id": "health_check",
      "type": "functional",
      "method": "GET",
      "endpoint": "/health",
      "expect": {
        "status": 200,
        "bodyPartial": { "status": "ok" }
      }
    },
    {
      "id": "stress_users",
      "type": "stress",
      "targetScenarioId": "create_user",
      "parameters": {
        "connections": 50,
        "duration": "10s",
        "pipelining": 1
      },
      "thresholds": {
        "p95": 200,
        "errors": 0.01
      }
    }
  ]
}

环境变量

使用 {{env.VAR_NAME}} 在环境变量的配置中:

{
  "config": {
    "baseUrl": "{{env.API_URL}}",
    "globalHeaders": {
      "Authorization": "Bearer {{env.API_KEY}}"
    }
  },
  "env": {
    "API_URL": "http://localhost:3000",
    "API_KEY": "your-key-here"
  }
}

命令

命令 描述
npm start 启动web服务器(http://localhost:3000)
npm run mcp 启动MCP网关进行IDE集成
npm run dev 在开发模式下运行服务器和客户端
npm test 运行所有测试
npm run build 建立客户

AI代理集成(SKILL.md)

该项目包括 SKILL.md AI编码助手(如Claude Code、Cursor、Windsurf)可以使用该文件来了解如何使用Testmate进行测试。

与AI代理一起使用

SKILL.md提供:

  • 所有可用的MCP工具和参数
  • 配置示例
  • 常见任务的使用提示
  • 环境变量设置
  • 压力测试参数和阈值

AI代理可以读取 SKILL.md 自动理解如何:

  • 生成并运行测试
  • 配置测试场景
  • 解释测试结果
  • 使用特定参数进行压力测试

项目结构

testmate/
├── gateway.js           # MCP server entry point
├── web-server.js       # HTTP server entry point
├── tests.json          # Test configuration
├── package.json        # Root dependencies
├── Sentinel/
│   ├── client/         # React UI dashboard
│   │   ├── src/
│   │   └── dist/      # Built static files
│   └── server/        # Core testing engine
│       ├── SentinelService.js
│       ├── functionalRunner.js
│       ├── stressRunner.js
│       ├── configLoader.js
│       └── tests/
└── README.md

测试

运行所有测试:

npm test

跑步覆盖:

npm run test:coverage

技术栈

  • 禁食 -Web服务器框架
  • MCP-SDK -模型上下文协议
  • 反应 -UI仪表板
  • 机炮 -负载测试
  • 玩笑 -测试框架
  • 双向通信 -实时更新

许可证

ISC