CN114860597A - Method, device, equipment and storage medium for determining code coverage rate - Google Patents

Method, device, equipment and storage medium for determining code coverage rate Download PDF

Info

Publication number
CN114860597A
CN114860597A CN202210492259.7A CN202210492259A CN114860597A CN 114860597 A CN114860597 A CN 114860597A CN 202210492259 A CN202210492259 A CN 202210492259A CN 114860597 A CN114860597 A CN 114860597A
Authority
CN
China
Prior art keywords
code
original file
statement
determining
data structure
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
Application number
CN202210492259.7A
Other languages
Chinese (zh)
Inventor
周朝信
黄震人
熊小庆
高梦杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202210492259.7A priority Critical patent/CN114860597A/en
Publication of CN114860597A publication Critical patent/CN114860597A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3676Test management for coverage analysis

Abstract

The disclosure provides a method for determining code coverage rate, which can be applied to the field of artificial intelligence. The method comprises the following steps: acquiring an original file and an execution log of a target object in the process of generating an output statement, wherein the original file comprises an original code and a code construction label; analyzing the original file to determine analysis data, wherein the analysis data comprises a target data structure; determining an analog statement of an output statement according to the target data structure and the execution log, wherein the code content of the analog statement is the same as that of the output statement; and determining the code coverage rate of the original file according to the simulation statement and the analysis data. The present disclosure also provides a code coverage determination apparatus, a device, a storage medium, and a program product.

Description

