Backend Development 12 min read

Comprehensive Guide to API Automation Testing with HttpRunner: Process, Implementation, and Optimization

This article explains the importance of API automation testing, outlines why it is needed for complex supply‑chain systems, describes the step‑by‑step implementation using HttpRunner, and details subsequent optimizations such as mock service validation, scheduled inspections, execution time reduction, self‑service pipelines, and future planning.

Beijing SF i-TECH City Technology Team
Beijing SF i-TECH City Technology Team
Beijing SF i-TECH City Technology Team
Comprehensive Guide to API Automation Testing with HttpRunner: Process, Implementation, and Optimization

1. Role of API Automation Testing

1) Improves regression testing efficiency and reduces cost; 2) Ensures consistency and repeatability, increasing trust; 3) Automates repetitive tasks, freeing testers to design better cases; 4) Handles tests that are difficult or costly to perform manually; 5) Supports continuous integration and delivery.

2. Why Perform API Automation Testing

In supply‑chain B2B scenarios, many customized processes share a main flow but contain numerous logical branches; manual testing is slow and often incomplete, making API automation essential.

3. Implementation and Iteration Process

3.1 Deployment Overview

The deployment process involves selecting a framework, building cases, and continuously optimizing the solution through eight stages.

3.2 Detailed Walkthrough

3.2.1 Writing Test Cases for Key Customers

First, choose a suitable framework, then invest time in writing automation cases. The team selected HttpRunner for its features such as full Requests compatibility, expressive case description, separation of test logic and execution code, layered case structure, high reusability, and extensive reporting.

3.2.2 Case Accumulation

After the framework is chosen, writing cases requires planning; cases are prioritized for common order flows and critical customers. Important considerations include detailed assertions, case robustness, and handling asynchronous processes.

3.2.3 Mock Service Parameter Validation

Mock services replace downstream RPC services with fixed responses, so parameter validation is added by logging request IDs, storing parameters in Redis, and comparing them against expectations during automated runs.

3.2.4 Scheduled Inspection

Jenkins jobs are configured to run periodic inspections of online services, verifying case stability.

3.2.5 Environment Stability

Scripts ensure code and database schema consistency, restart long‑running services to avoid goroutine leaks, monitor mock service health, and clean up logs.

3.2.6 Execution Time Optimization

Parallel execution scripts, direct database queries, and on‑demand script triggers reduced total execution time from over 15 minutes to about 3 minutes for 300+ cases.

3.2.7 Self‑Service for Developers

A Jenkins job allows developers to trigger automation by providing TAPD URL, module name, test branch, and project level, with results sent via enterprise WeChat.

3.2.8 Notification Channel Improvement

Success and failure notifications are separated into distinct channels to improve visibility.

3.2.9 Integration with Release System

Automation is enforced in the release pipeline for C/D‑level projects, requiring successful execution before proceeding.

4. Future Plans and Summary

4.1 Regression of New Features

Write cases before testing, adjust during testing, and use them for regression before release.

4.2 Execution in Any Environment

Shadow routing and mock configurations enable a single set of automation code and data to run in any environment.

Automation is an ongoing process that evolves with business changes, delivering increasing benefits as case coverage grows.

BackendCI/CDAutomationAPI testingHttpRunnermock services
Beijing SF i-TECH City Technology Team
Written by

Beijing SF i-TECH City Technology Team

Official tech channel of Beijing SF i-TECH City. A publishing platform for technology innovation, practical implementation, and frontier tech exploration.

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.