Code Coverage Rate Determination Using Log File Output Points

Resolve Bottlenecks,
Find Innovative Solutions
Generate 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

VSEngineering 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

Engineering Contradiction:
Improvecode coverage rate measurementVSAvoidtesting efficiency
Core Design Contradiction:
Measurement precisionVSProductivity

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.

Inventive Principle:
Principle #10Preliminary action

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.

Inventive Principle:
Principle #26Copying

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

Engineering Contradiction:
Improvecode coverage rateVSAvoidapplicability during execution
Core Design Contradiction:
Measurement precisionVSAdaptability or versatility

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.

Inventive Principle:
Principle #24Intermediary (Mediator)

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.

Inventive Principle:
Principle #28Mechanics substitution (Replace mechanical system)

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

Engineering Contradiction:
Improvecode coverage rate calculationVSAvoidprocessing time
Core Design Contradiction:
Measurement precisionVSLoss of time

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.

Inventive Principle:
Principle #10Preliminary action

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.

Inventive Principle:
Principle #16Partial or excessive action

Data Source

PatentEP2815319B1Code coverage rate determination method and system
Publication Date: 2024.05.15 ALIBABA GROUP HOLDING LTD
  • EP2815319B1 patent drawingFigure 1
  • EP2815319B1 patent drawingFigure 2A
  • EP2815319B1 patent drawingFigure 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.