Method, device, equipment and storage medium for determining code coverage rate
Technical Field
The present disclosure relates to the field of artificial intelligence, and in particular, to a method, an apparatus, an electronic device, a computer-readable storage medium, and a computer program product for determining code coverage.
Background
Coverage is a means of measuring test integrity for evaluating the reliability, stability and performance of a system, and is determined from executed code. Test coverage is an evaluation of the test completion program. Test coverage is represented by test requirements and coverage of test cases or coverage of executed code, based on evaluating test results and determining change requests during testing.
SQL (Structured Query Language) statement coverage statistics are different from java program coverage statistics, the java statement coverage statistics indicate whether the content of the target statement is executed, and the SQL statement coverage statistics include whether the target SQL statement is executed and whether SQL components spliced into the target SQL statement are executed. The existing framework can not realize the SQL statement change detection function and the SQL statement coverage monitoring function.
Disclosure of Invention
In view of the foregoing, the present disclosure provides a code coverage determination method and apparatus, an electronic device, a computer-readable storage medium, and a computer program product for determining coverage of an SQL statement.
According to a first aspect of the present disclosure, there is provided a method for determining code coverage, including: acquiring an original file and an execution log of a target object in the process of generating an output statement, wherein the original file comprises an original code and a code construction label; analyzing the original file to determine analysis data, wherein the analysis data comprises a target data structure; determining a simulation statement of the output statement according to the target data structure and the execution log, wherein the simulation statement and the output statement have the same code content; and determining the code coverage rate of the original file according to the simulation statement and the analysis data.
According to an embodiment of the present disclosure, the parsing data further includes tag location information including location information of the code construction tag; wherein the determining the code coverage of the original file according to the simulation statement and the analysis data comprises: determining target position information according to the label position information, wherein the target position information comprises position information of a code construction label corresponding to the code content of the simulation statement; and determining the code coverage rate of the original file according to the target position information and the target data structure.
According to an embodiment of the present disclosure, wherein determining the code coverage of the original file according to the target location information and the target data structure comprises: determining the whole position information of the original code according to the target data structure; and determining the code coverage rate of the original file according to the ratio of the target position information to the overall position information.
According to an embodiment of the present disclosure, the obtaining an execution log of a target object in generating an output statement includes: acquiring an execution method and an execution parameter required by generating the output statement through facet-oriented programming; and determining an execution log based on the execution method and the execution parameter.
According to an embodiment of the present disclosure, before the parsing the original file, further comprising: acquiring a current processing version of the target object; and under the condition that the current processing version is determined to be updated, replacing the current processing version with the updated processing version, wherein the updated processing version is used for analyzing the original file.
According to an embodiment of the present disclosure, further comprising: analyzing the original file by using the current processing version, and determining an updated target data structure; and determining changed data according to the non-updated target data structure and the updated target data structure.
According to a second aspect of the present disclosure, there is provided a code coverage determination apparatus including: the system comprises an acquisition module, a storage module and a processing module, wherein the acquisition module is used for acquiring an original file and an execution log of a target object in the process of generating an output statement, and the original file comprises an original code and a code construction label; the first determining module is used for analyzing the original file and determining analysis data, wherein the analysis data comprises a target data structure; a second determining module, configured to determine, according to the target data structure and the execution log, a simulated statement of the output statement, where code content of the simulated statement is the same as that of the output statement; and the statistical module is used for determining the code coverage rate of the original file according to the simulation statement and the analysis data.
According to a third aspect of the present disclosure, there is provided an electronic device comprising: one or more processors; a memory for storing one or more instructions, wherein the one or more instructions, when executed by the one or more processors, cause the one or more processors to implement the code coverage determination method described above.
According to a fourth aspect of the present disclosure, there is provided a computer-readable storage medium having stored thereon executable instructions that, when executed by a processor, cause the processor to implement the above-described code coverage determination method.
According to a fifth aspect of the present disclosure, there is provided a computer program product comprising computer executable instructions for implementing the above code coverage determination method when executed.
Drawings
The foregoing and other objects, features and advantages of the disclosure will be apparent from the following description of embodiments of the disclosure, which proceeds with reference to the accompanying drawings, in which:
fig. 1 schematically shows a system architecture of a code coverage determination method according to an embodiment of the present disclosure;
FIG. 2 schematically illustrates a flow chart of a method of code coverage determination in accordance with an embodiment of the present disclosure;
FIG. 3 schematically illustrates a flow chart of a method of determining raw code coverage from target location information and a target data structure according to an embodiment of the disclosure;
FIG. 4 schematically illustrates a flow chart of a method of determining raw code coverage from a ratio according to an embodiment of the disclosure;
FIG. 5 schematically illustrates a flow chart of a method of obtaining an execution log according to an embodiment of the present disclosure;
FIG. 6 schematically illustrates a flow chart of an update process version method according to an embodiment of the present disclosure;
FIG. 7 schematically illustrates a flow chart of a method of determining changed data according to an embodiment of the present disclosure;
fig. 8 is a block diagram schematically illustrating a structure of a code coverage determination apparatus according to an embodiment of the present disclosure; and
fig. 9 schematically shows a block diagram of an electronic device adapted to a method of code coverage determination according to an embodiment of the present disclosure.
Detailed Description
Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood that the description is illustrative only and is not intended to limit the scope of the present disclosure. In the following detailed description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the embodiments of the disclosure. It may be evident, however, that one or more embodiments may be practiced without these specific details. Moreover, in the following description, descriptions of well-known structures and techniques are omitted so as to not unnecessarily obscure the concepts of the present disclosure.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The terms "comprises," "comprising," and the like, as used herein, specify the presence of stated features, steps, operations, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, or components.
All terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art unless otherwise defined. It is noted that the terms used herein should be interpreted as having a meaning that is consistent with the context of this specification and should not be interpreted in an idealized or overly formal sense.
Where a convention analogous to "at least one of A, B and C, etc." is used, in general such a construction is intended in the sense one having skill in the art would understand the convention (e.g., "a system having at least one of A, B and C" would include but not be limited to systems that have a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.).
An embodiment of the present disclosure provides a method for determining code coverage, including: acquiring an original file and an execution log of a target object in the process of generating an output statement, wherein the original file comprises an original code and a code construction label; analyzing the original file to determine analysis data, wherein the analysis data comprises a target data structure; determining an analog statement of an output statement according to the target data structure and the execution log, wherein the code content of the analog statement is the same as that of the output statement; and determining the code coverage rate of the original file according to the simulation statement and the analysis data.
Fig. 1 schematically shows a system architecture of a code coverage determination method according to an embodiment of the present disclosure.
As shown in fig. 1, the system architecture 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. Various applications may be installed on the terminal devices 101, 102, 103, such as shopping-like applications, web browser applications, search-like applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 105 may be a server providing various services, such as a background management server (for example only) providing support for websites browsed by users using the terminal devices 101, 102, 103. The background management server may analyze and perform other processing on the received data such as the user request, and feed back a processing result (e.g., a webpage, information, or data obtained or generated according to the user request) to the terminal device.
It should be noted that the code coverage determination method provided by the embodiment of the present disclosure may be generally executed by the server 105. Accordingly, the code coverage determination apparatus provided by the embodiments of the present disclosure may be generally disposed in the server 105. The code coverage determination method provided by the embodiment of the present disclosure may also be performed by a server or a server cluster different from the server 105 and capable of communicating with the terminal devices 101, 102, 103 and/or the server 105. Accordingly, the code coverage determination apparatus provided by the embodiment of the present disclosure may also be disposed in a server or a server cluster different from the server 105 and capable of communicating with the terminal devices 101, 102, 103 and/or the server 105.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
The method for determining code coverage of the disclosed embodiment will be described in detail below with reference to fig. 2 to 7 based on the system architecture described in fig. 1.
Fig. 2 schematically shows a flow chart of a method of determining code coverage according to an embodiment of the present disclosure.
As shown in fig. 2, the method includes operations S201 to S204.
In operation S201, an execution log of an original file and a target object in generating an output statement is obtained, where the original file includes an original code and a code construction tag.
According to an embodiment of the present disclosure, the original file is a code file written by a developer according to development requirements, and includes original codes and code construction tags included in a database. For example, in the case of constructing an original file by a selection statement, the original code is the original code of call data contained in an existing database, and the code construction tag includes a constructed selection tag. The original file includes a file in xml format.
According to an embodiment of the present disclosure, the meaning of selecting a code expression of an original file is "eat food without getting an umbrella in sunny days; eating and holding the meal on cloudy days, and simultaneously including two original code sentences of 'holding the umbrella' and 'not holding the umbrella' in an original file at the moment, wherein the output target sentence is only one of the output sentences of 'holding the umbrella' or 'not holding the umbrella'; "on sunny days" or "on cloudy days" is determined by the code construction tag, that is, the code construction tag corresponding to the code implementing the selection function.
In operation S202, the original file is parsed, and parsing data is determined, where the parsing data includes a target data structure.
According to the embodiment of the disclosure, under the condition of an original file of an application program to be tested, the original file is analyzed, and analysis data is determined, wherein the analysis data comprises a target data structure. Similarly, the target data structure includes code information of the original file, such as the total number of lines of code in the original file, how many selection statements are in total, what the content of each selection statement is, and so on.
In operation S203, a mimic sentence of the output sentence is determined according to the target data structure and the execution log.
According to the embodiment of the disclosure, after analyzing the code contained in the original file, the application program generates an internal data structure, where the data structure includes code information of the original file, such as the total number of lines of the code in the original file, how many selection statements are in total, what the content of each selection statement is, and the like. In the case of generating an internal data structure, the persistence method is invoked directly to generate an output statement. The whole process from the acquisition of the original file to the generation of the output statement of the application program is recorded by the execution log, and the data for executing the log record comprises the called persistence method and the parameter information for calling the method.
According to the embodiment of the disclosure, the process of generating the output statement by the application program is independently completed. The method simulates one-pass program execution according to an original file and an execution log of an actual generation output statement process. Therefore, the present disclosure takes the original file and the execution log, and determines the mimic sentence of the output sentence. The analog statement and the output statement have the same code content but different storage locations.
In operation S204, code coverage of the original file is determined according to the simulation statement and the parsed data.
According to the embodiment of the disclosure, the analysis data includes code information of an original file, and the simulation statement is a statement obtained according to a process of generating an output statement by an application program. Comparing the analog sentences with the analysis data can obtain which sentences in the original file appear in the analog sentences and which do not appear in the original sentences. And determining the code coverage rate of the original file according to the difference between the analog sentence and the original file.
According to the embodiment of the disclosure, the SQL sentence of the original file is still used as' eating food in sunny days without getting an umbrella; eating and opening the umbrella on cloudy days are taken as an example, and when the output sentence is opened, the analog sentence is also opened, the analog sentence is compared with the original sentence, and the opening of the umbrella in the original sentence is determined to appear in the analog sentence. And determining the code coverage rate of the original file according to the code lines and all code line information of the occurrence of the 'umbrella opening' and 'non-umbrella opening' sentences. For example, "eating on sunny days without getting an umbrella" is located on one code line, "eating on cloudy days with getting an umbrella" is located on another code line, where the code coverage is 50%.
The method comprises the steps of obtaining an original file of an original application program and generating an execution log of an output statement to generate a simulation statement; by comparing the simulation statement with the original file, the coverage rate is determined without affecting the execution of the original application program. The coverage rate of the SQL statements is monitored, so that development personnel can improve the code quality and reduce the generation of waste codes.
FIG. 3 schematically illustrates a flow chart of a method of determining raw code coverage from target location information and a target data structure according to an embodiment of the disclosure.
As shown in fig. 3, the method includes operations S301 to S302.
In operation S301, target location information is determined according to the tag location information, and the target location information includes location information of a code construction tag corresponding to the code content of the simulation sentence.
According to an embodiment of the present disclosure, the parsing data further includes tag location information including location information of the code construction tag. Specifically, the tag position information includes position information of a code structure tag corresponding to the selection statement in the original file, for example, if "used for selection is used as the code structure tag, the position information corresponding to" if "is tag position information. The tag location information includes a line code, e.g., the first "if" is located on line 5 of the code in the original file, then the tag location information may be "5". It should be noted that the code build tag in the original file may include a plurality of identical "if" s, but the tag location information of each code build tag is not the same.
According to an embodiment of the present disclosure, the original file contains a plurality of selection statements, but not every selection statement is related to the final output statement. The target location information includes location information of code construction tags associated with the output statements, i.e., the code content of the code construction tags of the target are located in the simulation statements. For example, if the output sentence is "get an umbrella", then "eat in cloudy days, get an umbrella" in the original file, and the selection sentence corresponding to "in cloudy days" constructs a tag for the target code.
In operation S302, a code coverage of the original file is determined according to the target location information and the target data structure.
According to the embodiment of the disclosure, the target data structure comprises all file information of the original code, and the original file information and the target position information contained in the target data structure are compared to determine the code coverage rate of the original file. For example, the target position information is information corresponding to the content contained in the analog sentence in the original file, and the target data structure is obtained by comparing the original code information with the target position information of the acquired target information for all the code information contained in the original file, so as to obtain the difference between the original code information and the target position information, and determine the code coverage rate of the original file.
Fig. 4 schematically illustrates a flow chart of a method of determining original code coverage from a ratio according to an embodiment of the disclosure.
As shown in fig. 4, the method includes operations S401 to S402.
In operation S401, overall location information of the original code is determined according to the target data structure.
According to an embodiment of the present disclosure, the entire position information of the original code includes line position information of the code, for example, the entire line position information of the original code is stored in the form of a table. And determining the overall position information of the original code according to the content information of the original code contained in the target data structure, wherein the overall position information comprises the total number of code lines, the line position information of all code construction tags and the line position information of all the original codes.
In operation S402, a code coverage of the original file is determined according to a ratio between the target location information and the overall location information.
According to the embodiment of the disclosure, after the target position information of the code construction tag corresponding to the content appearing in the simulation sentence is determined, the code coverage of the original file is obtained according to the ratio between the target position information and the overall position information, for example, taking the total line number of the target position information as a numerator and the total line number of the overall position information as a denominator.
For example, the original code file includes 10 lines in total, where the lines where the content appearing in the simulation statement are lines 1, 4, 5, 6, 7, and 10, respectively, then the code coverage of the original file is 60%. For the coverage rate of the SQL sentences of the original file, the output simulation sentences are also SQL sentences, the numerator is the number of rows of all the SQL sentences covered by the output sentences in the original file, and the denominator is the total number of rows of all the SQL sentences in the original file. Specifically, the code structure tag is specifically "if", and in the case of parsing the original file, a source code line number corresponding to the code structure tag is additionally recorded, and when the content of the tag enters a final SQL statement, the line representing the carrier source code is covered, so as to determine the code coverage rate of the original file.
FIG. 5 schematically shows a flow chart of a method of obtaining an execution log according to an embodiment of the present disclosure.
As shown in fig. 5, the method includes operations S501 to S502.
In operation S501, an execution method and execution parameters required for generating an output statement are acquired through facet-oriented programming.
According to embodiments of the present disclosure, the implementation of a function requires the invocation of multiple methods and parameters, but not all parameters or methods participate in the final generation of the output statement in this process. And performing section programming on the application program by a section-oriented programming method, and acquiring parameter information of the execution method before the execution method is operated. Such as a function call statement.
For example, when the function of outputting 'do-it-today' is implemented, the application needs a persistence method to convert the calling functional statement of the application into a database-matched functional statement containing the original code of 'do-it-today', and for the function of outputting 'do-it-today', the method of the statement conversion is not a method directly related to implementing the output function.
In operation S502, an execution log is determined based on the execution method and the execution parameter.
According to the embodiment of the disclosure, a plurality of execution methods related to generating output statements and execution parameters of the execution methods are obtained through section programming, the execution methods and the execution parameters are corresponded and written into an execution log, and the execution conditions of all persistent methods of the current application program are recorded.
According to the embodiment of the disclosure, the execution log comprises all execution methods and execution parameters of the output statement generated by the application program; and determining a preset module in the execution log, wherein the preset module is used for storing the execution method and the execution parameter which are directly related to the generation of the output statement. The execution log may also store only the execution methods and execution parameters directly related to generating the output statements.
FIG. 6 schematically shows a flow chart of an update process version method according to an embodiment of the present disclosure.
As shown in fig. 6, the method includes operations S601 to S602.
In operation S601, a current processing version of a target object is acquired.
According to an embodiment of the present disclosure, the target object is an application currently under test. Because the application program in the prior art can be updated continuously according to the development requirement, the updated processing version can have a certain difference from the current processing version. Before the original file is analyzed by the target object, the current processing version of the target object is obtained, so that the difference comparison of data is carried out under the condition that the processing version is updated.
In operation S602, in a case that it is determined that the current processing version is updated, the current processing version is replaced with the updated processing version, and the updated processing version is used for parsing the original file.
According to the embodiment of the present disclosure, in a case where it is determined that the current processing version is updated, the current processing version is replaced with the updated processing version, for example, in a case where all versions are updated, the current processing version is entirely replaced with the updated processing version; and under the condition that the updating processing version is updated in a patch form, updating the patch file into the current processing version to obtain and update the processing version. The current processing version and the updated processing version are used for analyzing the original file, and the generated analysis data is related to the original file and also comprises processing information of the processing version.
FIG. 7 schematically illustrates a flow chart of a method of determining changed data according to an embodiment of the present disclosure.
As shown in fig. 7, the method includes operations S701 to S702.
In operation S701, the original file is parsed with the current processing version, and an un-updated target data structure is determined.
According to the embodiment of the disclosure, in the case that the current processing version is determined to have an update and the processing version is replaced with the updated processing version, the original file is parsed by the current processing version which is not updated, and the target data structure which is not updated is determined. After the processing version is updated, the updated processing version can analyze the original file to obtain an updated target data structure. The updating of the processing version can be optimization and addition of functions of the application program, so that the codes for realizing the same functions can be changed correspondingly.
According to the embodiment of the disclosure, the updated target data structure comprises the original code, the code construction tag and the line content in the original file, and the non-updated target data structure also comprises the original code, the code construction tag and the line content in the original file, wherein the contents of the original code, the code construction tag and the line content are the same part and different parts exist, so that the line information of the same code content can be different.
In operation S702, changed data is determined according to the non-updated target data structure and the updated target data structure.
According to an embodiment of the present disclosure, the changed data is determined according to the target data structure that is not updated and the target data structure that is updated. The original code corresponding to the "umbrella" is not changed, but the line information corresponding to the code is line 3 in the updated object data structure and line 2 in the non-updated object data structure, and at this time, the changed data can be specified by comparing the object data structures. Then, based on the changed data, it is possible to determine the change in the function, query entry, and code information of the application program. For example, the current project is written by an SQL statement, and target data structures before and after updating are compared, so that changes of the SQL statement can be detected.
According to the method and the device, through comparison of the data structures before and after updating, the change of the application program can be detected, and developers or testers are reminded to pay attention to the changed program and the program related to the changed part.
The method comprises the steps of generating simulation sentences by acquiring original files of original application programs and generating execution logs of output sentences; by comparing the simulation statement with the original file, the coverage rate is determined under the condition of not influencing the execution of the original application program, the monitoring function of the coverage rate of the SQL statement is realized, the improvement of the code quality by developers is facilitated, and the generation of waste codes is reduced. And monitoring the code coverage rate, and simultaneously monitoring the change of the code by comparing structural data generated before and after the version is changed, and reminding developers of paying attention to the changed code and program.
Fig. 8 schematically shows a block diagram of a code coverage determination apparatus according to an embodiment of the present disclosure.
As shown in fig. 8, the apparatus 800 for determining code coverage rate of this embodiment includes an obtaining module 801, a first determining module 802, a second determining module 803, and a counting module 804.
An obtaining module 801, configured to obtain an original file and an execution log of a target object in a process of generating an output statement, where the original file includes an original code and a code construction tag. In an embodiment, the obtaining module 801 may be configured to perform the operation S201 described above, which is not described herein again.
The first determining module 802 is configured to parse the original file, and determine parsed data, where the parsed data includes a target data structure. In an embodiment, the first determining module 802 may be configured to perform the operation S202 described above, which is not described herein again.
And a second determining module 803, configured to determine, according to the target data structure and the execution log, a simulated statement of the output statement, where the code content of the simulated statement is the same as that of the output statement. In an embodiment, the second determining module 803 may be configured to perform the operation S203 described above, which is not described herein again.
And the statistic module 804 is used for determining the code coverage rate of the original file according to the simulation statement and the analysis data. In an embodiment, the statistical module 804 may be configured to perform the operation S204 described above, which is not described herein again.
According to an embodiment of the present disclosure, the statistics module 804 includes a first determination unit and a second determination unit.
The first determining unit is used for determining target position information according to the label position information, and the target position information comprises position information of a code construction label corresponding to the code content of the simulation statement. In an embodiment, the first determining unit may be configured to perform the operation S301 described above, which is not described herein again.
The second determining unit is used for determining the code coverage rate of the original file according to the target position information and the target data structure. In an embodiment, the second determining unit may be configured to perform the operation S302 described above, which is not described herein again.
According to an embodiment of the present disclosure, the second determination unit includes a first determination subunit and a second determination subunit.
The first determining subunit is used for determining the whole position information of the original code according to the target data structure. In an embodiment, the first determining subunit may be configured to perform operation S401 described above, and is not described herein again.
And the second determining subunit is used for determining the code coverage rate of the original file according to the ratio of the target position information to the overall position information. In an embodiment, the second determining subunit may be configured to perform the operation S402 described above, which is not described herein again.
According to an embodiment of the present disclosure, the acquisition module 801 includes a first acquisition unit and a second acquisition unit.
The first acquisition unit is used for acquiring an execution method and execution parameters required by generating an output statement through section-oriented programming. In an embodiment, the first obtaining unit may be configured to perform the operation S501 described above, and is not described herein again.
The second acquisition unit is used for determining an execution log based on the execution method and the execution parameters. In an embodiment, the second obtaining unit may be configured to perform operation S502 described above, which is not described herein again.
According to an embodiment of the present disclosure, the code coverage determination apparatus 800 further includes a first updating module and a second updating module.
The first updating module is used for acquiring a current processing version of the target object. In an embodiment, the first updating module may be configured to perform the operation S601 described above, which is not described herein again.
The second updating module is used for replacing the current processing version with the updated processing version under the condition that the current processing version is determined to be updated, and the updated processing version is used for analyzing the original file. In an embodiment, the second updating module may be configured to perform the operation S602 described above, which is not described herein again.
According to an embodiment of the present disclosure, the code coverage determination apparatus 800 further includes a first change module and a second change module.
The first changing module is used for analyzing the original file by using the current processing version and determining an updated target data structure. In an embodiment, the first changing module may be configured to perform the operation S701 described above, which is not described herein again.
The second change module is configured to determine changed data according to the non-updated target data structure and the updated target data structure. In an embodiment, the second changing module may be configured to perform the operation S702 described above, which is not described herein again.
Fig. 9 schematically shows a block diagram of an electronic device adapted to a code coverage determination method according to an embodiment of the present disclosure.
As shown in fig. 9, an electronic apparatus 900 according to an embodiment of the present disclosure includes a processor 901 which can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)902 or a program loaded from a storage portion 908 into a Random Access Memory (RAM) 903. Processor 901 may comprise, for example, a general purpose microprocessor (e.g., a CPU), an instruction set processor and/or associated chipset, and/or a special purpose microprocessor (e.g., an Application Specific Integrated Circuit (ASIC)), among others. The processor 901 may also include on-board memory for caching purposes. The processor 901 may comprise a single processing unit or a plurality of processing units for performing the different actions of the method flows according to embodiments of the present disclosure.
In the RAM 903, various programs and data necessary for the operation of the electronic apparatus 900 are stored. The processor 901, the ROM 902, and the RAM 903 are connected to each other through a bus 904. The processor 901 performs various operations of the method flows according to the embodiments of the present disclosure by executing programs in the ROM 902 and/or the RAM 903. Note that the programs may also be stored in one or more memories other than the ROM 902 and the RAM 903. The processor 901 may also perform various operations of the method flows according to embodiments of the present disclosure by executing programs stored in the one or more memories.
Electronic device 900 may also include input/output (I/O) interface 905, input/output (I/O) interface 905 also connected to bus 904, according to an embodiment of the present disclosure. The electronic device 900 may also include one or more of the following components connected to the I/O interface 905: an input portion 906 including a keyboard, a mouse, and the like; an output section 907 including components such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 908 including a hard disk and the like; and a communication section 909 including a network interface card such as a LAN card, a modem, or the like. The communication section 909 performs communication processing via a network such as the internet. The drive 910 is also connected to the I/O interface 905 as necessary. A removable medium 911 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 910 as necessary, so that a computer program read out therefrom is mounted into the storage section 908 as necessary.
The present disclosure also provides a computer-readable storage medium, which may be contained in the apparatus/device/system described in the above embodiments; or may exist separately and not be assembled into the device/apparatus/system. The computer-readable storage medium carries one or more programs which, when executed, implement the method according to an embodiment of the disclosure.
According to embodiments of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, which may include, for example but is not limited to: a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. For example, according to embodiments of the present disclosure, a computer-readable storage medium may include the ROM 902 and/or the RAM 903 described above and/or one or more memories other than the ROM 902 and the RAM 903.
Embodiments of the present disclosure also include a computer program product comprising a computer program containing program code for performing the method illustrated in the flow chart. When the computer program product runs in a computer system, the program code is used for causing the computer system to realize the code coverage rate determination method provided by the embodiment of the disclosure.
The computer program performs the above-described functions defined in the system/apparatus of the embodiments of the present disclosure when executed by the processor 901. The systems, apparatuses, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the present disclosure.
In one embodiment, the computer program may be hosted on a tangible storage medium such as an optical storage device, a magnetic storage device, or the like. In another embodiment, the computer program may also be transmitted, distributed in the form of a signal on a network medium, and downloaded and installed through the communication section 909 and/or installed from the removable medium 911. The computer program containing program code may be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the foregoing.
In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 909, and/or installed from the removable medium 911. The computer program, when executed by the processor 901, performs the above-described functions defined in the system of the embodiment of the present disclosure. The systems, devices, apparatuses, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the present disclosure.
In accordance with embodiments of the present disclosure, program code for executing computer programs provided by embodiments of the present disclosure may be written in any combination of one or more programming languages, and in particular, these computer programs may be implemented using high level procedural and/or object oriented programming languages, and/or assembly/machine languages. The programming language includes, but is not limited to, programming languages such as Java, C + +, python, the "C" language, or the like. The program code may execute entirely on the user computing device, partly on the user device, partly on a remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., through the internet using an internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
Those skilled in the art will appreciate that various combinations and/or combinations of features recited in the various embodiments and/or claims of the present disclosure can be made, even if such combinations or combinations are not expressly recited in the present disclosure. In particular, various combinations and/or combinations of the features recited in the various embodiments and/or claims of the present disclosure may be made without departing from the spirit or teaching of the present disclosure. All such combinations and/or associations are within the scope of the present disclosure.

