Sign In to Follow Application
View All Documents & Correspondence

A System And A Method For Automated Unit Test Generation

Abstract: ABSTRACT A SYSTEM AND A METHOD FOR AUTOMATED UNIT TEST GENERATION A system and a method for automating unit test case generation is disclosed. The present invention provides generating a codebase extract by analysing an application source code. Further, one or more potential executable paths within a selected class or method are identified based on an analysis of the codebase extract. Furthermore, one or more statements associated with each of the one or more potential paths are executed using a symbolic execution technique and one or more calls to external dependencies associated with the respective paths are identified. 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. Yet further, each hint is updated with respective ideal return value. Finally, a unit test case for testing a selected class or method is generated by processing the hints with test data and an exclusion list.

Get Free WhatsApp Updates!
Notices, Deadlines & Correspondence

Patent Information

Application #
Filing Date
26 November 2018
Publication Number
22/2020
Publication Type
INA
Invention Field
COMPUTER SCIENCE
Status
Email
dev.robinson@amsshardul.com
Parent Application
Patent Number
Legal Status
Grant Date
2024-03-19
Renewal Date

Applicants

Cognizant Technology Solutions India Pvt. Ltd.
Techno Complex, No. 5/535 Old Mahabalipuram Road Okkiyam Thoraipakkam Chennai 600 097, Tamil Nadu India.

Inventors

1. Sakthivel Sabanayagam
FNO 10105, Indu Fortune Fields Gardenia, Phase 13 KPHB Colony, Hyderabad, Telangana 500072 India.
2. Saroj Pradhan
251A/27, NSC Bose Road, Kolkata, West Bengal 700047, India.
3. Srujana Korukoppula
FNO 203, Vindhya Lake Front, Plot No 406 & 407, Lakeview Colony, Pragati Nagar, Hyderabad, Telangana – 500090, India.
4. Vimal Kumar A
207-1, Bavadi Street, Bramadesam, Anthiyur Erode, Tamil Nadu – 638315, India.

Specification

We claim:
1. A computer implemented method for automating unit test case generation for one or more methods associated with an application source code, wherein the method is implemented by a processor executing program instructions stored in a memory, the method comprising:
identifying, by the processor, one or more potential executable paths associated with a selected method by analysing a code base extract using a path solving technique;
identifying, by the processor, one or more calls to external dependencies associated with each of the one or more potential executable paths using a symbolic execution technique;
generating, by the processor, one or more hints for the identified one or more calls to external dependencies, wherein each hint is representative of call information associated with the external dependencies;
updating, by the processor, the one or more hints with accurate implementations of an object type in each of the one or more hints, wherein the accurate implementation of each object type is identified based on determination of a predefined category associated with the object type;
updating, by the processor, each of the one or more hints with respective ideal return value, wherein the ideal return value of each of the one or more calls to external dependencies is determined based on an aggregated conditional expression associated with respective paths using one or more constraint solving techniques; and
generating, by the processor, a unit test code for the selected method by processing the one or more hints with a test data and an exclusion list.

2. The method as claimed in claim 1, wherein the codebase extract is generated by analysing and parsing the application source code, further wherein the codebase extract includes a class dependency graph and one or more abstract syntax graphs associated with the application source code.
3. The method as claimed in claim 1, wherein the code base extract is analysed for identifying one or more potential executable paths on receiving a request for generation of unit test for the selected method.
4. The method as claimed in claim 1, wherein identifying one or more calls to external dependencies comprises executing one or more statements associated with each of the one or more potential paths using a symbolic execution technique; creating and updating a symbol table while interpreting each statement associated with the respective one or more paths; and identifying a statement interpreted as method invocation as a call to external dependency.
5. The method as claimed in claim 4, wherein the hint is generated as a by-product of execution of the statement interpreted as external dependency.
6. The method as claimed in claim 1, wherein the one or more calls to external dependencies include calls to other methods in the application source code, calls to external libraries, database queries and calls to web service.
7. The method as claimed in claim 4, wherein the symbol table is a customized data structure configured to store semantic information associated with an expression, variables present in the expression, and the one or more methods associated with application source code.
8. The method as claimed in claim 7, wherein the semantic information includes scope, variable name,

