Conditional Branch Coverage Calculation Excluding Unnecessary Code

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Current code coverage testing methods provide inaccurate and unreliable results due to the inability to accurately calculate conditional branch coverage, especially in sophisticated projects where some conditional branches are unnecessary or impossible to cover.

Innovation Solution

A method and device for calculating conditional branch coverage by acquiring code types and comment information of uncovered conditional branch code lines, determining coverage parameters based on this information, and calculating coverage by adding these parameters to the total number of conditional branch code lines, thereby excluding unnecessary branches from the calculation.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If traditional code coverage testing is performed including all conditional branches, then the testing process is comprehensive, but the coverage results become inaccurate and unreliable due to unnecessary or impossible-to-cover branches

Engineering Contradiction:
Improvecoverage calculation accuracyVSAvoidcoverage report reliability
Core Design Contradiction:
Measurement precisionVSReliability

Solution Approach 1:

The patent extracts and excludes unnecessary conditional branches from the coverage calculation. By identifying branches that are impossible to cover or unnecessary for testing purposes, the system removes them from the denominator in coverage calculations, thereby improving both accuracy and reliability of coverage reports

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The patent applies different treatment to different conditional branches based on their specific characteristics. Some branches are marked as unnecessary or impossible to cover, and these receive special handling in the coverage calculation, allowing localized adjustments to improve overall measurement quality

Inventive Principle:
Principle #3Local quality

2Manufacturing precision

If all conditional branches are required to be covered, then the testing standard is strict and thorough, but the testing requirements cannot be met for sophisticated projects with unnecessary or impossible branches

Engineering Contradiction:
Improvetesting standard strictnessVSAvoidtesting requirement adaptability
Core Design Contradiction:
Manufacturing precisionVSAdaptability or versatility

Solution Approach 1:

The patent introduces dynamic adaptability to testing standards by allowing the coverage requirements to adjust based on the specific characteristics of the codebase. Necessary branches maintain strict coverage requirements, while unnecessary or impossible branches are dynamically excluded, making the testing standard adaptable to different project scenarios

Inventive Principle:
Principle #15Dynamics

Solution Approach 2:

The patent changes the parameters of coverage calculation by introducing weights and exclusion flags for different conditional branches. This allows the testing standard to be flexible - maintaining high precision for important branches while adapting to exclude problematic branches, thus balancing strictness and adaptability

Inventive Principle:
Principle #35Parameter changes

Data Source

PatentUS12093168B2Conditional branch coverage calculation method, device, computer apparatus, storage medium
Publication Date: 2024.09.17 GLENFLY TECH CO LTD
  • US12093168B2 patent drawing
  • US12093168B2 patent drawing

AI summary

The present disclosure relates to a conditional branch coverage calculation method and device, computer apparatus, storage medium and computer program product. The method includes: acquiring code types of uncovered conditional branch code lines in target code, and acquiring comment information corresponding to the uncovered conditional branch code lines according to the code type; acquiring coverage parameter corresponding to the uncovered conditional branch code lines according to the comment information corresponding to the uncovered conditional branch code lines; and calculating a conditional branch coverage corresponding to the target code according to the coverage parameters corresponding to the uncovered conditional branch code lines and a total number of conditional branch code lines in the target code.