Code Coverage Rate Determination Using Log File Output Points
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing code coverage rate determination methods are inefficient for large source code volumes and can only be implemented during the testing stage, as they require significant processing and cannot be applied during actual program execution.
Innovation Solution
A system and method that utilize log file output points to determine code coverage rate by retrieving and analyzing log files from source code, both theoretically and actually, to calculate the coverage rate without adding tags to the source code, allowing for continuous coverage assessment during program execution.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Measurement precision
If tags are added to source code in advance to determine code coverage rate, then code coverage can be measured, but processing overhead increases and testing time is affected when source code volume is large
Solution Approach 1:
The patent pre-calculates and stores theoretical log file output points and their corresponding source code locations during the code analysis phase. This preliminary action enables the system to quickly determine code coverage by simply checking whether log files were actually output during execution, without needing to add tags to the source code or perform complex runtime instrumentation.
Solution Approach 2:
The patent creates a theoretical model of log file output points by analyzing source code structure and storing this information separately. This copy of the code structure information allows the system to measure code coverage by comparing actual log output against the pre-established theoretical model, avoiding direct modification of the original source code.
2Measurement precision
If tags are added to source code to track execution, then code coverage rate can be determined, but the method cannot be implemented during actual program execution
Solution Approach 1:
The patent introduces log files as an intermediary mechanism between source code execution and coverage measurement. Instead of directly tagging source code, the system uses log file output as a mediator to record which code paths were executed. The theoretical log file output points serve as a reference model, and comparing actual log output against this model enables coverage determination during actual program execution.
Solution Approach 2:
The patent replaces the mechanical approach of adding tags directly to source code with a logging-based system. Instead of modifying the code structure itself, the system substitutes a logging mechanism that records execution traces in log files, which can then be analyzed to determine code coverage without affecting the original code or requiring code modification.
3Measurement precision
If source code is processed to add test information output settings, then code coverage rate can be calculated, but processing time increases significantly
Solution Approach 1:
The patent performs source code analysis and identifies all potential log file output points before execution. This preliminary analysis stores the theoretical locations where logs should be output based on source code structure. During actual execution, the system only needs to check whether logs were output at these pre-identified points, dramatically reducing processing time compared to analyzing or tagging the code during execution.
Solution Approach 2:
The patent analyzes the entire source code structure in advance to identify all potential log output points, even those that may not be reached during a particular execution. This excessive analysis ensures that the theoretical model covers all possible code paths, allowing the system to quickly determine coverage by simply checking which of these pre-identified points actually produced logs during execution.
Data Source
Figure 1
Figure 2A
Figure 2B
AI summary
Embodiments of the present application relate to a code coverage rate determination method, a code coverage rate determination system, and a computer program product for determining code coverage rate. A code coverage rate determination method is provided. The method includes retrieving source code of a program, determining theoretical number of log file output points included in the source code and location information of the log file output points, retrieving log files actually outputted during the execution of the program, determining an actual number of log file output points of the actual outputted log files based on the location information of the corresponding log file output points recorded in each log file, and determining a code coverage rate of the program based on the theoretical number of log file output points and the actual number of the log file output points of the actual outputted log files.