Transformer-Based Code Coverage Prediction Without Execution
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing code coverage measurement methods require significant computing resources and time to instrument, build, and execute the program, making them impractical for large software projects, especially when only a portion of the source code is available.
Innovation Solution
A neural transformer model with attention is used to predict code coverage without executing the software, generating a sequence of code coverage symbols for source code snippets based on a focal method and a test case, indicating which lines are covered, missed, or unreachable.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Measurement precision
If code coverage is measured by instrumenting and executing the program, then accurate code coverage data is obtained, but significant computing resources and time are consumed
Solution Approach 1:
The patent creates a static copy or representation of the code coverage information without executing the actual program. The neural transformer model generates predicted code coverage symbols that replicate the function of actual execution-based coverage measurement, eliminating the need to instrument and run the program while providing comparable coverage data.
Solution Approach 2:
The patent replaces the mechanical execution-based code coverage measurement system with an AI-based prediction system. Instead of using traditional instrumentation and program execution mechanisms, the system employs a neural transformer model that processes code and test case inputs to predict coverage outcomes, substituting computational execution with intelligent prediction.
2Loss of information
If the entire program is instrumented and executed for code coverage, then complete coverage information is obtained, but the process is too expensive for large software projects
Solution Approach 1:
The patent extracts and analyzes only the necessary portions of code relevant to the test case rather than processing the entire program. The neural transformer model focuses on extracting coverage information from specific code segments and test cases, eliminating the need to instrument and execute the whole program while still obtaining meaningful coverage data.
Solution Approach 2:
The patent performs partial code coverage analysis by predicting coverage for only the relevant code paths exercised by the test case rather than attempting to measure coverage for the entire program. This partial action approach provides sufficient coverage information without the excessive computational cost of full program execution.
3Reliability
If code coverage is measured through program execution, then actual execution paths are tracked, but it is not possible when only a portion of source code is available
Solution Approach 1:
The patent introduces an AI model as an intermediary that can work with incomplete code information. The neural transformer model serves as a mediator between the available code snippets and the coverage measurement goal, enabling coverage prediction even when the full program context is not available, thus maintaining reliability with partial information.
Data Source
AI summary
A code coverage prediction system utilizes a neural transformer model with attention to generate a sequence of coverage symbols given a focal method and a test case. The sequence of coverage symbols indicates whether a line of source code is covered by the test case, missed by the test case or unreachable. The sequence of coverage symbols is aligned with the focal method to produce a coverage-annotated focal method that associates a predicted coverage symbol with each line of source code in the focal method.


