CN115718701A - Program testing method, program testing device, computer equipment and storage medium - Google Patents
Program testing method, program testing device, computer equipment and storage medium Download PDFInfo
- Publication number
- CN115718701A CN115718701A CN202211474573.9A CN202211474573A CN115718701A CN 115718701 A CN115718701 A CN 115718701A CN 202211474573 A CN202211474573 A CN 202211474573A CN 115718701 A CN115718701 A CN 115718701A
- Authority
- CN
- China
- Prior art keywords
- program
- code
- tested
- preset
- comparison result
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Landscapes
- Debugging And Monitoring (AREA)
Abstract
The application relates to a program testing method, a program testing device, computer equipment, a storage medium and a computer program product, and relates to the technical field of artificial intelligence. Can be used in the field of financial science and technology or other related fields. The method comprises the following steps: acquiring a program to be tested and an original program before replacing a program language type corresponding to the program to be tested; according to a preset code comparison rule, comparing a first logic code in a program to be tested with a second logic code in an original program to obtain a logic code comparison result; comparing the semantic relation between a first semantic relation code in the program to be tested and a second semantic relation code in the original program according to a preset semantic comparison rule under the condition that the comparison result of the logic codes meets a preset first matching condition to obtain a semantic relation comparison result; and determining a program test result of the program to be tested according to the semantic relation comparison result and a preset program test rule. By adopting the method, the program testing efficiency can be improved.
Description
Technical Field
The present application relates to the field of artificial intelligence technologies, and in particular, to a program testing method, an apparatus, a computer device, a storage medium, and a computer program product.
Background
The software system may face the transformation of replacing the kind of the program development language with the change of the influencing factors such as the technology. For example, the programming language in the oracle storage process is replaced by java. Through the type replacement process of the programming language, the new program can still realize the functions of the original program. Therefore, in order to ensure that the new program with the replaced program language type can realize the functions of the original program, the new program with the replaced program language type needs to be subjected to program testing.
However, the conventional program testing method requires a tester to write a test code corresponding to each program to be tested. Moreover, from the perspective of software testing, the range of programs generally involved in replacing the types of program languages is wide, all logic branches of the whole program need to be covered by testing, and development of testing work is a great challenge. Therefore, the existing program testing method has the disadvantages of large workload, long time consumption and low efficiency.
Disclosure of Invention
In view of the foregoing, it is necessary to provide a program testing method, apparatus, computer device, computer readable storage medium and computer program product capable of improving efficiency.
In a first aspect, the present application provides a program testing method. The method comprises the following steps:
acquiring a program to be tested and an original program before replacing a program language type corresponding to the program to be tested;
according to a preset code comparison rule, comparing a first logic code in the program to be tested with a second logic code in the original program to obtain a logic code comparison result;
comparing the semantic relation between the first semantic relation code in the program to be tested and the second semantic relation code in the original program according to a preset semantic comparison rule under the condition that the comparison result of the logic codes meets a preset first matching condition to obtain a semantic relation comparison result;
and determining a program test result of the program to be tested according to the semantic relation comparison result and a preset program test rule.
In one embodiment, the code comparison of the first logic code in the program to be tested and the second logic code in the original program according to a preset code comparison rule to obtain a logic code comparison result includes:
comparing the first length of the first logic code in the program to be tested with the second length of the second logic code in the original program to obtain a code length comparison result;
determining code similarity of a first logic code and a second logic code according to a first logic code in the program to be tested, a second logic code in the original program and a preset code similarity determination rule;
and forming a logic code comparison result by comparing the code length comparison result with the code similarity.
In one embodiment, the first matching condition comprises a code similarity threshold; the semantic relationship comparison between the first semantic relationship code in the program to be tested and the second semantic relationship code in the original program is performed according to a preset semantic comparison rule under the condition that the comparison result of the logic codes meets a preset first matching condition, and the method further comprises the following steps of:
if the logic code comparison result shows that the first length is the same as the second length and the code similarity is greater than or equal to a preset code similarity threshold value, determining that the logic code comparison result meets a preset first matching condition;
and if the logic code comparison result shows that the first length is different from the second length or the code similarity is smaller than a preset code similarity threshold, determining that the logic code comparison result does not meet a preset first matching condition.
In one embodiment, the determining of the code similarity threshold includes:
determining a first program type of the program to be tested and a second program type of the original program;
determining the standard code similarity of the first program type and the second program type according to a first standard logic code of the program of the first program type, a second standard logic code of the program of the second program type and a preset code similarity determination rule;
and calculating a code similarity threshold according to the standard code similarity and a preset code similarity threshold calculation rule.
In one embodiment, the semantic relationship comparison between the first semantic relationship code in the program to be tested and the second semantic relationship code in the original program according to a preset semantic comparison rule to obtain a semantic relationship comparison result includes:
aiming at each first semantic relation code, determining a second semantic relation code corresponding to the first semantic relation code, and forming a target mapping relation of the first semantic relation code by using the first semantic relation code and the second semantic relation code corresponding to the first semantic relation code;
matching the target mapping relation with a preset standard mapping relation of a first semantic relation code and a second semantic relation code to obtain a matching result of the first semantic relation code;
and generating a semantic relation comparison result according to the matching result of each first semantic relation code.
In one embodiment, the determining the program test result of the program to be tested according to the result of the semantic relationship comparison and a preset program test rule includes:
acquiring the parameter types of the input parameters and the original program under the condition that the semantic relation comparison result meets a preset second matching condition, determining a rule according to the parameter types and a preset input parameter value, and determining the input parameter value of the input parameters;
assigning the entry parameter values to the entry parameters of the program to be tested and the entry parameters of the original program, and calling the program to be tested and the original program to obtain a first execution result of the program to be tested, a first data change result of the program to be tested, a second execution result of the original program and a second data change result of the original program;
performing consistency comparison on the first execution result and the second execution result to obtain a first comparison result, and performing consistency comparison on the first data change result and the second data change result to obtain a second comparison result;
and determining a program test result of the program to be tested according to the first comparison result and the second comparison result.
In one embodiment, the determining the program test result of the program to be tested according to the result of the semantic relationship comparison and a preset program test rule includes:
and under the condition that the semantic relation comparison result does not meet a preset second matching condition, taking a program test identifier which does not pass the representation test as a program test result of the program to be tested.
In one embodiment, the method further comprises:
under the condition that the program test result of the program to be tested shows that the test is failed, determining an object code inconsistent with the second code of the original program and the number of object lines of the object code in the first code of the program to be tested;
and forming program error information of the program to be tested by using the target code and the target line number.
In a second aspect, the present application further provides a program testing apparatus. The device comprises:
the acquisition module is used for acquiring a program to be detected and an original program before the program language type corresponding to the program to be detected is replaced;
the logic code comparison module is used for comparing a first logic code in the program to be tested with a second logic code in the original program according to a preset code comparison rule to obtain a logic code comparison result;
the semantic relation comparison module is used for comparing a first semantic relation code in the program to be tested with a second semantic relation code in the original program according to a preset semantic comparison rule under the condition that the logic code comparison result meets a preset first matching condition to obtain a semantic relation comparison result;
and the first determining module is used for determining a program test result of the program to be tested according to the semantic relation comparison result and a preset program test rule.
In one embodiment, the logic code comparison module is specifically configured to:
comparing the first length of the first logic code in the program to be tested with the second length of the second logic code in the original program to obtain a code length comparison result;
determining code similarity of a first logic code and a second logic code according to a first logic code in the program to be tested, a second logic code in the original program and a preset code similarity determination rule;
and forming a logic code comparison result by using the code length comparison result and the code similarity.
In one embodiment, the first matching condition comprises a code similarity threshold; the device further comprises:
the first judging module is used for determining that the logic code comparison result meets a preset first matching condition if the logic code comparison result shows that the first length is the same as the second length and the code similarity is greater than or equal to a preset code similarity threshold;
and the second judging module is used for determining that the logic code comparison result does not meet a preset first matching condition if the logic code comparison result shows that the first length is different from the second length or the code similarity is smaller than a preset code similarity threshold.
In one embodiment, the apparatus further comprises:
the second determining module is used for determining the first program type of the program to be tested and the second program type of the original program;
a third determining module, configured to determine a standard code similarity between the first program type and the second program type according to a first standard logic code of the program of the first program type, a second standard logic code of the program of the second program type, and a preset code similarity determination rule;
and the calculation module is used for calculating a code similarity threshold according to the standard code similarity and a preset code similarity threshold calculation rule.
In one embodiment, the semantic relationship comparing module is specifically configured to:
aiming at each first semantic relation code, determining a second semantic relation code corresponding to the first semantic relation code, and forming a target mapping relation of the first semantic relation code by using the first semantic relation code and the second semantic relation code corresponding to the first semantic relation code;
matching the target mapping relation with a preset standard mapping relation of a first semantic relation code and a second semantic relation code to obtain a matching result of the first semantic relation code;
and generating a semantic relation comparison result according to the matching result of each first semantic relation code.
In one embodiment, the first determining module is specifically configured to:
acquiring the parameter types of the input parameters and the input parameters of the original program under the condition that the semantic relation comparison result meets a preset second matching condition, and determining a rule according to the parameter types and a preset input parameter value to determine the input parameter value of the input parameters;
assigning the entry value to the entry of the program to be tested and the entry of the original program, and calling the program to be tested and the original program to obtain a first execution result of the program to be tested, a first data change result of the program to be tested, a second execution result of the original program and a second data change result of the original program;
performing consistency comparison on the first execution result and the second execution result to obtain a first comparison result, and performing consistency comparison on the first data change result and the second data change result to obtain a second comparison result;
and determining a program test result of the program to be tested according to the first comparison result and the second comparison result.
In one embodiment, the first determining module is specifically configured to:
and under the condition that the semantic relation comparison result does not meet a preset second matching condition, taking a program test identifier which does not pass the representation test as a program test result of the program to be tested.
In one embodiment, the apparatus further comprises:
a fourth determining module, configured to determine, in the first code of the program to be tested, an object code inconsistent with the second code of the original program and a number of target lines of the object code, if a program test result of the program to be tested indicates that the test fails;
and the forming module is used for forming the program error information of the program to be tested by using the target code and the target line number.
In a third aspect, the present application also provides a computer device. The computer device comprises a memory storing a computer program and a processor implementing the steps of the first aspect when executing the computer program.
In a fourth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the first aspect described above.
In a fifth aspect, the present application further provides a computer program product. The computer program product comprising a computer program which, when executed by a processor, performs the steps of the first aspect described above.
According to the program testing method, the program testing device, the computer equipment, the storage medium and the computer program product, the first logic code in the program to be tested and the second logic code of the original program before the program language type corresponding to the program to be tested is replaced are subjected to code comparison according to the preset code comparison rule, under the condition that the obtained code comparison result meets the preset first matching condition, the first semantic relation code in the program to be tested and the second semantic relation code in the original program are subjected to semantic relation comparison according to the preset semantic relation comparison rule, and the program testing result of the program to be tested is determined according to the obtained semantic relation comparison result and the preset program testing rule. Therefore, the program to be tested after the program language type replacement and the original program before the program language type replacement corresponding to the program to be tested are sequentially subjected to logic code comparison and semantic relation comparison, and whether the static logic of the program to be tested is consistent with that of the original program is judged, so that whether the program to be tested after the program language type replacement can realize the function of the original program is judged.
Drawings
FIG. 1 is a flow diagram illustrating a method for program testing in one embodiment;
FIG. 2 is a flow chart illustrating the logic code comparison step performed in one embodiment;
FIG. 3 is a flow chart illustrating a method for program testing in accordance with another embodiment;
FIG. 4 is a flowchart illustrating the code similarity threshold determination step in one embodiment;
FIG. 5 is a flowchart illustrating the semantic relationship comparison step performed in one embodiment;
FIG. 6 is a flowchart illustrating the step of determining the program test result of the program under test in one embodiment;
FIG. 7 is a flowchart illustrating a program testing method according to another embodiment;
FIG. 8 is a flowchart illustrating a method for program testing in accordance with another embodiment;
FIG. 9 is a block diagram showing the structure of a program test apparatus according to an embodiment;
FIG. 10 is a diagram showing an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
In an embodiment, as shown in fig. 1, a program testing method is provided, and this embodiment is illustrated by applying the method to a terminal, and it is to be understood that the method may also be applied to a server, and may also be applied to a system including the terminal and the server, and is implemented by interaction between the terminal and the server. The terminal can be but not limited to various personal computers, notebook computers, smart phones, tablet computers, internet of things equipment and portable wearable equipment, and the internet of things equipment can be smart sound boxes, smart televisions, smart air conditioners, smart vehicle-mounted equipment and the like. The portable wearable device can be a smart watch, a smart bracelet, a head-mounted device, and the like. The server may be implemented as a stand-alone server or as a server cluster consisting of a plurality of servers. In this embodiment, the method includes the steps of:
step 101, acquiring a program to be tested and an original program before replacing a program language type corresponding to the program to be tested.
In the embodiment of the present application, the program to be tested is a new program after replacing the program language type that needs to be tested. And the terminal determines the original program before the program language type corresponding to the program to be tested is replaced. And then, the terminal acquires the program to be tested and the original program corresponding to the program to be tested.
Specifically, the terminal queries the original program name of the original program corresponding to the program to be tested in a preset corresponding relationship between the program name to be tested and the original program name according to the program name to be tested. The terminal takes the database of the program language type of the original program as a target database. Then, the terminal determines the original program in the configuration information of the target database according to the original program name. Then, the terminal acquires the original program in the target database. And simultaneously, the terminal acquires the program to be tested. The configuration information of the target database comprises the mapping relation between the original program name and the original program.
And 102, comparing a first logic code in the program to be tested with a second logic code in the original program according to a preset code comparison rule to obtain a logic code comparison result.
In the embodiment of the present application, the first logic code is a logic code in a program to be tested, and the second logic code is a logic code in an original program. Logical code includes, but is not limited to, if, for, and switch. And the code comparison rule is used for comparing whether the logic codes in the program to be tested are consistent with the logic codes in the original program. And the logic code comparison result is used for representing the consistency degree of the logic codes in the program to be tested and the original program.
And the terminal sequentially acquires the first logic codes in the program to be tested according to the sequence from front to back. Meanwhile, the terminal arranges the first logic codes in the program to be tested in sequence according to the obtained sequence to obtain a first logic code sequence. Similarly, the terminal sequentially obtains the second logic codes in the original program according to the sequence from front to back. Meanwhile, the terminal sequentially arranges the second logic codes in the original program according to the obtained sequence to obtain a second logic code sequence. And then, the terminal compares the first logic code sequence with the second logic code sequence according to a preset code comparison rule to obtain a logic code comparison result.
103, comparing the semantic relationship between the first semantic relationship code in the program to be tested and the second semantic relationship code in the original program according to a preset semantic comparison rule under the condition that the comparison result of the logic codes meets a preset first matching condition, so as to obtain a semantic relationship comparison result.
In the embodiment of the present application, the first matching condition is used to measure whether the logic codes in the program to be tested and the original program are consistent. The first semantic relation code is a semantic relation code in the program to be tested. The second semantic relation code is a semantic relation code in the original program. The semantic relation code is a part of the code which represents semantic relation. Semantic relationship code includes, but is not limited to, logical operators and conditional predicate values. And the semantic comparison rule is used for comparing whether the semantic relation codes in the program to be tested are consistent with those in the original program. And the semantic relation comparison result is used for representing the consistency degree of the semantic relation between the program to be tested and the original program.
The terminal judges whether the comparison result of the logic codes meets a preset first matching condition. And under the condition that the comparison result of the logic codes meets a preset first matching condition, the terminal performs semantic relation comparison on the first semantic relation codes in the program to be tested and the second semantic relation codes in the original program according to a preset semantic comparison rule to obtain a semantic relation comparison result.
Specifically, the terminal sequentially obtains a first semantic relation code in the program to be tested according to a sequence from front to back. Meanwhile, the terminal sequentially arranges the first semantic relation codes in the program to be tested according to the obtained sequence to obtain a first semantic relation code sequence. Similarly, the terminal sequentially acquires the second semantic relation codes in the original program according to the sequence from front to back. Meanwhile, the terminal sequentially arranges the second semantic relation codes in the original program according to the obtained sequence to obtain a second semantic relation code sequence. Then, the terminal carries out semantic relation comparison on the first semantic relation code sequence and the second semantic relation code sequence according to a preset semantic relation comparison rule to obtain a semantic relation code comparison result.
And step 104, determining a program test result of the program to be tested according to the semantic relation comparison result and a preset program test rule.
In the embodiment of the present application, the program test rule is used for performing a program test on the program to be tested after the program language type is replaced. And the program test result is used for indicating whether the program to be tested after the program language type replacement passes the program test. And the terminal determines the program test result of the program to be tested according to the semantic relation comparison result and a preset program test rule. Specifically, the terminal determines the program test identifier according to the semantic relation comparison result. Then, the terminal generates a program test result of the program to be tested, which contains the program test identification.
In one example, if the semantic relation comparison result indicates that the semantic relations are consistent, the terminal determines that the program test identifier is an identifier that represents that the test passes. And if the semantic relation comparison result shows that the semantic relations are inconsistent, the terminal determines that the program test identifier is an identifier which represents that the test fails.
In one example, the terminal identifies the program test as a program test result of the program to be tested.
In the program testing method, according to a preset code comparison rule, a first logic code in a program to be tested and a second logic code of an original program before replacement of a program language type corresponding to the program to be tested are compared, under the condition that an obtained code comparison result meets a preset first matching condition, a semantic relation is compared between a first semantic relation code in the program to be tested and a second semantic relation code in the original program according to the preset semantic comparison rule, and then a program testing result of the program to be tested is determined according to the obtained semantic relation comparison result and the preset program testing rule. Therefore, the program to be tested after the program language type replacement and the original program before the program language type replacement corresponding to the program to be tested are sequentially subjected to logic code comparison and semantic relation comparison, and whether the static logic of the program to be tested is consistent with that of the original program is judged, so that whether the program to be tested after the program language type replacement can realize the function of the original program is judged. Moreover, when the program range generally involved in replacing the program language type is wide and all logic branches of the whole program need to be tested to cover, the efficiency of the automatic testing method is further improved compared with the existing manual testing method. Moreover, the existing dynamic test method can only ensure the correct logic processing of the more limited logic branches of the program to be tested through limited operation tests, and the method can ensure the correct static logic of each logic branch of the program to be tested by comparing whether the static logic of the program to be tested is consistent with that of the original program or not to perform program test, thereby greatly improving the comprehensiveness and accuracy of the program test.
In one embodiment, the terminal determines that the program test identifier of the program to be tested is an identifier indicating that the test fails when the comparison result of the logic code does not meet a preset first matching condition. Then, the terminal generates a program test result of the program to be tested, which contains the program test identification.
In one embodiment, as shown in fig. 2, according to a preset code comparison rule, a specific process of comparing a first logic code in a program to be tested with a second logic code in an original program to obtain a logic code comparison result includes the following steps:
step 201, comparing a first length of a first logic code in the program to be tested with a second length of a second logic code in the original program to obtain a code length comparison result.
In the embodiment of the present application, the code length comparison result is used to indicate whether the lengths of the logic codes of the program to be tested and the original program are the same. And the terminal sequentially acquires the first logic codes in the program to be tested according to the sequence from front to back. Meanwhile, the terminal arranges the first logic codes in the program to be tested in sequence according to the obtained sequence to obtain a first logic code sequence. Similarly, the terminal sequentially acquires the second logic codes in the original program according to the sequence from front to back. Meanwhile, the terminal arranges the second logic codes in the original program in sequence according to the acquired sequence to obtain a second logic code sequence. Then, the terminal compares the first length of the first logic code sequence with the second length of the second logic code sequence to obtain a code length comparison result.
Step 202, determining a rule according to a first logic code in the program to be tested, a second logic code in the original program and a preset code similarity, and determining the code similarity of the first logic code and the second logic code.
In the embodiment of the application, the code similarity determination rule is used for determining the code similarity of the logic codes in the program to be tested and the original program. The code similarity is used to indicate the degree of similarity of the codes. And the terminal determines the code similarity of the first logic code and the second logic code according to a first logic code sequence in the program to be tested, a second logic code sequence in the original program and a preset code similarity determination rule.
In one example, the terminal calculates the code similarity of the first logic code and the second logic code according to a first logic code in the program to be tested, a second logic code in the original program and an edit distance algorithm.
And step 203, comparing the code length comparison result with the code similarity to form a logic code comparison result.
In the embodiment of the application, the terminal compares the code length with the code similarity to form a logic code comparison result.
In the program testing method, the logic code comparison result is formed by comparing the lengths of the logic codes of the program to be tested and the original program, determining the code similarity of the logic codes of the program to be tested and the original program, and comparing the code length comparison result with the code similarity. Therefore, the method for comparing the lengths of the logic codes and determining the similarity can further ensure that the logic codes of the program to be tested after the program language type replacement are consistent with the original program, further improve the comprehensiveness and accuracy of static logic comparison, and further improve the comprehensiveness and accuracy of program testing.
In one embodiment, the first matching condition includes a code similarity threshold. As shown in fig. 3, when the comparison result of the logical codes meets the preset first matching condition, the following steps are further included before comparing the semantic relationship between the first semantic relationship code in the program to be tested and the second semantic relationship code in the original program according to the preset semantic comparison rule to obtain the semantic relationship comparison result:
step 301, if the logic code comparison result indicates that the first length is the same as the second length and the code similarity is greater than or equal to a preset code similarity threshold, determining that the logic code comparison result meets a preset first matching condition.
In the embodiment of the present application, the code similarity threshold is used to measure whether the logic codes of the program to be tested and the original program are consistent. For example, the code similarity threshold may be 75%. And the terminal presets a code similarity threshold. Then, the terminal compares the code similarity with a preset code similarity threshold. If the logic code comparison result shows that the first length is the same as the second length and the code similarity is greater than or equal to a preset code similarity threshold, the terminal determines that the logic code comparison result meets a preset first matching condition.
In step 302, if the logic code comparison result indicates that the first length is different from the second length or the code similarity is smaller than a preset code similarity threshold, it is determined that the logic code comparison result does not satisfy a preset first matching condition.
In this embodiment, if the logic code comparison result indicates that the first length is different from the second length or the code similarity is smaller than a preset code similarity threshold, the terminal determines that the logic code comparison result does not satisfy a preset first matching condition.
In the program testing method, if the logic code comparison result indicates that the first length is the same as the second length and the code similarity is greater than or equal to a preset code similarity threshold, it is determined that the logic code comparison result meets a preset first matching condition; and if the logic code comparison result shows that the first length is different from the second length or the code similarity is smaller than a preset code similarity threshold value, determining that the logic code comparison result does not meet a preset first matching condition. Therefore, the lengths of the logic codes of the program to be tested and the original program are the same, and the code similarity between the logic codes of the program to be tested and the original program is greater than or equal to a code similarity threshold value, so that a first matching condition is formed together, the logic codes are compared in length, the similarity is determined, the consistency between the logic codes of the program to be tested after the program language type replacement and the original program can be further ensured, the comprehensiveness and accuracy of static logic comparison are further improved, and the comprehensiveness and accuracy of program testing are further improved.
In one embodiment, as shown in fig. 4, the determination process of the code similarity threshold includes the following steps:
step 401, determining a first program type of a program to be tested and a second program type of an original program.
In an embodiment of the present application, the first program type is a program language type of a program to be tested. The second program type is the program language type of the original program. The terminal determines a first program type of the program to be tested and a second program type of the original program according to the program to be tested and the original program.
Step 402, determining the standard code similarity of the first program type and the second program type according to a first standard logic code of the program of the first program type, a second standard logic code of the program of the second program type, and a preset code similarity determination rule.
In the embodiment of the application, the terminal acquires a first standard logic code of a program of a first program type and a second standard logic code of a program of a second program type. And then, the terminal determines the standard code similarity of the first program type and the second program type according to the first standard logic code, the second standard logic code and a preset code similarity determination rule.
In one example, the terminal calculates a standard code similarity of the first program type and the second program type according to the first standard logic code, the second standard logic code, and an edit distance algorithm.
And 403, calculating a code similarity threshold according to the standard code similarity and a preset code similarity threshold calculation rule.
In the embodiment of the application, the terminal calculates the code similarity threshold according to the standard code similarity and a preset code similarity threshold calculation rule. And the code similarity threshold calculation rule is used for calculating the code similarity threshold.
In one example, the terminal may subtract the standard threshold difference from the standard code similarity to calculate the code similarity threshold. Wherein the standard threshold difference is a difference between the standard code similarity and the code similarity threshold. For example, the standard threshold difference may be 5%.
In the program testing method, the standard code similarity is determined according to the first standard logic code corresponding to the program type of the program to be tested, the second standard logic code corresponding to the program type of the original program and the preset code similarity determination rule, and then the code similarity threshold is calculated according to the standard code similarity and the preset code similarity threshold calculation rule, so that the process of determining the code similarity threshold is quick, the code similarity threshold is reasonable, and the program testing accuracy is further improved.
In one embodiment, as shown in fig. 5, the specific process of comparing the semantic relationship between the first semantic relationship code in the program to be tested and the second semantic relationship code in the original program according to the preset semantic comparison rule to obtain the semantic relationship comparison result includes the following steps:
step 501, for each first semantic relation code, determining a second semantic relation code corresponding to the first semantic relation code, and forming a target mapping relation of the first semantic relation code by using the first semantic relation code and the second semantic relation code corresponding to the first semantic relation code.
In the embodiment of the application, for each first semantic relation code in the first semantic relation code sequence, the terminal determines a second semantic relation code corresponding to the first semantic relation code in the second semantic relation code sequence. Then, the terminal constructs the first semantic relation code and the second semantic relation code corresponding to the first semantic relation code into the target mapping relation of the first semantic relation code.
In one example, the terminal may determine a code line number of the first semantic relation code in the first semantic relation code sequence. Then, the terminal determines a second semantic relation code of the same number of code lines in the second semantic relation code sequence. Then, the terminal takes the second semantic relation code as a second semantic relation code corresponding to the first semantic relation code.
Step 502, matching the target mapping relation with a preset standard mapping relation between the first semantic relation code and the second semantic relation code to obtain a matching result of the first semantic relation code.
In the embodiment of the application, the terminal presets the standard mapping relation between the first semantic relation code and the second semantic relation code. And then, the terminal matches the target mapping relation with the standard mapping relation to obtain a matching result of the first semantic relation code. And the matching result is used for indicating whether the target mapping relation of the first semantic relation code is successfully matched with the standard mapping relation.
Step 503, generating a semantic relation comparison result according to the matching result of each first semantic relation code.
In the embodiment of the application, the terminal generates the semantic relation comparison result according to the matching result of each first semantic relation code.
In one example, the terminal may determine a total number of matching results for the matching results of the first semantic relationship code. Meanwhile, the terminal determines the matching success number of the matching result of the first semantic relation code indicating successful matching. And then, the terminal divides the matching success number by the total number of the matching results to calculate the semantic relation similarity. And then, the terminal takes the semantic relation similarity as a semantic relation comparison result. And the semantic relation similarity is used for expressing the similarity of the semantic relation between the program to be tested and the original program.
In one example, the terminal constructs a semantic relation comparison result from matching results of the first semantic relation codes.
In an example, if the matching result of each first semantic relation code indicates that the matching is successful, the terminal determines that the semantic relation comparison identifier is an identifier that represents that the semantic relation comparison passes. If the matching result of the first semantic relation codes indicates that the matching is not successful, the terminal determines that the semantic relation comparison identifier is an identifier indicating that the semantic relation comparison is not passed. Then, the terminal generates a semantic relation comparison result containing the semantic relation comparison identifier. For example, the terminal uses the semantic relation comparison identifier as a semantic relation comparison result.
In the program testing method, a target mapping relation corresponding to the first semantic relation code is formed by determining the second semantic relation code corresponding to each first semantic relation code and the second semantic relation code corresponding to the first semantic relation code, each target mapping relation is matched with the standard mapping relation, and a semantic relation comparison result is generated according to the obtained matching result of each first semantic relation code. Thus, the target mapping relation is formed by the first semantic relation codes in the program to be tested and the second semantic relation codes corresponding to the first semantic relation codes, and then the target mapping relation is matched with the standard mapping relation, so that the comparison of the more hierarchical semantic relation between the program to be tested and the original program is realized, the consistency between the semantic relation of the program to be tested after the program language type replacement and the original program can be ensured, the comprehensiveness and the accuracy of static logic comparison are further improved, and the comprehensiveness and the accuracy of program testing are further improved.
In one embodiment, as shown in fig. 6, the specific process of determining the program test result of the program to be tested according to the semantic relationship comparison result and the preset program test rule includes the following steps:
step 601, under the condition that the semantic relation comparison result meets a preset second matching condition, obtaining the parameter types of the input parameter and the input parameter of the original program, determining a rule according to the parameter types and the preset input parameter value, and determining the input parameter value of the input parameter.
In the embodiment of the present application, the second matching condition is used to measure whether the semantic relationship between the program to be tested and the original program is consistent. The second matching condition corresponds to the semantic relation comparison result. The second matching condition may be that the semantic relation comparison identifier is an identifier representing that the semantic relation comparison passes. The second matching condition may also be that the semantic relationship similarity is greater than or equal to a semantic relationship similarity threshold. For example, the semantic relationship similarity threshold may be 100%. The parameter-entering value determination rule is used for determining a parameter-entering value. The parameter type determination rule may include a mapping relationship between the parameter type of the parameter and the parameter value.
And the terminal judges whether the semantic relation comparison result meets a preset second matching condition. And under the condition that the semantic relation comparison result meets a preset second matching condition, the terminal acquires the parameter types of the input parameters and the input parameters of the original program. And then, the terminal determines a rule according to the parameter type and a preset parameter value, and determines the parameter value of the parameter.
In one example, the terminal may obtain the original program. And then, the terminal executes the sql file to obtain a parameter table of the original program. Then, the terminal inquires the parameter type and the parameter entry of the original program in the parameter table of the original program. The sql file is used for acquiring the input and output references of the original program in the database and storing the references in the newly added table. The parameter table of the original program comprises the parameters of the original program and the parameter types of the parameters.
In one example, for each parameter, the terminal takes a fixed value of the parameter type as the parameter value of the parameter according to the parameter type of the parameter.
In one example, for each parameter, the terminal takes a random value of the parameter type as the parameter value of the parameter according to the parameter type of the parameter.
Step 602, assigning an entry parameter value to an entry parameter of the program to be tested and an entry parameter value to an entry parameter of the original program, and calling the program to be tested and the original program to obtain a first execution result of the program to be tested, a first data change result of the program to be tested, a second execution result of the original program and a second data change result of the original program.
In the embodiment of the present application, the first execution result is an execution result of the program to be tested. The second execution result is the execution result of the original program. The first data change result is used for representing the data change generated in the execution process of the program to be tested. The second data change result is used for representing the data change generated in the execution process of the original program. The first data change result may include data generated after the program under test is executed and a table modified during the execution of the program under test. The second data change result may include data generated after execution of the original program and a table modified during execution of the original program.
And aiming at each entry parameter, the terminal assigns an entry parameter value corresponding to the entry parameter to the program to be tested, calls the program to be tested and obtains a first execution result of the program to be tested and a first data change result of the program to be tested. Meanwhile, aiming at each entry, the terminal assigns an entry value corresponding to the entry to the original program, calls the original program and obtains a second execution result of the original program and a second data change result of the program to be tested.
Step 603, performing consistency comparison on the first execution result and the second execution result to obtain a first comparison result, and performing consistency comparison on the first data change result and the second data change result to obtain a second comparison result.
In the embodiment of the application, the terminal performs consistency comparison on the first execution result and the second execution result to obtain a first comparison result. And then, the terminal carries out consistency comparison on the first data change result and the second data change result to obtain a second comparison result. And the first comparison result is used for indicating whether the first execution result and the second execution result are consistent or not. The second comparison result is used for indicating whether the first data change result is consistent with the second data change result.
Step 604, determining a program test result of the program to be tested according to the first comparison result and the second comparison result.
In this embodiment of the application, if the first comparison result indicates that the first execution result is consistent with the second execution result, and the second comparison result indicates that the first data change result is consistent with the second data change result, the terminal determines that the program test identifier of the program to be tested is an identifier that characterizes the test passing. And if the first comparison result shows that the first execution result is inconsistent with the second execution result or the second comparison result shows that the first data change result is inconsistent with the second data change result, the terminal determines that the program test identifier of the program to be tested is an identifier which represents that the test fails. Then, the terminal generates a program test result of the program to be tested, which contains the program test identification.
In one example, the terminal identifies the program test as a program test result of the program to be tested.
In the program testing method, under the condition that the semantic relation comparison result meets a preset second matching condition, the parameter types of the input parameters and the input parameters of the original program are obtained, the input parameters of the input parameters are determined, the determined input parameters are assigned to the input parameters of the program to be tested and the original program, the program to be tested and the original program are called after the value is assigned, the first execution result of the program to be tested, the first data change result of the program to be tested, the second execution result of the original program and the second data change result of the original program are obtained, then the execution result and the data change result are respectively compared in a consistent mode, and the program testing result of the program to be tested is determined according to the comparison result. Therefore, under the condition that the static logic of the program to be tested is consistent with that of the original program, the program to be tested and the original program are assigned with the same reference values, the execution results and the generated data of the program to be tested and the original program are compared in a consistent manner, the running mechanism and the logic processing of part of logic branches of the program to be tested are ensured to be correct, whether the function of the original program can be realized by the program to be tested after the program language type replacement is carried out is judged from the static logic and the dynamic running, and the comprehensiveness and the accuracy of the program test are further improved. In addition, the method realizes the program test on the dynamic operation aspect of the program to be tested by comparing the consistency of a plurality of levels such as the return value, the program operation state, the database processing condition and the like, and can further improve the comprehensiveness and the accuracy of the dynamic operation program test, thereby further improving the comprehensiveness and the accuracy of the program test. In addition, compared with the existing dynamic operation test, the method does not need to waste time and labor, the test code of the program to be tested is compiled for each different program to be tested so as to obtain the input parameter of the program to be tested in a targeted manner, the input parameter value and the expected operation result are designed for the obtained input parameter, the operation result of the program to be tested is compared with the expected operation result, the input parameter of the original program is obtained, the same value is given to the input parameter of the program to be tested and the input parameter of the original program, the operation result of the program to be tested is compared with the operation result of the original program in a consistent manner, and the efficiency of the program test is further improved.
In one embodiment, the specific process of determining the program test result of the program to be tested according to the semantic relation comparison result and the preset program test rule comprises the following steps: and under the condition that the semantic relation comparison result does not meet a preset second matching condition, taking the program test identification which does not pass the representation test as the program test result of the program to be tested.
In the embodiment of the application, under the condition that the semantic relation comparison result does not meet the preset second matching condition, the terminal determines that the program test identifier is an identifier indicating that the test fails. And then, the terminal takes the program test identification which represents that the test fails as the program test result of the program to be tested.
In the program testing method, under the condition that the semantic relation comparison result does not meet the preset second matching condition, the program testing identifier which does not pass the representation test is used as the program testing result of the program to be tested. Therefore, the program test result of the program to be tested which is inconsistent with the semantic relation of the original program is determined as the test failure, and the accuracy of the program test can be improved.
In one embodiment, as shown in fig. 7, the program testing method further includes the steps of:
step 701, under the condition that the program test result of the program to be tested indicates that the test is failed, determining an object code inconsistent with the second code of the original program and the number of object lines of the object code in the first code of the program to be tested.
In an embodiment of the present application, the first code is a code of a program to be tested. The second code is the code of the original program. The first code may be a first logic code or a first semantic relation code. The second code may be a second logic code or a second semantic relationship code. The condition that the program test result of the program to be tested indicates that the test fails may be a condition that the comparison result of the logic code does not meet a preset first matching condition, or a condition that the comparison result of the semantic relation code does not meet a preset second matching condition.
And under the condition that the program test result of the program to be tested shows that the test is failed, the terminal determines the target code inconsistent with the second code of the original program and the target line number of the target code in the first code of the program to be tested.
In one example, the terminal determines, in the first logical code, an object code and a target number of lines of the object code that are inconsistent with the second logical code.
In one example, the terminal determines, in the first semantic relation code, object code that is inconsistent with the second semantic relation code and a number of object lines of the object code.
Step 702, the target code and the target line number constitute program error information of the program to be tested.
In the embodiment of the application, the terminal constructs the program error information of the program to be tested by using the target code and the target line number. The program error information is used for representing the part of the program error to be tested.
In the program testing method, under the condition that the program testing result of the program to be tested indicates that the test is failed, the program error information of the program to be tested is determined, wherein the program error information comprises inconsistent codes and inconsistent line numbers of the codes, so that a user can quickly determine the wrong codes of the program to be tested, and the comprehensiveness and convenience of the program testing are improved.
In one embodiment, as shown in FIG. 8, the program test method includes the steps of: step 801, acquiring a program to be tested and an original program corresponding to the program to be tested, and skipping to step 802; step 802, comparing a first logic code in the program to be tested with a second logic code in the original program according to a preset code comparison rule to obtain a logic code comparison result, and skipping to step 803; step 803, judging whether the logic code comparison result meets a preset first matching condition; skipping to step 811 when the logic code comparison result does not satisfy the preset first matching condition; skipping to step 804 when the logic code comparison result meets a preset first matching condition; step 804, comparing the semantic relation between the first semantic relation code in the program to be tested and the second semantic relation code in the original program according to a preset semantic comparison rule to obtain a semantic relation comparison result, and skipping to step 805; step 805, judging whether the semantic relation comparison result meets a preset second matching condition; skipping to step 811 under the condition that the semantic relation comparison result does not satisfy the preset second matching condition; skipping to step 806 when the semantic relation comparison result meets a preset second matching condition; 806, acquiring the parameter types of the parameter entries and the parameter entries of the original program, determining the parameter entry values of the parameter entries according to the parameter types and a preset parameter entry value determining rule, and jumping to 807; 807, assigning reference values to the reference of the program to be tested and the reference of the original program, calling the program to be tested and the original program to obtain a first execution result of the program to be tested, a first data change result of the program to be tested, a second execution result of the original program and a second data change result of the original program, and skipping to 808; step 808, comparing the first execution result with the second execution result in a consistent manner to obtain a first comparison result, comparing the first data change result with the second data change result in a consistent manner to obtain a second comparison result, and skipping to step 809; step 809, judging whether the first comparison result indicates that the first execution result is consistent with the second execution result and the second comparison result indicates that the first data change result is consistent with the second data change result; if the first comparison result indicates that the first execution result is inconsistent with the second execution result, or the second comparison result indicates that the first data change result is inconsistent with the second data change result, skipping to step 811; if the first comparison result indicates that the first execution result is consistent with the second execution result, and the second comparison result indicates that the first data change result is consistent with the second data change result, skipping to step 810; step 810, determining that the program test result of the program to be tested is a test pass; step 811, determining that the program test result of the program to be tested is a test failure.
It should be understood that, although the steps in the flowcharts related to the embodiments described above are shown in sequence as indicated by the arrows, the steps are not necessarily performed in sequence as indicated by the arrows. The steps are not limited to being performed in the exact order illustrated and, unless explicitly stated herein, may be performed in other orders. Moreover, at least a part of the steps in the flowcharts related to the embodiments described above may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, and the execution order of the steps or stages is not necessarily sequential, but may be rotated or alternated with other steps or at least a part of the steps or stages in other steps.
Based on the same inventive concept, the embodiment of the present application further provides a program testing apparatus for implementing the program testing method mentioned above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the method, so the specific limitations in one or more embodiments of the program testing device provided below can be referred to the limitations of the program testing method in the above, and are not described herein again.
In one embodiment, as shown in fig. 9, there is provided a program test device 900 comprising: an obtaining module 910, a logic code comparing module 920, a semantic relation comparing module 930, and a first determining module 940, wherein:
an obtaining module 910, configured to obtain a program to be tested and an original program before replacing a program language type corresponding to the program to be tested;
a logic code comparison module 920, configured to perform code comparison on the first logic code in the program to be tested and the second logic code in the original program according to a preset code comparison rule, so as to obtain a logic code comparison result;
a semantic relation comparison module 930, configured to, when the logical code comparison result meets a preset first matching condition, perform semantic relation comparison on the first semantic relation code in the program to be tested and the second semantic relation code in the original program according to a preset semantic comparison rule to obtain a semantic relation comparison result;
a first determining module 940, configured to determine a program test result of the program to be tested according to the semantic relationship comparison result and a preset program test rule.
Optionally, the logic code comparison module 920 is specifically configured to:
comparing the first length of the first logic code in the program to be tested with the second length of the second logic code in the original program to obtain a code length comparison result;
determining code similarity of a first logic code and a second logic code according to a first logic code in the program to be tested, a second logic code in the original program and a preset code similarity determination rule;
and forming a logic code comparison result by comparing the code length comparison result with the code similarity.
Optionally, the first matching condition includes a code similarity threshold; the apparatus 900 further comprises:
the first judging module is used for determining that the logic code comparison result meets a preset first matching condition if the logic code comparison result shows that the first length is the same as the second length and the code similarity is greater than or equal to a preset code similarity threshold;
and the second judging module is used for determining that the logic code comparison result does not meet a preset first matching condition if the logic code comparison result shows that the first length is different from the second length or the code similarity is smaller than a preset code similarity threshold.
Optionally, the apparatus 900 further includes:
the second determining module is used for determining the first program type of the program to be tested and the second program type of the original program;
a third determining module, configured to determine a standard code similarity between the first program type and the second program type according to a first standard logic code of the program of the first program type, a second standard logic code of the program of the second program type, and a preset code similarity determination rule;
and the calculation module is used for calculating a code similarity threshold according to the standard code similarity and a preset code similarity threshold calculation rule.
Optionally, the semantic relation comparing module 930 is specifically configured to:
aiming at each first semantic relation code, determining a second semantic relation code corresponding to the first semantic relation code, and forming a target mapping relation of the first semantic relation code by using the first semantic relation code and the second semantic relation code corresponding to the first semantic relation code;
matching the target mapping relation with a preset standard mapping relation of a first semantic relation code and a second semantic relation code to obtain a matching result of the first semantic relation code;
and generating a semantic relation comparison result according to the matching result of each first semantic relation code.
Optionally, the first determining module 940 is specifically configured to:
acquiring the parameter types of the input parameters and the input parameters of the original program under the condition that the semantic relation comparison result meets a preset second matching condition, and determining a rule according to the parameter types and a preset input parameter value to determine the input parameter value of the input parameters;
assigning the entry value to the entry of the program to be tested and the entry of the original program, and calling the program to be tested and the original program to obtain a first execution result of the program to be tested, a first data change result of the program to be tested, a second execution result of the original program and a second data change result of the original program;
performing consistency comparison on the first execution result and the second execution result to obtain a first comparison result, and performing consistency comparison on the first data change result and the second data change result to obtain a second comparison result;
and determining a program test result of the program to be tested according to the first comparison result and the second comparison result.
Optionally, the first determining module 940 is specifically configured to:
and under the condition that the semantic relation comparison result does not meet a preset second matching condition, taking a program test identifier which does not pass the representation test as a program test result of the program to be tested.
Optionally, the apparatus 900 further includes:
a fourth determining module, configured to determine, in the first code of the program to be tested, an object code inconsistent with the second code of the original program and a number of target lines of the object code, if a program test result of the program to be tested indicates that the test fails;
and the forming module is used for forming the program error information of the program to be tested by using the target code and the target line number.
The various modules in the program test device described above may be implemented in whole or in part by software, hardware, and combinations thereof. The modules can be embedded in a hardware form or independent of a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as shown in fig. 10. The computer apparatus includes a processor, a memory, an input/output interface, a communication interface, a display unit, and an input device. The processor, the memory and the input/output interface are connected by a system bus, and the communication interface, the display unit and the input device are connected by the input/output interface to the system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operating system and the computer program to run on the non-volatile storage medium. The input/output interface of the computer device is used for exchanging information between the processor and an external device. The communication interface of the computer device is used for communicating with an external terminal in a wired or wireless manner, and the wireless manner can be realized through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. The computer program is executed by a processor to implement a program testing method. The display unit of the computer device is used for forming a visual visible picture, and can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.
Those skilled in the art will appreciate that the architecture shown in fig. 10 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the steps of the above-described method embodiments when executing the computer program.
In an embodiment, a computer-readable storage medium is provided, on which a computer program is stored, which computer program, when being executed by a processor, carries out the steps of the above-mentioned method embodiments.
In an embodiment, a computer program product is provided, comprising a computer program which, when being executed by a processor, carries out the steps of the above-mentioned method embodiments.
It should be noted that, the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) referred to in the present application are information and data authorized by the user or sufficiently authorized by each party, and the collection, use and processing of the related data need to comply with the relevant laws and regulations and standards of the relevant country and region.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, databases, or other media used in the embodiments provided herein can include at least one of non-volatile and volatile memory. The nonvolatile Memory may include a Read-Only Memory (ROM), a magnetic tape, a floppy disk, a flash Memory, an optical Memory, a high-density embedded nonvolatile Memory, a resistive Random Access Memory (ReRAM), a Magnetic Random Access Memory (MRAM), a Ferroelectric Random Access Memory (FRAM), a Phase Change Memory (PCM), a graphene Memory, and the like. Volatile Memory can include Random Access Memory (RAM), external cache Memory, and the like. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others. The databases referred to in various embodiments provided herein may include at least one of relational and non-relational databases. The non-relational database may include, but is not limited to, a block chain based distributed database, and the like. The processors referred to in the various embodiments provided herein may be, without limitation, general purpose processors, central processing units, graphics processors, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, or the like.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the present application. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.
Claims (12)
1. A method of program testing, the method comprising:
acquiring a program to be tested and an original program before replacing a program language type corresponding to the program to be tested;
according to a preset code comparison rule, comparing a first logic code in the program to be tested with a second logic code in the original program to obtain a logic code comparison result;
comparing the semantic relationship between the first semantic relationship code in the program to be tested and the second semantic relationship code in the original program according to a preset semantic comparison rule under the condition that the comparison result of the logic codes meets a preset first matching condition to obtain a semantic relationship comparison result;
and determining a program test result of the program to be tested according to the semantic relation comparison result and a preset program test rule.
2. The method of claim 1, wherein the code comparison of the first logic code in the program to be tested and the second logic code in the original program according to a preset code comparison rule to obtain a logic code comparison result comprises:
comparing the first length of the first logic code in the program to be tested with the second length of the second logic code in the original program to obtain a code length comparison result;
determining code similarity of a first logic code and a second logic code according to a first logic code in the program to be tested, a second logic code in the original program and a preset code similarity determination rule;
and forming a logic code comparison result by using the code length comparison result and the code similarity.
3. The method of claim 2, wherein the first matching condition comprises a code similarity threshold; when the logic code comparison result meets a preset first matching condition, performing semantic relation comparison on the first semantic relation code in the program to be tested and the second semantic relation code in the original program according to a preset semantic comparison rule, and before obtaining a semantic relation comparison result, the method further includes:
if the logic code comparison result shows that the first length is the same as the second length and the code similarity is greater than or equal to a preset code similarity threshold value, determining that the logic code comparison result meets a preset first matching condition;
and if the logic code comparison result shows that the first length is different from the second length or the code similarity is smaller than a preset code similarity threshold, determining that the logic code comparison result does not meet a preset first matching condition.
4. The method of claim 3, wherein the determining the code similarity threshold comprises:
determining a first program type of the program to be tested and a second program type of the original program;
determining the standard code similarity of the first program type and the second program type according to a first standard logic code of the program of the first program type, a second standard logic code of the program of the second program type and a preset code similarity determination rule;
and calculating a code similarity threshold according to the standard code similarity and a preset code similarity threshold calculation rule.
5. The method according to claim 1, wherein the semantic relationship comparison of the first semantic relationship code in the program to be tested and the second semantic relationship code in the original program according to a preset semantic comparison rule to obtain a semantic relationship comparison result comprises:
aiming at each first semantic relation code, determining a second semantic relation code corresponding to the first semantic relation code, and forming a target mapping relation of the first semantic relation code by using the first semantic relation code and the second semantic relation code corresponding to the first semantic relation code;
matching the target mapping relation with a preset standard mapping relation of a first semantic relation code and a second semantic relation code to obtain a matching result of the first semantic relation code;
and generating a semantic relation comparison result according to the matching result of each first semantic relation code.
6. The method of claim 1, wherein the determining the program test result of the program to be tested according to the semantic relationship comparison result and a preset program test rule comprises:
acquiring the parameter types of the input parameters and the input parameters of the original program under the condition that the semantic relation comparison result meets a preset second matching condition, and determining a rule according to the parameter types and a preset input parameter value to determine the input parameter value of the input parameters;
assigning the entry value to the entry of the program to be tested and the entry of the original program, and calling the program to be tested and the original program to obtain a first execution result of the program to be tested, a first data change result of the program to be tested, a second execution result of the original program and a second data change result of the original program;
performing consistency comparison on the first execution result and the second execution result to obtain a first comparison result, and performing consistency comparison on the first data change result and the second data change result to obtain a second comparison result;
and determining a program test result of the program to be tested according to the first comparison result and the second comparison result.
7. The method of claim 1, wherein the determining the program test result of the program to be tested according to the semantic relationship comparison result and a preset program test rule comprises:
and under the condition that the semantic relation comparison result does not meet a preset second matching condition, taking a program test identifier which does not pass the representation test as a program test result of the program to be tested.
8. The method of claim 1, further comprising:
under the condition that the program test result of the program to be tested indicates that the test is failed, determining an object code inconsistent with the second code of the original program and the target line number of the object code in the first code of the program to be tested;
and forming program error information of the program to be tested by using the target code and the target line number.
9. A program test apparatus, the apparatus comprising:
the acquisition module is used for acquiring a program to be detected and an original program before the program language type corresponding to the program to be detected is replaced;
the logic code comparison module is used for comparing a first logic code in the program to be tested with a second logic code in the original program according to a preset code comparison rule to obtain a logic code comparison result;
the semantic relation comparison module is used for comparing the semantic relation between the first semantic relation code in the program to be tested and the second semantic relation code in the original program according to a preset semantic comparison rule under the condition that the logical code comparison result meets a preset first matching condition to obtain a semantic relation comparison result;
and the first determining module is used for determining a program test result of the program to be tested according to the semantic relation comparison result and a preset program test rule.
10. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor, when executing the computer program, implements the steps of the method of any of claims 1 to 8.
11. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 8.
12. A computer program product comprising a computer program, characterized in that the computer program realizes the steps of the method of any one of claims 1 to 8 when executed by a processor.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211474573.9A CN115718701A (en) | 2022-11-23 | 2022-11-23 | Program testing method, program testing device, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211474573.9A CN115718701A (en) | 2022-11-23 | 2022-11-23 | Program testing method, program testing device, computer equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115718701A true CN115718701A (en) | 2023-02-28 |
Family
ID=85256070
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211474573.9A Pending CN115718701A (en) | 2022-11-23 | 2022-11-23 | Program testing method, program testing device, computer equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115718701A (en) |
-
2022
- 2022-11-23 CN CN202211474573.9A patent/CN115718701A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108459964B (en) | Test case selection method, device, equipment and computer readable storage medium | |
CN116610583A (en) | SCA tool maturity evaluation method, SCA tool maturity evaluation device, SCA tool maturity evaluation equipment, SCA tool maturity evaluation medium and SCA tool maturity evaluation product | |
CN115718701A (en) | Program testing method, program testing device, computer equipment and storage medium | |
CN115130002A (en) | Recommendation request processing method and device, computer equipment and storage medium | |
CN112631905A (en) | Execution process data management method and device, computer equipment and storage medium | |
CN112417020A (en) | Method and device for realizing service expansion, computer equipment and storage medium | |
CN112835886A (en) | Data table field adding method and device | |
CN117349358B (en) | Data matching and merging method and system based on distributed graph processing framework | |
CN117827895A (en) | Index data processing method and device and computer equipment | |
CN116737541A (en) | Test positioning method, device, computer equipment and computer storage medium | |
CN117331812A (en) | Service code verification method, device, computer equipment, storage medium and product | |
CN117612192A (en) | Electronic drawing information identification method, system, electronic equipment and storage medium | |
CN114896590A (en) | Application program detection method, system, device and computer equipment | |
CN115687074A (en) | Business system testing method and device, computer equipment and storage medium | |
CN114817065A (en) | Interface automation test method and device and computer equipment | |
CN115437935A (en) | Test case generation method and device, computer equipment and storage medium | |
CN115510130A (en) | Report generation method and device, computer equipment and storage medium | |
CN117033242A (en) | Test data generation method, device, computer equipment and storage medium | |
CN117435478A (en) | Program logic function detection method, device, computer equipment and storage medium | |
CN118093161A (en) | Task management method, device, computer equipment, storage medium and program product | |
CN116775955A (en) | Data tag solidifying method, device, computer equipment and storage medium | |
CN115904968A (en) | Interface testing method and device, computer equipment and storage medium | |
CN117389601A (en) | Financial software influence traceability analysis method, device, equipment and storage medium | |
CN114610749A (en) | Database execution statement optimization method, apparatus, device, medium, and program product | |
CN116909876A (en) | Debugging method, debugging device, computer device, storage medium, and program product |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |