ML-Based Test Case Generation for Source Code

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Software developers face challenges in ensuring the quality and robustness of source code due to the resource-intensive and time-consuming nature of manual test case design for white-box and black-box testing, especially when translating code from one programming language to another, often resulting in insufficient or inefficient testing.

Innovation Solution

The implementation of machine learning models, such as neural networks, to automatically generate test cases for source code, including the use of code-to-embedding and embedding-to-test models for unit testing and functional testing, enabling the generation of robust and accurate test cases without human intervention.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If manual test case design is used for white-box and black-box testing, then testing coverage can be achieved, but resource usage and time consumption increase significantly

Engineering Contradiction:
Improvetesting coverageVSAvoidtime consumption
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The system enables self-service testing by automatically generating test cases through machine learning models. The ML model analyzes source code and autonomously creates both white-box and black-box test cases without requiring manual developer intervention, thus maintaining comprehensive testing coverage while dramatically reducing time consumption.

Inventive Principle:
Principle #25Self-service

Solution Approach 2:

The patent replaces the mechanical manual process of test case design with an automated machine learning-based system. The ML model processes source code and generates test cases algorithmically, substituting the manual mechanical effort of developers with an automated intelligent system that operates faster and more efficiently.

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

2Reliability

If manual test case design is used, then testing can be performed, but extensive client device resources are required

Engineering Contradiction:
Improvetesting qualityVSAvoidclient device resources
Core Design Contradiction:
ReliabilityVSUse of energy by moving object

Solution Approach 1:

The system performs self-service by automatically generating test cases through ML models, eliminating the need for developers to manually create tests. This automation maintains high testing quality while optimizing resource utilization, as the ML model efficiently processes code and generates tests without requiring extensive continuous human device resource engagement.

Inventive Principle:
Principle #25Self-service

Solution Approach 2:

The system performs preliminary action by generating test cases automatically before execution. The ML model pre-processes source code and creates comprehensive test cases in advance, reducing the need for extensive real-time resource consumption during the actual testing phase while maintaining high testing quality.

Inventive Principle:
Principle #10Preliminary action

3Productivity

If developers manually generate test cases, then testing can be performed, but insufficient test cases are often developed due to time constraints

Engineering Contradiction:
Improvetest case generation speedVSAvoidtest case sufficiency
Core Design Contradiction:
ProductivityVSReliability

Solution Approach 1:

The system enables self-service test case generation through ML models that automatically analyze source code and generate comprehensive test cases without human intervention. This automation dramatically increases productivity by generating test cases rapidly while ensuring sufficiency through the model's ability to analyze code structure and identify all necessary test scenarios.

Inventive Principle:
Principle #25Self-service

Solution Approach 2:

The system applies parameter changes by adjusting the complexity and scope of test case generation based on code analysis. The ML model dynamically determines the appropriate number and type of test cases needed, optimizing both generation speed and sufficiency by adapting test case parameters to the specific characteristics of the source code being tested.

Inventive Principle:
Principle #35Parameter changes

4Reliability

If brute-force approaches are used for black-box testing, then all inputs can be explored, but computational cost and time increase significantly

Engineering Contradiction:
Improveinput exploration coverageVSAvoidcomputational power
Core Design Contradiction:
ReliabilityVSPower

Solution Approach 1:

The patent replaces the computationally intensive brute-force mechanical approach with an intelligent ML-based system. The ML model analyzes code structure and semantics to intelligently generate test inputs that are likely to reveal errors, substituting exhaustive computational power with targeted intelligent computation that achieves equivalent or better coverage with significantly reduced computational resources.

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

Solution Approach 2:

The system applies parameter changes by optimizing test input selection based on code analysis. Instead of uniformly exploring all possible inputs with equal computational power, the ML model adjusts input parameters intelligently, focusing computational resources on high-value test cases that are most likely to detect errors while maintaining comprehensive input exploration coverage.

Inventive Principle:
Principle #35Parameter changes

Data Source

PatentUS11899566B1Training and/or using machine learning model(s) for automatic generation of test case(s) for source code
Publication Date: 2024.02.13 GOOGLE LLC
  • US11899566B1 patent drawing
  • US11899566B1 patent drawing
  • US11899566B1 patent drawing

AI summary

Training and/or utilization of machine learning model(s) (e.g., neural network model(s)) in automatically generating test case(s) for source code. Techniques disclosed herein can be utilized in generating test case(s) for unit test testing (or other white-box testing) and/or for functional testing (or other black-box testing). In some implementations, the machine learning model(s) can be trained on source code, unit test pairs. In some additional or alternative implementations, reinforcement learning techniques can be utilized to check for correctness of base source code, target source code pairs (e.g., by matching program execution of different branches).