Claims (10)

1. A method of code coverage determination, comprising:
acquiring an original file and an execution log of a target object in the process of generating an output statement, wherein the original file comprises an original code and a code construction label;
analyzing the original file to determine analysis data, wherein the analysis data comprises a target data structure;
determining a simulation statement of the output statement according to the target data structure and the execution log, wherein the simulation statement and the output statement have the same code content; and
and determining the code coverage rate of the original file according to the simulation statement and the analysis data.
2. The method of claim 1, the parsed data further comprising tag location information comprising location information of the code construction tag; wherein the determining the code coverage of the original file according to the simulation statement and the analysis data comprises:
determining target position information according to the label position information, wherein the target position information comprises position information of a code construction label corresponding to the code content of the simulation statement; and
and determining the code coverage rate of the original file according to the target position information and the target data structure.
3. The method of claim 2, wherein determining code coverage of the original file from the target location information and the target data structure comprises:
determining the whole position information of the original code according to the target data structure; and
and determining the code coverage rate of the original file according to the ratio of the target position information to the whole position information.
4. The method of claim 1, wherein said obtaining an execution log of a target object in generating an output statement comprises:
acquiring an execution method and an execution parameter required by generating the output statement through facet-oriented programming; and
based on the execution method and the execution parameters, an execution log is determined.
5. The method of claim 1, further comprising, prior to said parsing the original file:
acquiring a current processing version of the target object; and
and under the condition that the current processing version is determined to be updated, replacing the current processing version with the updated processing version, wherein the updated processing version is used for analyzing the original file.
6. The method of claim 5, further comprising:
analyzing the original file by using the current processing version, and determining an updated target data structure; and
and determining changed data according to the non-updated target data structure and the updated target data structure.
7. A code coverage determination apparatus, comprising:
the system comprises an acquisition module, a storage module and a processing module, wherein the acquisition module is used for acquiring an original file and an execution log of a target object in the process of generating an output statement, and the original file comprises an original code and a code construction label;
the first determining module is used for analyzing the original file and determining analysis data, wherein the analysis data comprises a target data structure;
a second determining module, configured to determine, according to the target data structure and the execution log, a simulated statement of the output statement, where code content of the simulated statement is the same as that of the output statement; and
and the statistical module is used for determining the code coverage rate of the original file according to the simulation statement and the analysis data.
8. An electronic device, comprising:
one or more processors;
a memory to store one or more instructions that,
wherein the one or more instructions, when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-6.
9. A computer readable storage medium having stored thereon executable instructions which, when executed by a processor, cause the processor to carry out the method of any one of claims 1 to 6.
10. A computer program product comprising computer executable instructions for implementing the method of any one of claims 1 to 6 when executed.
CN202210492259.7A 2022-05-07 2022-05-07 Method, device, equipment and storage medium for determining code coverage rate Pending CN114860597A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210492259.7A CN114860597A (en) 2022-05-07 2022-05-07 Method, device, equipment and storage medium for determining code coverage rate

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210492259.7A CN114860597A (en) 2022-05-07 2022-05-07 Method, device, equipment and storage medium for determining code coverage rate

