Automated Unit Test Generation via Symbolic Execution and Dependency Mocking

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing tools for automated unit test case generation fail to handle external dependencies such as calls to external libraries and web services, requiring human intervention and resulting in poor code coverage.

Innovation Solution

A system and method that uses symbolic execution and constraint solving techniques to identify and generate hints for external dependencies, allowing for automated unit test case generation without human intervention, by analyzing potential executable paths and updating hints with accurate implementations and ideal return values.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Extent of automation

If existing tools use symbolic execution and constraint solving for automated unit test generation, then test case automation is improved, but the tools fail to handle external dependencies requiring human intervention

Engineering Contradiction:
Improveautomated unit test generationVSAvoidhandling external dependencies
Core Design Contradiction:
Extent of automationVSEase of operation

Solution Approach 1:

The patent introduces an intermediary mechanism that intercepts and mocks external dependency calls within the symbolic execution engine. This mediator layer allows the system to handle external dependencies automatically by providing simulated responses, eliminating the need for human intervention while maintaining test automation.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The system performs preliminary actions by pre-configuring mock objects and expectations before test execution. By setting up the simulation environment in advance, the symbolic execution engine can automatically handle external dependencies during test generation without requiring manual intervention at runtime.

Inventive Principle:
Principle #10Preliminary action

2Manufacturing precision

If existing tools require spying and faking arrangements for external dependencies, then test cases can be generated, but code coverage metrics are poor

Engineering Contradiction:
Improvecode coverage metricsVSAvoidspying and faking arrangement
Core Design Contradiction:
Manufacturing precisionVSDevice complexity

Solution Approach 1:

The patent merges the dependency handling mechanism directly into the symbolic execution engine, combining code analysis, mock generation, and test case creation into a unified system. This integration eliminates the need for separate spying and faking arrangements, improving code coverage while reducing overall system complexity.

Inventive Principle:
Principle #5Merging (Combining)

Solution Approach 2:

The system provides self-service by automatically generating appropriate mock objects and configuring them based on the analyzed code structure. The symbolic execution engine itself performs the tasks previously requiring external spying and faking tools, improving code coverage without adding complexity.

Inventive Principle:
Principle #25Self-service

3Extent of automation

If existing tools are unable to access source code for external dependencies, then symbolic execution is simplified, but human intervention is required

Engineering Contradiction:
Improveaccess to external dependency source codeVSAvoidhuman intervention time
Core Design Contradiction:
Extent of automationVSLoss of time

Solution Approach 1:

The patent creates simplified copies or models of external dependency interfaces through automatic mock generation. Instead of requiring access to actual external source code, the system generates representative mock implementations that capture the essential behavior, enabling full automation without human intervention or access to external codebases.

Inventive Principle:
Principle #26Copying

Data Source

PatentUS10949334B2System and a method for automated unit test generation
Publication Date: 2021.03.16 COGNIZANT TECH SOLUTIONS INDIA PVT LTD
  • US10949334B2 patent drawing
  • US10949334B2 patent drawing
  • US10949334B2 patent drawing

AI summary

A system and a method for automating unit test case including generating a codebase extract by analysing an application source code, identifying one or more potential executable paths within a selected class or method based on an analysis of the codebase extract, executing one or more statements associated with each of the one or more potential paths using a symbolic execution technique and identifying one or more calls to external dependencies associated with the respective paths, and subsequently, a hint for spying and mocking respective external dependencies is generated, as a by-product of symbolic execution on identification of the external dependencies, whereby each hint is updated with respective ideal return value, and a unit test case for testing a selected class or method is generated by processing the hints with test data and an exclusion list.