Backend Development 21 min read

Design and Implementation of an Automated Backend Interface Testing System

This article presents a comprehensive backend automated testing framework that unifies HTTP and RPC access, introduces a parameter‑pool concept, leverages JSON Schema and JSONPath for validation, and outlines coverage metrics, test case generation, discovery, and continuous improvement to achieve near‑100% API test coverage.

High Availability Architecture
High Availability Architecture
High Availability Architecture
Design and Implementation of an Automated Backend Interface Testing System

Backend developers often face recurring bugs, version‑compatibility issues, and high maintenance costs for test cases. To address these challenges, the article proposes an automated testing system that aims for 100% test‑case coverage while reducing management overhead.

Background and Motivation : Existing tools like WeJestAPITest, JMeter, and Postman either lack flexibility for custom scheduling, RPC support, or integration with internal systems. The new system is built to be language‑agnostic, low‑code, and closely aligned with backend developers' workflows.

Overall Architecture : The system unifies HTTP (e.g., http://host:port/urlpath + reqbody ) and RPC (e.g., rpc://ip:port/method + reqbody ) access, allowing test cases to be assigned to modules and dispatched via an asynchronous MQ with multiple trigger sources and granular scheduling options.

Parameter Pool : A key‑value pool stores extracted variables from responses, supporting both literal values and JSONPointer paths. This decouples test case dependencies, enabling reusable variables across scenarios.

JSON Schema Component : Validation rules are expressed as JSON Schema, providing full‑field coverage, type checks, and constraints. Example schema for a bookInfo object:

{
  "type": "object",
  "required": ["bookId","title","author","cover","format","price"],
  "properties": {
    "bookId": {"type": "string", "const": "123456"},
    "title": {"type": "string", "minLength": 1},
    "author": {"type": "string", "minLength": 1},
    "cover": {"type": "string", "format": "uri"},
    "format": {"type": "string", "enum": ["epub","txt","pdf","mobi"]},
    "price": {"type": "number", "exclusiveMinimum": 0}
  }
}

JSONPath Component : For assertions that involve relational checks (e.g., $.updateTime > $.createTime ) or array validations, JSONPath expressions are used. Sample expressions:

// validate updateTime >= createTime
$.updateTime > $.createTime

// ensure bookId equals a specific value
$.bookId == ["123456"]

// datas array must be non‑empty
$.datas.length > [0]

Coverage Metrics : Coverage is measured at both global and per‑API levels. An API’s effective test cases consist of all enumerated parameter values plus their valid combinations. Formulas:

GlobalCoverage = CoveredAPIs / TotalAPIs * 100%
APIEffectiveCases = EnumeratedValues + EnumeratedCombinations
APICoverage = CoveredEffectiveCases / APIEffectiveCases * 100%

Test Case Generation and Discovery : Online traffic is analyzed to extract parameter characteristics (count, type, value range, enumerability, combinability). Enumerated parameters are used to auto‑generate test cases and JSON Schemas via tools like genson . New interfaces and uncovered parameter combinations are discovered offline and added to the suite.

Continuous Improvement : Failed cases trigger automated promotion workflows—removing obsolete cases, replacing them with regenerated ones, or refining schemas. The system supports multi‑source scheduling, RPC integration, and scenario testing with variable references.

Conclusion : By integrating JSON Schema, JSONPath, a parameter pool, and traffic‑driven case generation, the framework achieves near‑100% API coverage, reduces manual effort, and provides a scalable, language‑agnostic solution for backend automated testing.

backendJSON SchemaAutomated TestingJsonPathtest coverageAPI testing
High Availability Architecture
Written by

High Availability Architecture

Official account for High Availability Architecture.

0 followers
Reader feedback

How this landed with the community

login 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.