Configs2026年7月18日·1 分钟阅读

Hoverfly — Lightweight API Simulation and Service Virtualization

A lightweight Go-based tool for simulating and testing HTTP services by capturing and replaying API traffic.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Hoverfly API Simulation
直接安装命令
npx -y tokrepo@latest install 513ba3dc-82e9-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

Hoverfly is a lightweight HTTP(S) proxy written in Go that captures and simulates API interactions. It sits between your application and external services, recording real responses during development and replaying them during testing — eliminating flaky tests caused by third-party dependencies.

What Hoverfly Does

  • Captures real HTTP traffic and stores it as replayable simulations
  • Simulates APIs by matching requests and returning recorded responses
  • Modifies responses on the fly with middleware and templating
  • Introduces network latency and failure scenarios for chaos testing
  • Provides a web admin UI and REST API for simulation management

Architecture Overview

Hoverfly operates as a forward or reverse proxy. In capture mode, it passes requests through to real services while recording request-response pairs. In simulate mode, it matches incoming requests against stored simulations using configurable matchers (exact, glob, regex, xpath, jsonpath) and returns the paired response without hitting the real service.

Self-Hosting & Configuration

  • Single binary install via brew, apt, or direct download
  • Run as a proxy or in webserver mode (no proxy config needed)
  • Manage via hoverctl CLI or REST admin API on port 8888
  • Import/export simulations as JSON for version control
  • Configure request matching strategies per endpoint

Key Features

  • Record-and-replay workflow for deterministic API testing
  • Request matching with glob, regex, XPath, and JSONPath matchers
  • Response templating with dynamic data (timestamps, UUIDs, request fields)
  • Middleware support for custom response modification logic
  • Stateful simulations for multi-step workflow testing

Comparison with Similar Tools

  • WireMock — Java-based, more features for enterprise mocking; Hoverfly is lighter and language-agnostic
  • MockServer — Broader protocol support; Hoverfly focuses on HTTP simplicity
  • Mountebank — Multi-protocol (TCP, SMTP); Hoverfly is HTTP-only but faster
  • Nock (Node.js) — In-process HTTP mocking; Hoverfly works as external proxy for any language

FAQ

Q: Can Hoverfly handle HTTPS traffic? A: Yes. It generates a self-signed CA certificate for MITM proxy mode. Install the CA cert in your trust store for transparent HTTPS capture.

Q: How do I use Hoverfly in CI pipelines? A: Export simulations to JSON, commit them to your repo, and start Hoverfly in simulate mode before running tests. No network access to real APIs needed.

Q: Does Hoverfly support WebSocket or gRPC? A: Hoverfly is HTTP/HTTPS only. For gRPC, consider using grpc-mock or similar tools.

Q: Can I add latency to simulations? A: Yes. Configure fixed or random delays per simulation to test timeout handling and retry logic.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产