Building a High-Performance SpringBoot + layui API Automation Platform from Scratch
This article details the design and implementation of a SpringBoot‑based API automation platform with a layui front‑end, covering architecture choices, permission management, hierarchical data design, test case handling, test set execution, result reporting, and future enhancements such as scheduling, email notifications, and multithreading.
Preface
Interface automation has lower maintenance cost and more precise result verification than UI automation. Existing solutions like TestNG or JMeter have limitations, so a custom platform was built over two months using SpringBoot, Mybatis, MySQL, Redis, jQuery, and layui.
Overview
Technology Stack
Backend: SpringBoot + Mybatis + MySQL + Redis
Frontend: jQuery + layui (recommended for beginners, with future migration to Vue)
Features
Extreme simplicity: clean UI, easy interaction
Visual data management: convenient addition and maintenance of data
Hierarchical design: projects, modules, interfaces, cases, and test suites are organized to ensure consistency and reduce redundancy
Single‑point debugging: online execution of test cases with detailed request/response info
Workflow assembly: combine multiple cases into a test suite with business‑logic flow
Details
Permission Management Design
Classic tree‑structured role control is used, with additional group permissions for the automation module.
Group permissions allow assigning or removing users and projects per group.
Platform Entry
The login page uses a Spring theme; registration is disabled and users are added by an administrator.
Redis stores token information with configurable expiration and encryption rules.
redis:
host: localhost
port: 6379
timeout: 10s
lettuce:
pool:
min-idle: 0
max-idle: 8
max-active: 8
max-wait: -1ms
password:
token:
expire:
seconds: 72000
jwtSecret: (XIAO:)_$^11244^%$_(WEI:)_@@++--(LAO:)_++++_.sds_(SHI:)Hierarchical Design
Data is divided into five layers: Project Management, Interface List, Case Management, Test Suite, and Test Result.
Project Management
Defines the basic framework of the system, e.g., platform: Sina News, project: Sports, module: La Liga.
Platform: Sina News
Project: Sports
Module: La Liga
IP address: omitted
Project modules enforce data consistency by requiring interfaces to be created under existing modules.
Each project usually has its own IP address; modules inherit the IP.
Interface List
After creating a project module, interfaces can be added under it.
Key rules:
Defines basic interface info (path, method, etc.) without detailed parameters.
Each interface must be unique; duplicate paths are prevented.
Platform, project, and module are selected from existing project management data.
Case Management
Cases describe interfaces in detail and are the core module.
Key points:
Cases depend on interfaces; they inherit IP and path.
Multiple cases per interface with different parameter values.
Case types: standard, normal, abnormal. Only one standard case per interface, which can be copied for convenience.
Execute button sends a request using the case data; edit and detail buttons allow modification and inspection.
Basic Information
Displays descriptive information automatically read from the associated platform, project, module, interface, etc.
Request Parameters
Includes request headers and body.
Associated Extraction
Used for test suites when later interfaces depend on values from previous responses, e.g., extracting a token after login.
Variable name: name of the temporary variable.
Path expression: JSON path, same syntax as JMeter’s JSON Extractor.
Default value: used when extraction fails.
Result Assertion
Supports regular assertions (contains, equals, JSON) and Beanshell assertions.
Contains: response includes expected value.
Equals: response exactly matches expected value.
JSON: extracts a field via path expression and compares it to expected value.
Result Example
Shows a sample response returned by an interface.
Test Suite
Combines multiple interface cases into a business‑logic workflow.
Editing a test suite involves adding/removing cases and ordering them.
One‑click execution runs all cases sequentially; future plans include project‑level execution and multithreading.
Test Result
After execution, results are persisted and can be viewed in detail.
Double‑click a row to view the raw response.
Challenges and Optimization List
Implementation of Associations
During test suite execution, a map (association pool) is created in memory. Each case’s extraction rules are applied to its response; extracted values are stored in the pool. When a case parameter uses the ${param} syntax, the value is fetched from the pool. This enables dynamic sharing of values across cases and simplifies updates.
Pending Optimizations
Scheduled tasks: visual editor for timed jobs.
Email notifications: decide format for sending test results.
Multithreading: execute suites per project with thread pools.
Preconditions: cases may depend on prerequisite conditions.
Retry strategy: automatic retries for failed cases with configurable count.
Request parameters: support JSON body format.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java High-Performance Architecture
Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