variable data type, associated symbol, value, format of the value, constraints, variable type, object type information, resolved data type of the variable, type cast information associated with the object, expression information.
9. The method as claimed in claim 1, wherein one or more conditional expressions associated with each of the one or more potential executable paths are collected and aggregated.
10. The method as claimed in claim 1, wherein the call information associated with the external dependency includes object type, method being called, return type, arguments with values and associated symbols.
11. The method as claimed in claim 1, wherein a format of the one or more hints is selected from xml and JSON.
12. The method as claimed in claim 1, wherein the predefined categories associated with the object type include an interface, an abstract class and a base class.
13. The method as claimed in claim in 12, wherein the accurate implementation for the object type is identified using type cast information associated with the object from the symbol table if the object type is associated with the base class.
14. The method as claimed in claim in 12, wherein the accurate implementation for the object type is identified using a predefined-list of possible implementations along with a reflection technique, if the object type is associated with an interface or an abstract class.
15. The method as claimed in claim 1, wherein each ideal return value is representative of a value which is to be returned by respective external call such that downstream execution of respective path is feasible.

16. The method as claimed in claim 1, wherein the exclusion list comprises a pre-generated list of object types which are not to be mocked.
17. The method as claimed in claim 1, wherein processing of the one or more hints with the exclusion list comprises determining if the object type associated with one or more hints is associated with the exclusion list.
18. A system for automating unit test case generation for one or more methods associated with an application source code, wherein the system interfaces with an application subsystem comprising the application source code, the system comprising:
a memory storing program instructions; a processor configured to execute program instructions stored in the memory; and a unit test generation engine in communication with the processor configured to:
identify one or more potential executable paths associated with a selected method by analysing a code base extract using a path solving technique;
identify one or more calls to external dependencies associated with each of the one or more potential executable paths using a symbolic execution technique;
generate one or more hints for the identified one or
more calls to external dependencies, wherein each hint is
representative of call information associated with the
external dependencies;
update one or more hints with respective accurate implementations of an object type in each of the one or more hints, wherein the accurate implementation of each object type is identified based on determination of a predefined category associated with the object type;

update each of the one or more hints with respective ideal return value, wherein the ideal return value of each of the one or more calls to external dependencies is determined based on an aggregated conditional expression associated with respective paths using one or more constraint solving techniques; and
generate a unit test code for the selected method by processing the one or more hints with a test data and an exclusion list.
19. The system as claimed in claim 18, wherein the unit test generation engine comprises a code extraction unit in communication with the processor, the code extraction unit configured to generate a codebase extract by analysing the application source code using static analysis and parsing the analysed application source code, further wherein the codebase extract includes a class dependency graph and one or more abstract syntax graphs associated with the application source code.
20. The system as claimed in claim 18, wherein the unit test generation engine comprises a computation engine in communication with the processor, the computation engine comprises a path solving unit configured to: analyse the codebase extract on receiving a request for generation of unit test for the selected method; identify one or more potential executable paths within the selected method using a path solving technique; and filter invalid or infeasible paths before transmitting for further processing.
21. The system as claimed in claim 20, wherein the computation engine comprises a hint generation unit configured to: execute one or more statements associated with each of the one or more potential paths using a symbolic execution technique; create and update a symbol table while interpreting each statement associated with respective one or more paths; and identify a statement