Publications (1)

Publication Number Publication Date
CN114860597A true CN114860597A (en) 2022-08-05

Family

ID=82635553

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210492259.7A Pending CN114860597A (en) 2022-05-07 2022-05-07 Method, device, equipment and storage medium for determining code coverage rate

Country Status (1)

Country Link
CN (1) CN114860597A (en)

Similar Documents

Publication Publication Date Title
US11487539B2 (en) Systems and methods for automating and monitoring software development operations
EP3511836A1 (en) Generation of automated testing scripts by converting manual test cases
US20130339931A1 (en) Application trace replay and simulation systems and methods
CN112527382B (en) Method for deploying pipeline engine system, and method and device for continuous integration
CN112596738B (en) Method and device for determining front-end page to be tested, storage medium and electronic equipment
CN113918864A (en) Website page testing method, testing system, testing device, electronic equipment and medium
US9104573B1 (en) Providing relevant diagnostic information using ontology rules
CN114860597A (en) Method, device, equipment and storage medium for determining code coverage rate
CN111367791B (en) Method, device, medium and electronic equipment for generating test case
CN114036054A (en) Code quality evaluation method, device, equipment, medium and program product
CN113391988A (en) Method and device for losing user retention, electronic equipment and storage medium
CN113487224A (en) Content processing method, apparatus, device, medium, and program product
CN113392623A (en) Service data object generation method, generation device, electronic device and storage medium
CN117271301A (en) Test method, test device, electronic equipment and medium
CN117493208A (en) Software testing method and device, electronic equipment and storage medium
CN114528224A (en) Persistent integration method, apparatus, electronic device, storage medium, and program product
CN115309571A (en) Abnormality detection method, abnormality detection device, electronic apparatus, and storage medium
CN117667642A (en) Code detection method, device, equipment and medium of application program
CN115629983A (en) Test case set generation method, device, equipment and medium
CN113590425A (en) Data processing method, apparatus, device, medium, and program product
CN115687083A (en) Business system testing method and device, electronic equipment and storage medium
CN116243961A (en) Version file processing method and device, electronic equipment and storage medium
CN115687090A (en) Test case generation method, device, equipment and medium
CN115617691A (en) System testing method and device
CN114911770A (en) Method, device, equipment and medium for evaluating database migration

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