Industry Insights 11 min read

How Baidu Scales Intelligent Testing: From AST Unit Tests to GUI Action Generation

This article reveals Baidu's end‑to‑end intelligent testing pipeline, detailing AST‑driven unit test creation, automated interface test generation, visual UI interaction case synthesis, smart GUI action set production, and front‑end assertion automation, along with the techniques and results achieved.

Baidu Geek Talk
Baidu Geek Talk
Baidu Geek Talk
How Baidu Scales Intelligent Testing: From AST Unit Tests to GUI Action Generation

01. AST‑Based Abnormal Unit Test Generation

Automatic code‑level test case generation addresses the difficulty and time cost of writing unit tests by analyzing code structure and information to produce test code automatically.

The core technique combines code understanding, test data generation, and test‑driven code synthesis. Static analysis transforms source code into structured function feature data, capturing call patterns, variable declarations, assignments, relationships, literals, and mock points.

Test data generation draws from boundary, random, mutation, literal values, instrumentation parameters, and custom business data. To avoid explosion, the system augments traditional generation with high‑risk variable selection, path selection, symbolic execution, and search‑based algorithms such as genetic algorithms that evaluate fitness to guide data creation, improving branch coverage while limiting invalid cases.

Test‑driven code synthesis uses multi‑language templates (e.g., gtest) and intelligent mock generators to emit compilable test code. The solution currently supports C++, Go, and Objective‑C, detecting over 1,000 abnormal patterns such as crashes, infinite loops, and panics.

02. Interface‑Level Test Case Automation

Interface test automation generates API requests to replace manual test case authoring, reducing incomplete coverage and labor costs.

The approach extracts API definitions from management tools, logs, packet captures, and manual analysis, then applies field constraints to automatically produce large batches of test cases for contract and regression testing.

Assertion automation leverages historical execution results to infer expected response structures and value characteristics, automatically generating assertions for each field. Over 20,000 smart cases have been created, representing more than 80% of the total case volume.

03. UI Shallow Interaction Case Generation

UI automation faces high authoring cost, low recall, and maintenance overhead. For simple UI interactions, visual techniques are employed to generate test cases.

The pipeline consists of an offline data‑mining module and a real‑time execution module. Offline, a DNN object‑detection model classifies and regresses UI components, while a mining process records key DOM elements to build contextual action sequences. Online, these actions are replayed and validated using UI‑diff visual comparison.

The system has produced low‑cost, high‑recall cases across multiple product lines, uncovering 16 real issues and generating over 1,000 cases for a pre‑admission pipeline, with three defects already identified during trial.

04. GUI Traversal Action‑Set Automatic Generation

This stage tackles the generation of action sets for GUI traversal, monkey testing, and inspection, aiming for efficient, human‑like exploration.

Action‑set generation balances resource consumption and coverage/bug‑exposure rates. Traditional random monkey testing is fast but wasteful; the proposed method builds a weighted graph from UI component trees, assigning weights based on attributes and historical usage, then transforms the problem into a weighted graph traversal.

To avoid local loops, a Deep‑Q‑Learning agent receives rewards for reaching new pages, enabling self‑exploration and learning. Compared with pure random traversal, intelligent traversal improves coverage by 33% for the same time and reduces testing time by 75% for equal coverage.

05. Front‑End Test Assertion Automation

Manual assertion writing suffers from inconsistency, high effort, and incompleteness, leading to missed bugs.

The solution generates comprehensive assertions automatically. Two strategies are used: reference‑based recall, comparing the current version against a known‑good version; and non‑reference recall, detecting obvious anomalies such as white screens or garbled text.

Baidu's implementation adds multi‑level page understanding and feature extraction to handle device‑specific layout variations and complex pages, achieving a daily run count of hundreds of thousands, an accuracy above 97%, and interception of over 2,000 bugs.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ASTAutomated TestingSoftware qualityUI testingBaiduTest Generation
Baidu Geek Talk
Written by

Baidu Geek Talk

Follow us to discover more Baidu tech insights.

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.