Source Code Coverage Tracking Without Manual Test Instrumentation

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Manual participation of a skilled person is required to obtain code coverage, increasing costs and complexity in measuring source code quality.

Innovation Solution

A method and apparatus that automatically obtains code coverage by adding private variables to methods not executed in the source code, recording execution of code statements, and displaying coverage information without modifying the startup command, enabling parallel testing and accurate coverage measurement across multiple test cases.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If manual participation of a skilled person is used to obtain code coverage, then code coverage measurement is achieved, but labor costs and operational complexity increase

Engineering Contradiction:
Improvecode coverage measurementVSAvoidmanual participation requirement
Core Design Contradiction:
Measurement precisionVSEase of operation

Solution Approach 1:

The code coverage measurement system performs self-service by automatically adding private variables to unexecuted methods and collecting execution data without human intervention. The system autonomously instruments the source code, executes test cases, and generates coverage reports, eliminating the need for skilled personnel to manually perceive and record the coverage obtaining process.

Inventive Principle:
Principle #25Self-service

Solution Approach 2:

Private variables serve as intermediaries between the code execution process and the coverage measurement system. These variables are automatically added to methods and statements to record execution status, acting as a mediator that captures coverage information without requiring manual intervention while maintaining the natural flow of code execution.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Measurement precision

If private variables are added to all methods including executed ones, then complete coverage information is obtained, but code modification complexity and maintenance costs increase

Engineering Contradiction:
Improvecoverage information completenessVSAvoidcode modification complexity
Core Design Contradiction:
Measurement precisionVSDevice complexity

Solution Approach 1:

The system applies local quality by adding private variables selectively only to unexecuted methods and specific code statements, rather than uniformly to all code. This targeted approach ensures coverage information is collected where needed (in previously unexecuted paths) while minimizing unnecessary modifications to already-executed code, thereby reducing overall code complexity and maintenance burden.

Inventive Principle:
Principle #3Local quality

Solution Approach 2:

The system performs partial action by instrumenting only the necessary portions of the code (unexecuted methods and statements) rather than the entire codebase. This selective instrumentation achieves complete coverage measurement while avoiding the overhead of modifying every single method, thus balancing measurement completeness with code modification simplicity.

Inventive Principle:
Principle #16Partial or excessive action

3Measurement precision

If the startup command is modified to add private variables, then code coverage tracking is enabled, but test platform flexibility and ease of use decrease

Engineering Contradiction:
Improvecode coverage trackingVSAvoidtest platform flexibility
Core Design Contradiction:
Measurement precisionVSAdaptability or versatility

Solution Approach 1:

The system performs preliminary action by automatically adding private variables to unexecuted methods before test execution begins. This pre-instrumentation occurs transparently during the testing setup phase, so that when tests are run with the original startup command, coverage tracking is already enabled without requiring any modification to the user's test invocation process, thus preserving platform flexibility.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The code coverage system provides self-service by automatically configuring itself through private variable insertion without requiring user intervention or startup command modification. The system autonomously prepares the codebase for coverage measurement, executes tests, and generates reports, allowing users to maintain their original testing workflow while benefiting from automated coverage tracking.

Inventive Principle:
Principle #25Self-service

Data Source

PatentUS20260010462A1Source code processing method and apparatus, and storage medium
Publication Date: 2026.01.08 HUAWEI CLOUD COMPUTING TECHNOLOGIES CO LTD
  • US20260010462A1 patent drawing
  • US20260010462A1 patent drawing
  • US20260010462A1 patent drawing

AI summary

This application discloses a source code processing method and apparatus, and a storage medium, and pertains to the computer field. The method includes: receiving an instruction for starting a code test, and adding a private variable to at least one first method included in first source code, where the at least one first method is a method that is not executed in the first source code, and the private variable is used to record execution of each code statement in the first method when the first method is executed; when a test on the first source code is completed using a first test case, obtaining first code coverage information based on the private variable, where the first code coverage information describes execution of a code statement in the at least one first method.