interpreted as method invocation as a call to external dependency.
22. The system as claimed in claim 21, wherein the hint generation unit is configured to collect one or more conditional expressions associated with each of the one or more paths; and aggregate the one or more conditional expressions associated with each path respectively.
23. The system as claimed in claim 21, wherein the hint is generated as a by-product of execution of the statement interpreted as external dependency.
24. The system as claimed in claim 18, wherein the one or more calls to external dependencies include calls to other methods associated with the application source code, calls to external libraries, database queries and calls to web service.
25. The system as claimed in claim 21, wherein the symbol table is a customized data structure configured to store semantic information associated with an expression, variables present in the expression, and the one or more methods associated with application source code.
26. The system as claimed in claim 25, wherein the semantic information includes scope, variable name, variable data type, associated symbol, value, format of the value, constraints, variable type including literal, number, null or list, object type information, resolved data type of the variable, type cast information associated with the object, expression information.
27. The system as claimed in claim 18, wherein the call information associated with the external dependency includes object type, method being called, return type, arguments with values and associated symbols.
28. The system as claimed in claim 18, wherein a format of the one or more hints is selected from xml and JSON.

29. The system as claimed in claim 18, wherein the predefined categories associated with the object type include an interface, an abstract class and a base class.
30. The system as claimed in claim 29, wherein the accurate implementation for the object type is identified using type cast information associated with the object from the symbol table if the object type is associated with the base class.
31. The system as claimed in claim 29, wherein the accurate implementation for the object type is identified using a predefined-list of possible implementations along with a reflection technique, if the object type is associated with an interface or an abstract class.
32. The system as claimed in claim 18, wherein each ideal return value is representative of a value which is to be returned by respective external call such that downstream execution of the respective path is feasible.
33. The system as claimed in claim 18, wherein the exclusion list comprises a pre-generated list of object types which are not to be mocked.
34. The system as claimed in claim 18, wherein the unit test generation engine comprises a code generation unit in communication with the processor, the code generation unit configured to: determine if the object type associated with respective hints are included in the exclusion list; create appropriate mock statement, if the object type is not found in the exclusion list; and generate the unit test case for the selected method by processing the one or more hints with test data and the exclusion list.
35. A computer program product comprising:
a non-transitory computer-readable medium having computer-readable program code stored thereon, the

computer-readable program code comprising instructions that, when executed by a processor, cause the processor to:
identify one or more potential executable paths associated with a selected method by analysing a code base extract using a path solving technique;
identify one or more calls to external dependencies associated with each of the one or more potential executable paths using a symbolic execution technique;
generate one or more hints for the identified one or
more calls to external dependencies, wherein each hint is
representative of call information associated with the
external dependencies;
update one or more hints with accurate implementations of an object type in each of the one or more hints, wherein the accurate implementation of each object type is identified based on determination of a predefined category associated with the object type;
update each of the one or more hints with respective ideal return value, wherein the ideal return value of each of the one or more calls to external dependencies is determined based on an aggregated conditional expression associated with respective paths using one or more constraint solving techniques; and
generate a unit test code for the selected method by processing the one or more hints with a test data and an exclusion list.

Documents

Application Documents

