US 11,921,621 B2
System and method for improved unit test creation
Maciej Głowa, Cracow (PL); Nathan Michael Jakubiak, Pasadena, CA (US); Michał Rozenau, Slupsk (PL); Marcin Strojny, Cracow (PL); Piotr Grzesik, Cracow (PL); and Michał Kusmierczyk, Cracow (PL)
Assigned to PARASOFT CORPORATION, Monrovia, CA (US)
Filed by PARASOFT CORPORATION, Monrovia, CA (US)
Filed on Aug. 27, 2021, as Appl. No. 17/459,240.
Claims priority of provisional application 63/076,283, filed on Sep. 9, 2020.
Prior Publication US 2022/0075710 A1, Mar. 10, 2022
Int. Cl. G06F 11/36 (2006.01)
CPC G06F 11/3684 (2013.01) [G06F 11/3688 (2013.01)] 18 Claims
OG exemplary drawing
 
1. A method, executed by one or more processors, for creating unit tests for testing a computer program, the method comprising:
receiving, over a computer network, an electronic request that specifies a portion in the computer program to be covered by the unit test;
constructing a Control Flow Graph (CFG) representation for the portion in the computer program, wherein the CFG includes at least an assignment node for assigning a method call executed by a flow analysis software to a given variable and information about the given variable that is being assigned with a value, and a return value node representing an exit point from a method called by the flow analysis software;
parsing the CFG by the flow analysis software to build a plurality of different potential execution paths that may lead to the portion in the computer program and to identify a unique formula for each of the potential execution paths wherein each formula includes a list of pre-conditions and associated variables that represent a simulated execution path;
parsing a source code of the portion in the computer program, by the one or more processors, to generate an abstract syntax tree as representation of a content of the portion in the computer program, by mapping a source code of the portion to a tree according to syntax rules of a programming language;
analyzing the portion in the computer program to determine whether it provides capability to set each of the associated variables in each formula, utilizing the abstract syntax tree;
translating variables, fields, and expressions of the source code represented in the each formula into a plurality of decision variables, using pre-determined categories of constraints;
computing a solution to the list of pre-conditions from the each formula to one of the potential solutions that specifies values for decision variables;
selecting a formula, from the plurality of formulas, with fewest number of associated variables, which has a solution that specifies values for decision variables for given pre-conditions;
creating a unit test, based on the solution and the list of pre-conditions collected and solved; and
executing the unit test to test the computer program.