How HiMock Transforms Full‑Scenario Mock Testing for Complex Backend Services

HiMock is a comprehensive mock platform designed to overcome traditional mock limitations by offering low‑code, code‑decoupled, high‑performance, and full‑scenario support across multiple protocols and front‑end/back‑end channels, enabling efficient testing, performance benchmarking, and parallel development for complex services such as bike, e‑bike, and ride‑hailing.

HelloTech
HelloTech
HelloTech
How HiMock Transforms Full‑Scenario Mock Testing for Complex Backend Services

Pain Points in Hello Business Data Scenarios

Hello (哈啰) operates a wide range of services—bike sharing, e‑bike, battery swapping, ride‑hailing, etc.—accessed via APP, Alipay mini‑program, WeChat mini‑program, H5 and web. Core services are exposed through HTTP or internal RPC interfaces, covering user growth, configuration, comprehensive platforms, storage, algorithms, open APIs, big data, and mapping. Testing these heterogeneous flows reveals severe bottlenecks.

Integrated Hardware‑Software Application Scenarios

The platform must handle both software and hardware protocols, linking devices such as bicycles, e‑bikes, batteries, and cabinets to the backend services.

Testing Phase Pain Points

Data‑testing pipelines for bike‑related features can take more than half a day to construct manually. Different input parameters produce divergent results, making mock data generation difficult. For assist‑bike features, simulating out‑of‑zone power‑off scenarios requires lengthy on‑site runs. Ride‑hailing integrates numerous third‑party platforms, causing regression testing to be cumbersome. Payment modules involve many exception cases, especially identity verification data that is hard to fabricate. Battery‑swap development suffers from parallel projects and missing partner APIs, inflating debugging costs. E‑bike unit tests require massive mock code, and some mocks need intrusive code changes.

Comparison of HiMock and Traditional Mock

Traditional mock suffers from frequent code changes, simple linear chains, difficult data construction without documentation, and limited protocol support. Hello’s full‑scenario requirements demand minimal code changes, support for complex multi‑endpoint and hardware protocols, parallel development with divergent responses, and extensibility across soft‑hardware interfaces.

Rethinking Traditional Mock Design

HiMock is built on six principles: low‑code framework for rapid setup, complete code decoupling so users never modify production code, high performance without impacting system metrics, low‑cost user‑friendly mock creation, support for pre‑ and post‑processing scenarios (signatures, callbacks, DB ops), and full‑scenario coverage across all front‑end and back‑end protocols.

Practical Implementation of Mock Technology for Full‑Scenario Business Domains

The new architecture breaks the conventional hardware‑software coupling by intercepting requests at a unified rule engine. After protocol interception, the engine evaluates rules for match, silence switches, effective time windows, scope, latency, parameter substitution, and post‑conditions, delivering a one‑stop multi‑endpoint mock solution.

Breaking Traditional Internet’s Hardware‑Software Combined Mock Architecture

Service flow: C‑end users (APP, Alipay/WeChat mini‑programs) pass through an HTTP gateway into domain‑specific entry points (bike, assist‑bike, e‑bike, swap, ride‑hailing). After protocol interception, the rule engine determines whether a mock applies based on configured criteria, then returns the mock response. The platform supports silent switches, time‑bound activation, scoped deployment, latency injection, and parameter replacement.

Overall HiMock Workflow

Mock cases originate from three sources: HiMock itself, Fox, and third‑party tools. Backend requests are intercepted by an Agent, which consults the rule engine to return mock data if a rule matches. The Agent is auto‑deployed during Atlas container rollout and updates itself when new cases are added. Front‑end requests on iOS use NSURLProtocol interception; Android uses OkHttp interception; other protocols can be added via a plugin system.

Underlying Agent Design

The Agent relies on four components: bytecode interception (using ByteBuddy for low‑code agility), pluggable protocol interceptors, a shell premain function for dynamic code updates, and post‑processing to handle database writes, message dispatch, and callback execution. It intercepts HTTP clients such as CloseableHttpClient, HttpClient, OkHttpClient, RestTemplate, RPC handlers, and MQ clients.

Rule Engine Design

The engine focuses on high concurrency, compatibility, and multi‑endpoint support. All intercepted requests are normalized to JSON for rule matching. After benchmarking fastJson, Jackson, json‑path, and snack3, snack3 was chosen for its richer selector syntax and superior performance. Supported conditions include equals, not equals, contains, not contains, in, and logical combinations (AND/OR). Parameters are auto‑generated from request payloads, and expected values are intelligently matched.

Platform System Architecture

HiMock consists of a web dashboard, core services, data layer, Agent, and mock service. The web UI provides dashboard, mock management, permission control, and tool integration (YAPI/Swagger import). Core services handle container orchestration, automatic deployment, mock creation, logging, rule management, and statistics. The data layer uses MySQL, Redis, and Elasticsearch; Redis caches real‑time data, which is periodically flushed to MySQL for persistence.

Real‑World Use Cases

HiMock supports dependency testing (date‑bound mock activation), automated testing (auto‑toggle switches), performance testing (global silent mode to bypass mocks), and parallel development (scoped mock activation and dynamic parameter adjustment). However, it emphasizes that mock‑based testing should complement, not replace, non‑mock testing to avoid blind spots.

Platform Capabilities

Key features include RPC mock creation with customizable titles (e.g., assist‑bike compensation), environment selection (FAT/UAT), permanent or time‑bound activation, automatic parameter extraction from request logs, execution logs, and change history. Advanced scenarios support post‑mock callbacks for HMS, HTTP, etc.

Value‑Recovery Analysis of HiMock

Six metrics are tracked: interface call statistics, mock coverage per business line, mock proportion, business‑line mock operation analysis, mock case counts, and average mock execution time. Visual dashboards show per‑line call volume, mock call ratios, and trends.

Future Plans and Discussion

Roadmap includes three stages: (1) manual mock capture (current pain point), (2) integrated HiMock platform with one‑click front‑end capture, rule auto‑generation, and log‑driven mock creation, dramatically improving efficiency, and (3) intelligent HiMock that adapts to middleware protocols (DB, MQ), integrates with simulation labs, and adds self‑learning capabilities for broader scenario coverage.

Rule Enginebackend developmentPerformance TestingService Architecturetesting automationmock testing
HelloTech
Written by

HelloTech

Official Hello technology account, sharing tech insights and developments.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.