# Name Date
1 201841044428-IntimationOfGrant19-03-2024.pdf 2024-03-19
1 201841044428-STATEMENT OF UNDERTAKING (FORM 3) [26-11-2018(online)].pdf 2018-11-26
2 201841044428-PROOF OF RIGHT [26-11-2018(online)].pdf 2018-11-26
2 201841044428-PatentCertificate19-03-2024.pdf 2024-03-19
3 201841044428-Written submissions and relevant documents [19-03-2024(online)].pdf 2024-03-19
3 201841044428-POWER OF AUTHORITY [26-11-2018(online)].pdf 2018-11-26
4 201841044428-Written submissions and relevant documents [18-03-2024(online)].pdf 2024-03-18
4 201841044428-FORM 1 [26-11-2018(online)].pdf 2018-11-26
5 201841044428-DRAWINGS [26-11-2018(online)].pdf 2018-11-26
5 201841044428-Correspondence to notify the Controller [15-02-2024(online)].pdf 2024-02-15
6 201841044428-FORM-26 [15-02-2024(online)].pdf 2024-02-15
6 201841044428-COMPLETE SPECIFICATION [26-11-2018(online)].pdf 2018-11-26
7 201841044428-US(14)-HearingNotice-(HearingDate-06-03-2024).pdf 2024-02-12
7 201841044428-REQUEST FOR CERTIFIED COPY [29-11-2018(online)].pdf 2018-11-29
8 201841044428-FORM 18 [29-11-2018(online)].pdf 2018-11-29
8 201841044428-FER.pdf 2021-10-17
9 Correspondence by Agent_Form1_PA_03-12-2018.pdf 2018-12-03
9 201841044428-CLAIMS [29-07-2021(online)].pdf 2021-07-29
10 201841044428-COMPLETE SPECIFICATION [29-07-2021(online)].pdf 2021-07-29
10 201841044428-FORM 3 [04-03-2019(online)].pdf 2019-03-04
11 201841044428-FER_SER_REPLY [29-07-2021(online)].pdf 2021-07-29
11 201841044428-Information under section 8(2) [29-07-2021(online)].pdf 2021-07-29
12 201841044428-FORM 3 [29-07-2021(online)].pdf 2021-07-29
13 201841044428-FER_SER_REPLY [29-07-2021(online)].pdf 2021-07-29
13 201841044428-Information under section 8(2) [29-07-2021(online)].pdf 2021-07-29
14 201841044428-COMPLETE SPECIFICATION [29-07-2021(online)].pdf 2021-07-29
14 201841044428-FORM 3 [04-03-2019(online)].pdf 2019-03-04
15 201841044428-CLAIMS [29-07-2021(online)].pdf 2021-07-29
15 Correspondence by Agent_Form1_PA_03-12-2018.pdf 2018-12-03
16 201841044428-FER.pdf 2021-10-17
16 201841044428-FORM 18 [29-11-2018(online)].pdf 2018-11-29
17 201841044428-REQUEST FOR CERTIFIED COPY [29-11-2018(online)].pdf 2018-11-29
17 201841044428-US(14)-HearingNotice-(HearingDate-06-03-2024).pdf 2024-02-12
18 201841044428-COMPLETE SPECIFICATION [26-11-2018(online)].pdf 2018-11-26
18 201841044428-FORM-26 [15-02-2024(online)].pdf 2024-02-15
19 201841044428-Correspondence to notify the Controller [15-02-2024(online)].pdf 2024-02-15
19 201841044428-DRAWINGS [26-11-2018(online)].pdf 2018-11-26
20 201841044428-Written submissions and relevant documents [18-03-2024(online)].pdf 2024-03-18
20 201841044428-FORM 1 [26-11-2018(online)].pdf 2018-11-26
21 201841044428-Written submissions and relevant documents [19-03-2024(online)].pdf 2024-03-19
21 201841044428-POWER OF AUTHORITY [26-11-2018(online)].pdf 2018-11-26
22 201841044428-PROOF OF RIGHT [26-11-2018(online)].pdf 2018-11-26
22 201841044428-PatentCertificate19-03-2024.pdf 2024-03-19
23 201841044428-STATEMENT OF UNDERTAKING (FORM 3) [26-11-2018(online)].pdf 2018-11-26
23 201841044428-IntimationOfGrant19-03-2024.pdf 2024-03-19

Search Strategy

1 SearchstrategyE_07-01-2021.pdf

ERegister / Renewals

3rd: 23 Apr 2024

From 26/11/2020 - To 26/11/2021

4th: 23 Apr 2024

From 26/11/2021 - To 26/11/2022

5th: 23 Apr 2024

From 26/11/2022 - To 26/11/2023

6th: 23 Apr 2024

From 26/11/2023 - To 26/11/2024

7th: 23 Apr 2024

From 26/11/2024 - To 26/11/2025

8th: 23 Apr 2024

From 26/11/2025 - To 26/11/2026

9th: 23 Apr 2024

From 26/11/2026 - To 26/11/2027

10th: 23 Apr 2024

From 26/11/2027 - To 26/11/2028

11th: 23 Apr 2024

From 26/11/2028 - To 26/11/2029

12th: 23 Apr 2024

From 26/11/2029 - To 26/11/2030

13th: 23 Apr 2024

From 26/11/2030 - To 26/11/2031

14th: 23 Apr 2024

From 26/11/2031 - To 26/11/2032

15th: 23 Apr 2024

From 26/11/2032 - To 26/11/2033