Precise Testing for Backend Services: Automated Test Case Selection, Impact Assessment, and Incremental Code Coverage Analysis
The article presents a comprehensive approach to improve backend service testing by building a mapping between automated test cases and code coverage, enabling selective test execution, objective impact assessment, and incremental coverage analysis to enhance test efficiency, reliability, and CI stability.
The current testing practice for web and app backend services relies heavily on black‑box testing, which depends on testers' experience and leads to subjective coverage, missed defects, and unstable automation due to high personnel turnover.
Three major problems are identified: (1) excessive subjectivity of black‑box testing, (2) lack of objective metrics for test coverage, and (3) poor stability of large‑scale automated test suites, causing CI failures and wasted effort.
The proposed solution consists of three layers: (1) automated test case selection, (2) test impact range assessment, and (3) incremental code coverage analysis. A mapping library that links each automated test case to the set of code methods it covers is built using Jacoco on‑the‑fly instrumentation, avoiding service restarts.
For test case selection, when a code change (diff) is detected, the changed method list is matched against the mapping library to extract only the relevant test cases, which are then dynamically bound to a CI plan, reducing execution time and improving CI stability.
Impact assessment uses the same mapping to aggregate the URIs of affected test cases, providing a concrete report that guides manual regression testing and prevents missed test scopes.
Incremental coverage analysis combines the changed method list with coverage reports generated by Jacoco to produce an incremental coverage report, highlighting uncovered branches or lines and suggesting targeted test case creation.
The implementation leverages Java, SSH+RPC framework, Jacoco, Git diff JSON output, and a custom API for dynamic CI plan updates. Images illustrate the architecture, mapping generation process, and workflow.
Current progress shows over 40% incremental coverage as a test exit criterion, more than 50% reduction in test suite size for core modules, and detection of multiple bugs through the new approach.
Future plans include extending precise testing to trunk/slow CI stages, integrating case selection into business‑level test traffic filtering, exposing generic APIs for other languages and frameworks, and incorporating additional data sources such as historical code quality and bug metrics to further refine testing recommendations.
Baidu Intelligent Testing
Welcome to follow.
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.