WO2020244445A1 - 一种覆盖信息获取方法及装置 - Google Patents
一种覆盖信息获取方法及装置 Download PDFInfo
- Publication number
- WO2020244445A1 WO2020244445A1 PCT/CN2020/093025 CN2020093025W WO2020244445A1 WO 2020244445 A1 WO2020244445 A1 WO 2020244445A1 CN 2020093025 W CN2020093025 W CN 2020093025W WO 2020244445 A1 WO2020244445 A1 WO 2020244445A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- code
- version
- coverage information
- line
- executed
- 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.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/3668—Testing of software
- G06F11/3672—Test management
- G06F11/3676—Test management for coverage analysis
Definitions
- the present invention relates to the field of financial technology (Fintech), and in particular to a method and device for obtaining coverage information.
- the embodiments of the present application provide a method and device for obtaining coverage information, which solves the problem that in the prior art, the amount of calculation is huge when obtaining coverage information, which is prone to errors, and will lead to a long entire process, and the efficiency of obtaining coverage information of different codes between versions Lower question.
- an embodiment of the present application provides a method for obtaining coverage information, including: obtaining first coverage information; the first coverage information is used to indicate whether each line of code corresponding to line numbers 1 to K is executed, where: When a line of code corresponding to line number i is executed in N versions of the code, it means that the line of code corresponding to line number i is executed, otherwise, it means that the line of code corresponding to line number i has not been executed; K is the first version code The number of lines of code included; i is an integer greater than or equal to 1 and less than or equal to K; the first version code is the last submitted code among the N version codes; according to the first version code and the first version code The second version code, which determines the difference code in the first version code that is different from the second version code; the second version code is the code submitted for the first time among the N version codes; according to the difference code And the first coverage information determines the second coverage information; the second coverage information is used to indicate whether each line of code in the difference code is executed in
- the first coverage information is obtained, and the first coverage information indicates whether each line of code corresponding to the line number 1 to K is executed.
- This method does not need to frequently pull each of the N version codes to determine each After submitting the version code for the second time, the difference code directly based on the first version code and the second version code can determine the difference code in the second version code that is different from the first version code, thereby The amount of calculation and error rate are greatly reduced, thereby reducing the entire process time.
- the second coverage information is obtained, that is, each line of code in the difference code is in the first
- the obtaining of the first coverage information includes: obtaining N sets of third coverage information; wherein, each set of third coverage information of the N sets of third coverage information is identical to the N versions One version code in the code uniquely corresponds, and the set of third coverage information is used to indicate whether each line of code in the version code is executed; the N sets of third coverage information are merged into the first coverage information.
- each set of third coverage information and the first coverage information of the N sets of third coverage information is an array, and for the value of any subscript of the array, if the value is the first A preset value indicates that the code corresponding to the subscript has been executed in the version code corresponding to the group of coverage information, and if the value is the second preset value, it indicates that the code corresponding to the subscript is not in the group Is executed in the version code corresponding to the coverage information; the merging of the N groups of third coverage information into the first coverage information includes: according to each subscript in the array of the first coverage information, the The value of the subscript in the N arrays of the N sets of third coverage information is operated according to a preset operation rule, and the operation result is used as the value of the subscript in the array of the first coverage information.
- the determination of a difference code in the first version code that is different from the second version code according to the first version code and the second version code includes: If there is a new code in the first version code relative to the second version code, the newly added code is taken as the first code set; if the first version code has a code block that is deleted relative to the second version code, In the second version of the code, the line of code before the first line of the deleted code block and the line of code after the end line of the deleted code block are taken as the second code set; if the first version of the code exists relative to the second version The code block whose code annotation changes, then the code block whose annotation changes are used as the third code set; the first code set, the third code set, and all the codes in the third code set, As the difference code.
- the determining second coverage information according to the difference code and the first coverage information includes: for each line of code in the difference code, if it is in the first coverage information Indicates that the line of code is executed, then it is determined that the line of code is executed in the first version code; otherwise, it is determined that the line of code is not executed in the first version code; according to each line in the difference code Determine whether the code is executed in the first version code, and determine the second coverage information.
- an embodiment of the present application provides a coverage information obtaining device, including: an obtaining module, configured to obtain first coverage information; and the first coverage information is used to indicate whether each line of code corresponding to line numbers 1 to K is Is executed, where, when a line of code corresponding to line number i is executed in N versions of code, it means that the line of code corresponding to line number i is executed, otherwise, it means that the line of code corresponding to line number i has not been executed; K Is the number of lines of code included in the first version code; i is an integer greater than or equal to 1 and less than or equal to K; the first version code is the last submitted code among the N version codes; the processing module uses According to the first version code and the second version code, determine the difference code in the first version code that is different from the second version code; the second version code is among the N version codes The code submitted for the first time; determine the second coverage information according to the difference code and the first coverage information; the second coverage information is used to indicate whether each line of code in
- the obtaining module is specifically configured to: obtain N sets of third coverage information; wherein, each set of third coverage information of the N sets of third coverage information is compared with the N version codes A version code of is uniquely corresponding, and the set of third coverage information is used to indicate whether each line of code in the version code is executed; the N sets of third coverage information are merged into the first coverage information.
- each set of third coverage information and the first coverage information of the N sets of third coverage information is an array, and for the value of any subscript of the array, if the value is the first A preset value indicates that the code corresponding to the subscript has been executed in the version code corresponding to the group of coverage information, and if the value is the second preset value, it indicates that the code corresponding to the subscript is not in the group Is executed in the version code corresponding to the coverage information; the acquisition module is specifically configured to: according to each subscript in the array of the first coverage information, perform a calculation of the subscript in the N arrays of the N sets of third coverage information The value is calculated according to a preset operation rule, and the operation result is used as the value of the subscript in the array of the first coverage information.
- the processing module is specifically configured to: if the first version code has a new code relative to the second version code, use the newly added code as the first code set; if If the first version code has a code block that is deleted relative to the second version code, then in the second version code, a line of code before the first line of the deleted code block and a line of code after the end line are taken as the first A second code set; if there is a code block in the first version code that changes with respect to the second version code annotation, the code block with the annotation changed is used as the third code set; and the first code The set, the third code set, and all codes in the third code set are used as the difference code.
- the processing module is specifically configured to: for each line of code in the difference code, if the line of code is indicated in the first coverage information, it is determined that the line of code is Is executed in the first version code; otherwise, it is determined that this line of code is not executed in the first version code; according to whether each line of code in the difference code is executed in the first version code, it is determined that all The second coverage information.
- an embodiment of the present application provides a computer device, including:
- At least one processor and,
- a memory communicatively connected with the at least one processor; wherein,
- the memory stores a program executable by the at least one processor, and the program is executed by the at least one processor, so that the at least one processor can execute the coverage information obtaining method as described above.
- an embodiment of the present application provides a non-transitory computer-readable storage medium, the non-transitory computer-readable storage medium stores a computer program, and the computer program is used to make the computer execute the above-mentioned overlay Information acquisition method.
- the embodiments of the present invention also provide a computer program product.
- the computer program product includes a computer program stored on a non-transitory computer-readable storage medium.
- the computer program When the computer program is executed by a computer, the computer program The computer executes the coverage information acquisition method described above.
- FIG. 1 is a schematic diagram of the flow of steps of a method for obtaining coverage information in an embodiment of this application;
- Figure 2 is a system architecture diagram to which a method for obtaining coverage information in an embodiment of the application can be applied;
- FIG. 3 is a flowchart of steps for automatically injecting coverage information agents into a system architecture diagram to which a coverage information acquisition method in an embodiment of the application is applicable;
- FIG. 4 is a schematic structural diagram of an apparatus for obtaining coverage information in an embodiment of this application.
- FIG. 5 is a schematic structural diagram of an electronic device provided by an embodiment of the present invention.
- the coverage information of the difference code between versions that is, the execution of the code in the difference code during the running process of the newer version of the code, such as the number of lines executed by the difference code during the running process, and the number of lines executed by the difference code account for the total lines of the difference code The proportion of the number, etc.
- an embodiment of the present application provides a method for obtaining first coverage information, and a step flowchart of the method is shown in FIG. 1.
- Step 101 Obtain first coverage information.
- the coverage information refers to the information that the code in the program file is executed at runtime. During the execution of a program file, each line of code in the program file may have been executed from the beginning to the end of the execution of the program file, or it may have never been executed. If a line of code is executed, it is said that this line of code is covered, otherwise, it is said that this line of code is not covered.
- the coverage information may be ratio information, line number information, etc. of the code covered in the program file, which is not limited in the embodiment of the present application.
- Blank line when editing the code in the program file, there are some blank lines without code in the program file. The deletion or non-deleting of these blank lines does not affect the operation of the program. These are not considered when obtaining coverage information. Blank line.
- the first coverage information is used to indicate whether each line of code corresponding to line number 1 to K is executed.
- a line of code corresponding to line number i is executed in N version codes, it means that line number i corresponds to A line of code is executed, otherwise, it means that the line of code corresponding to line number i has not been executed;
- K is the number of lines of code included in the first version code;
- i is an integer greater than or equal to 1 and less than or equal to K
- the first A version code is the last submitted code among the N version codes.
- Step 102 According to the first version code and the second version code, determine a difference code in the first version code that is different from the second version code.
- the second version code is the code submitted for the first time among the N version codes.
- Step 103 Determine second coverage information according to the difference code and the first coverage information.
- the second coverage information is used to indicate whether each line of code in the difference code is executed in the first version code.
- step 101 an optional implementation manner for obtaining the first coverage information is as follows:
- each set of third coverage information of the N sets of third coverage information uniquely corresponds to one of the N version codes, and the set of third coverage information is used to indicate Whether each line of code in the version code is executed; combining the N groups of third coverage information into the first coverage information.
- the forms of the N sets of third coverage information and the first coverage information are not limited.
- each set of third coverage information of the N sets of third coverage information the The first coverage information is an array.
- the value of any subscript of the array if the value is the first preset value, it indicates that the code corresponding to the subscript has been executed in the version code corresponding to the set of coverage information . If the value is the second preset value, it indicates that the code corresponding to the subscript is not executed in the version code corresponding to the set of coverage information.
- the N sets of third coverage information can be changed in the following manner Merged into the first coverage information:
- the value of the subscript in the N arrays of the N sets of third coverage information is operated according to a preset operation rule, and the operation result is taken as the first The value of the subscript in an array of coverage information.
- each of the N arrays is a Boolean array
- the first preset value is 0, the second preset value is 1, and the preset operation rule is AND operation.
- the result of the AND operation on N Boolean arrays is also a Boolean array, and this Boolean array is used as the first coverage information.
- the difference code refers to codes that have differences between versions.
- the embodiment of the present application only exemplifies the determination rules of the difference codes, and the determination rules of the difference codes can be adjusted according to specific implementation scenarios. This is not limited, and the specific determination rules as follows:
- the difference code is divided into file difference and file content difference.
- File difference If the file path or file name changes, it means that there is a file difference;
- File content difference The file path and file name are not sent, but the file content is sent.
- files refer to program files.
- the content of the code can be changed by adding or subtracting a series of files, as well as adding or subtracting certain lines of a file, as follows:
- the first version of the code has a new file. For the newly added file, all the code lines of the entire file are included in the difference code. For files whose codes in the first version are reduced compared to the codes in the second version, the reduced codes are not included in the difference code.
- the code line refers to the edit line of the code in the file, such as a blank line, is not regarded as a code line.
- the first case some lines of code are added. For newly added lines of code, they are directly included in the difference code.
- the reduced file lines may affect the function of the upper and lower code lines, so the upper and lower lines of the deleted code block are included in the difference code.
- the code block refers to a group of consecutive lines of code, and the line before the first line of the deleted code block and the line after the end line are included in the difference code.
- the program file of the second version code has lines 1 to 10 in total
- the program file of the first version code has lines 1 to 8
- the program file of the first version code has lines 1 to 6
- the lines are the same as lines 1 to 6 of program file 1 of the second version code
- lines 7 to 8 of program file 1 of the first version code are the same as lines 9 to 10 of program file 1 of the second version code.
- the program file 1 of the first version code is relative to the program file 1 of the second version code.
- the 7th to 8th lines in the program file 1 of the second version code are deleted, which is the deleted code block, so it will be deleted.
- the line before the first line of the code block, which is the 6th line in the program file 1 of the first version code, and the line after the end line of the deleted code block, which is the 7th line in the program file 1 of the first version code Line (corresponding to the 9th line in the program file 1 of the second version code), including the difference code.
- annotations may affect the execution of the annotated code block, so here for the same code block in the same file, if the annotation of the code block occurs Modification, the code line set by the entire code block can be included in the difference code.
- annotations are a mechanism provided in the Java programming language, which allows programmers to write metadata directly while writing code. The annotated code will not be directly affected by the annotation, it will only provide the third system with information about itself for different needs.
- an optional implementation manner for determining the difference code in step 102 is as follows:
- the newly added code is taken as the first code set; if the first version code has a code that is deleted relative to the second version code Code block, in the second version code, a line of code before the first line and a line of code after the end line of the deleted code block are taken as the second code set; if the first version code exists relative to the The code block whose annotations of the second version have changed is used as the third code set; the first code set, the third code set, and the third code set are All codes, as the difference code.
- blank lines in the program file are not included in the difference code.
- the first line in the program file A is 1, the second line is 2, the third line is 3, and the first line in the program file B is 1 , The second line is empty, the third line is 2, and the fourth line is 3. It is considered that there is no difference between program file A and program file B.
- Step 102 obtains the difference code in the first version code that is different from the second version code
- step 103 further obtains the second coverage information according to the difference code obtained in step 102.
- the second coverage information is the information about whether each line of code in the difference code is executed during the execution of the first version of the code.
- step 103 an optional implementation manner for obtaining the second coverage information is as follows:
- the second coverage information is determined according to whether each line of code in the difference code is executed in the first version code.
- the executed code line recorded in the difference code and recorded in the first coverage information is taken as the code line covered in the second coverage information.
- the submission information of git can be automatically collected, the coverage information of the N version codes are merged in advance, the first coverage information is obtained, and the first version code is combined with The difference code of the second version code, so as to quickly obtain the second coverage information.
- Jenkins is deployed on the application machine, and git is deployed on the server.
- the application machine is the machine for project development, and the application machine submits each modified code to the server.
- git commit which is a modification submission in git
- git tag is a snapshot of the git repository, pointing to a pointer to a modification submission
- git commit id which is used in git A unique string that identifies each modification submitted. You can use git commit to record the file differences between each modification submission of Jenkins, and use git tag to point to each commit modification of Jenkins, and use git commit id to identify each commit modification of Jenkins.
- Each module is introduced below:
- the commit id information collection module is a module in the application machine.
- the commit id information collection module will automatically collect the commit id of the current version code and output the result to the application release material package.
- the application is when the program is written Software applications.
- the application release material package is a software package that is used to load when instrumentation is used to add additional functions. In this system architecture, the release material package is Jenkins. After the version is compiled, the version information is output to the specified directory and the specified file name under the application package. Version information includes: git branch name, git commit id corresponding to the build and release of the material package.
- the coverage information agent injection module will automatically access the coverage information agent to avoid misoperation and operation delay caused by manual access. This module monitors the application name of the current application and its corresponding process identification (pid) relationship on the machine where the application is running, and determines whether the application has been connected to the coverage information agent by judging whether the pid of the application exists. Automatically connect the coverage information agent to the application. Among them, pid refers to the process identification number in the operating system, that is, the process identifier. A pid is created every time a program is opened in the operating system. The module will also combine the output results of the commit id information collection module. After accessing the coverage information agent, it will send a heartbeat to the coverage information collection module through the network for data synchronization, and will also send the coverage information collection module the application from startup to the current time. Coverage information over a period of time.
- the coverage information collection module is used to regularly receive the heartbeat information of the coverage agent, determine the online status of the coverage information agent, and also periodically or manually send the coverage information collection instructions to the online coverage information agent to collect application information Overwrite information.
- the collected coverage information is combined with the previously existing coverage information. For example, N groups of third coverage information are combined to obtain the first coverage information accumulated over a period of time and store it on a local disk.
- the coverage information agent injection module provided in this embodiment of the application automatically injects the step flow chart of the coverage information agent, taking Application A as an example.
- Step 301 Obtain pid_1 of application A through a command called Process Status (ps).
- the ps command is used to list the processes currently running in the system.
- the ps command lists the snapshots of the current processes, which are the processes at the moment when the ps command is executed.
- Step 302 Request the coverage information collection module to obtain the pid_2 reported by the application A.
- Step 303 Determine whether pid1 of application A does not exist or pid_1 and pid_2 are not equal.
- step 304 If yes, go to step 304.
- Step 304 Inject the coverage information agent.
- Step 304 uses the application program interface of instrumentation provided by java to inject the coverage proxy.
- Step 305 Report pid_1.
- Difference code comparison module When receiving an instruction to generate coverage information, the difference code comparison module will obtain the latest tag and the version code corresponding to the current commit id from git through the network, and compare and obtain the difference files between the two and between the files The difference line, output the difference result of the corresponding code line.
- the instruction that triggers the source code comparison can be automatic trigger or manual trigger.
- the coverage information output module is used to combine the first coverage information and the difference code to generate second coverage information.
- the first coverage information is obtained, and the first coverage information indicates whether each line of code corresponding to the line number 1 to K is executed.
- This method does not need to frequently pull each of the N version codes to determine each After submitting the version code for the second time, the difference code directly based on the first version code and the second version code can determine the difference code in the second version code that is different from the first version code, thereby The amount of calculation and error rate are greatly reduced, thereby reducing the entire process time.
- the second coverage information is obtained, that is, each line of code in the difference code is in the first
- FIG. 4 it is a schematic structural diagram of an apparatus for obtaining coverage information in an embodiment of this application.
- An embodiment of the present application provides an apparatus for obtaining coverage information, including: an obtaining module 401, configured to obtain first coverage information; the first coverage information is used to indicate whether each line of code corresponding to line numbers 1 to K is executed, Among them, when a line of code corresponding to line number i is executed in N versions of code, it means that the line of code corresponding to line number i is executed, otherwise, it means that the line of code corresponding to line number i has not been executed; K is the first The number of lines of code included in the version code; i is an integer greater than or equal to 1 and less than or equal to K; the first version code is the last submitted code among the N version codes; the processing module 402 is configured to The first version code and the second version code determine the difference code of the first version code that is different from the second version code; the second version code is the first submission among the N version codes The code; according to the difference code and the first coverage information, determine second coverage information; the second coverage information is used to indicate whether each line of code in the difference code is executed
- the obtaining module 401 is specifically configured to: obtain N sets of third coverage information; wherein, each set of third coverage information of the N sets of third coverage information is associated with the N version codes One of the version codes in is uniquely corresponding, and the set of third coverage information is used to indicate whether each line of code in the version code is executed; the N sets of third coverage information are merged into the first coverage information.
- each set of third coverage information and the first coverage information of the N sets of third coverage information is an array, and for the value of any subscript of the array, if the value is the first A preset value indicates that the code corresponding to the subscript has been executed in the version code corresponding to the group of coverage information, and if the value is the second preset value, it indicates that the code corresponding to the subscript is not in the group Is executed in the version code corresponding to the coverage information; the acquiring module 401 is specifically configured to: according to each subscript in the array of the first coverage information, perform the following operations in the N arrays of the N sets of third coverage information. The value of the subscript is calculated according to a preset operation rule, and the result of the operation is used as the value of the subscript in the array of the first coverage information.
- the processing module 402 is specifically configured to: if the first version code has a new code relative to the second version code, use the newly added code as the first code set; If the first version code has a code block that is deleted relative to the second version code, then in the second version code, a line of code before the first line of the deleted code block and a line of code after the end line are taken as A second code set; if there is a code block in the first version code that changes with respect to the second version code annotation, the code block with the annotation changed is taken as the third code set; The code set, the third code set, and all codes in the third code set are used as the difference code.
- the processing module 402 is specifically configured to: for each line of code in the difference code, if the line of code is indicated in the first coverage information, determine that the line of code is Is executed in the first version code; otherwise, it is determined that this line of code is not executed in the first version code; according to whether each line of code in the difference code is executed in the first version code, it is determined The second coverage information.
- the present invention also provides a computer device, as shown in FIG. 5, including:
- processor 501 Including a processor 501, a memory 502, a transceiver 503, and a bus interface 504, wherein the processor 501, the memory 502 and the transceiver 503 are connected through the bus interface 504;
- the processor 501 is configured to read a program in the memory 502 and execute the voting method in the above-mentioned blockchain, and the method includes:
- the first coverage information is used to indicate whether each line of code corresponding to line number 1 to K is executed, wherein, when a line of code corresponding to line number i is executed in N version codes, It means that the line of code corresponding to line number i is executed, otherwise, it means that the line of code corresponding to line number i is not executed; K is the number of lines of code included in the first version code; i is greater than or equal to 1 and less than or equal to K An integer of; the first version code is the last submitted code among the N version codes;
- the first version code and the second version code determine the difference code in the first version code that is different from the second version code; the second version code is the first in the N version codes Submitted code;
- the second coverage information is used to indicate whether each line of code in the difference code is executed in the first version code.
- the processor 501 may be a central processing unit (CPU for short), a network processor (NP for short), or a combination of CPU and NP. It can also be a hardware chip.
- the aforementioned hardware chip may be an application-specific integrated circuit (ASIC for short), a programmable logic device (PLD for short), or a combination thereof.
- ASIC application-specific integrated circuit
- PLD programmable logic device
- the above-mentioned PLD can be a complex programmable logic device (complex programmable logic device, CPLD), a field-programmable gate array (FPGA), a generic array logic (generic array logic, GAL), or any of them combination.
- the memory 502 is configured to store one or more executable programs, and can store data used by the processor 501 when performing operations.
- the program may include program code, and the program code includes computer operation instructions.
- the memory 502 may include a volatile memory (volatile memory), such as random-access memory (RAM for short); the memory 502 may also include a non-volatile memory (non-volatile memory), such as flash memory ( flash memory, hard disk drive (HDD for short) or solid-state drive (SSD for short); the memory 502 may also include a combination of the foregoing types of memory.
- volatile memory volatile memory
- RAM random-access memory
- non-volatile memory non-volatile memory
- flash memory flash memory, hard disk drive (HDD for short) or solid-state drive (SSD for short
- SSD solid-state drive
- the memory 502 stores the following elements, executable modules or data structures, or their subsets, or their extended sets:
- Operating instructions including various operating instructions, used to implement various operations.
- Operating system including various system programs, used to implement various basic services and process hardware-based tasks.
- the bus interface 504 may be a wired communication access port, a wireless bus interface or a combination thereof, where the wired bus interface may be, for example, an Ethernet interface.
- the Ethernet interface can be an optical interface, an electrical interface or a combination thereof.
- the wireless bus interface may be a WLAN interface.
- the embodiments of the present invention also provide a non-transitory computer-readable storage medium, the non-transitory computer-readable storage medium stores a computer program, and the computer program is used to make the computer execute the above-mentioned coverage information Obtaining method.
- embodiments of the present invention also provide a computer program product.
- the computer program product includes a computer program stored on a non-transitory computer-readable storage medium.
- the computer program When the computer program is executed by a computer, the computer program The computer executes the coverage information obtaining method.
- the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, this application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, optical storage, etc.) containing computer-usable program codes.
- a computer-usable storage media including but not limited to disk storage, optical storage, etc.
- These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device.
- the device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
- Debugging And Monitoring (AREA)
Abstract
Description
Claims (13)
- 一种覆盖信息获取方法,其特征在于,包括:获取第一覆盖信息;所述第一覆盖信息用于指示行号为1至K对应的每行代码是否被执行,其中,当行号i对应的一行代码,在N个版本代码中均被执行,则表示行号i对应的一行代码被执行,否则,表示行号i对应的一行代码未被执行;K为第一版本代码包括的代码的行数;i为大于或等于1且小于或等于K的整数;所述第一版本代码为所述N个版本代码中最后一次提交的代码;根据所述第一版本代码与第二版本代码,确定所述第一版本代码中,与所述第二版本代码存在差异的差异代码;所述第二版本代码为所述N个版本代码中首次提交的代码;根据所述差异代码以及所述第一覆盖信息,确定第二覆盖信息;所述第二覆盖信息用于指示所述差异代码中每行代码在所述第一版本代码中是否被执行。
- 如权利要求1所述的方法,其特征在于,所述获取第一覆盖信息,包括:获取N组第三覆盖信息;其中,所述N组第三覆盖信息的每组第三覆盖信息,与所述N个版本代码中的一个版本代码唯一对应,该组第三覆盖信息用于指示该版本代码中每行代码是否被执行;将所述N组第三覆盖信息合并为所述第一覆盖信息。
- 如权利要求2所述的方法,其特征在于,所述N组第三覆盖信息的每组第三覆盖信息、所述第一覆盖信息均为一个数组,对于该数组任一下标的取值,若该取值为第一预设值,则指示该下标对应的代码已在该组覆盖信息对应的版本代码中被执行,若该取值为第二预设值,则指示该下标对应的代码未在该组覆盖信息对应的版本代码中被执行;所述将所述N组第三覆盖信息合并为所述第一覆盖信息,包括:按照所述第一覆盖信息的数组中每个下标,对所述N组第三覆盖信息的N个数组中该下标的取值按预设运算规则做运算,将该运算结果作为所述第一覆盖信息的数组中该下标的取值。
- 如权利要求1-3任一所述的方法,其特征在于,所述根据所述第一版本代码与第二版本代码,确定所述第一版本代码中,与所述第二版本代码存在差异的差异代码,包括:若所述第一版本代码存在相对所述第二版本代码的新增代码,则将所述新增代码作为第一代码集合;若所述第一版本代码存在相对所述第二版本代码删除的代码块,则将在所述第二版本代码中,删除的代码块首行之前的一行代码和末尾行之后的一行代码,作为第二代码集合;若所述第一版本代码中存在相对所述第二版本代码注解发生变化的代码块,则将所述注解发生变化的代码块,作为第三代码集合;将所述第一代码集合、所述第三代码集合以及所述第三代码集合中所有代码,作为所述差异代码。
- 如权利要求1-3任一所述的方法,其特征在于,所述根据所述差异代码以及所述第一覆盖信息,确定第二覆盖信息,包括:针对所述差异代码中每一行代码,若在所述第一覆盖信息中指示了该行代码被执行,则确定该行代码在所述第一版本代码中被执行;否则,确定该行代码在所述第一版本代码中未被执行;根据所述差异代码中每一行代码在所述第一版本代码中是否被执行,确定所述第二覆盖信息。
- 一种覆盖信息获取装置,其特征在于,包括:获取模块,用于获取第一覆盖信息;所述第一覆盖信息用于指示行号为1至K对应的每行代码是否被执行,其中,当行号i对应的一行代码,在N个版本代码中均被执行,则表示行号i对应的一行代码被执行,否则,表示行号i对应的一行代码未被执行;K为第一版本代码包括的代码的行数;i为大于或等于1且小于或等于K的整数;所述第一版本代码为所述N个版本代码中最后一次提交的代码;处理模块,用于根据所述第一版本代码与第二版本代码,确定所述第一版本代码中,与所述第二版本代码存在差异的差异代码;所述第二版本代码为所述N个版本代码中首次提交的代码;根据所述差异代码以及所述第一覆盖信息,确定第二覆盖信息;所述第二覆盖信息用于指示所述差异代码中每行代码在所述第一版本代码中是否被执行。
- 如权利要求6所述的装置,其特征在于,所述获取模块具体用于:获取N组第三覆盖信息;其中,所述N组第三覆盖信息的每组第三覆盖信息,与所述N个版本代码中的一个版本代码唯一对应,该组第三覆盖信息用于指示该版本代码中每行代码是否被执行;将所述N组第三覆盖信息合并为所述第一覆盖信息。
- 如权利要求7所述的装置,其特征在于,所述N组第三覆盖信息的每组第三覆盖信息、所述第一覆盖信息均为一个数组,对于该数组任一下标的取值,若该取值为第一预设值,则指示该下标对应的代码已在该组覆盖信息对应的版本代码中被执行,若该取值为第二预设值,则指示该下标对应的代码未在该组覆盖信息对应的版本代码中被执行;所述获取模块具体用于:按照所述第一覆盖信息的数组中每个下标,对所述N组第三覆盖信息的N个数组中该下标的取值按预设运算规则做运算,将该运算结果作为所述第一覆盖信息的数组中该下标的取值。
- 如权利要求6-8任一所述的装置,其特征在于,所述处理模块具体用于:若所述第一版本代码存在相对所述第二版本代码的新增代码,则将所述新增代码作为第一代码集合;若所述第一版本代码存在相对所述第二版本代码删除的代码块,则将在所述第二版本代码中,删除的代码块首行之前的一行代码和末尾行之后的一行代码,作为第二代码集合;若所述第一版本代码中存在相对所述第二版本代码注解发生变化的代码块,则将所述注解发生变化的代码块,作为第三代码集合;将所述第一代码集合、所述第三代码集合以及所述第三代码集合中所有代码,作为所述差异代码。
- 如权利要求6-8任一所述的装置,其特征在于,所述处理模块具体用于:针对所述差异代码中每一行代码,若在所述第一覆盖信息中指示了该行代码被执行,则确定该行代码在所述第一版本代码中被执行;否则,确定该行代码在所述第一版本代码中未被执行;根据所述差异代码中每一行代码在所述第一版本代码中是否被执行,确定所述第二覆盖信息。
- 一种计算机设备,其特征在于,包括:至少一个处理器;以及,与所述至少一个处理器通信连接的存储器;其中,所述存储器存储有可被所述至少一个处理器执行的程序,所述程序被所述至少一个处理器执行,以使所述至少一个处理器能够执行权利要求1-5任一所述的方法。
- 一种非暂态计算机可读存储介质,其特征在于,所述非暂态计算机 可读存储介质存储计算机程序,所述计算机程序用于使所述计算机执行权利要求1-5任一所述方法。
- 一种计算机程序产品,其特征在于,所述计算机程序产品包括存储在非暂态计算机可读存储介质上的计算机程序,当所述计算机程序被计算机执行时,使所述计算机执行权利要求1-5任一所述方法。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201910477036.1A CN110262966B (zh) | 2019-06-03 | 2019-06-03 | 一种覆盖信息获取方法及装置 |
| CN201910477036.1 | 2019-06-03 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2020244445A1 true WO2020244445A1 (zh) | 2020-12-10 |
Family
ID=67916534
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2020/093025 Ceased WO2020244445A1 (zh) | 2019-06-03 | 2020-05-28 | 一种覆盖信息获取方法及装置 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN110262966B (zh) |
| WO (1) | WO2020244445A1 (zh) |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113590173A (zh) * | 2021-06-25 | 2021-11-02 | 济南浪潮数据技术有限公司 | 一种代码统计方法、系统、设备以及介质 |
| CN115794606A (zh) * | 2022-10-25 | 2023-03-14 | 平安银行股份有限公司 | 一种代码覆盖率确定方法、装置、设备和可读存储介质 |
| CN119807041A (zh) * | 2024-12-17 | 2025-04-11 | 上海金融期货信息技术有限公司 | 一种面向发布的多维度集成测试质量实时观测方法和系统 |
Families Citing this family (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110262966B (zh) * | 2019-06-03 | 2024-10-29 | 深圳前海微众银行股份有限公司 | 一种覆盖信息获取方法及装置 |
| CN113377431B (zh) * | 2020-02-25 | 2025-03-25 | 华为云计算技术有限公司 | 一种代码处理方法、装置、设备及介质 |
| CN112181430B (zh) * | 2020-09-29 | 2024-06-14 | 北京云族佳科技有限公司 | 代码变更统计方法、装置、电子设备及存储介质 |
| CN114860296A (zh) * | 2022-03-22 | 2022-08-05 | 北京快乐茄信息技术有限公司 | 软件持续集成方法、装置和存储介质 |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN105608011A (zh) * | 2016-03-01 | 2016-05-25 | 网易(杭州)网络有限公司 | 代码测试覆盖率统计结果的确定方法及装置 |
| US20170132109A1 (en) * | 2015-11-11 | 2017-05-11 | International Business Machines Corporation | Automatic collection and presentation of runtime data semantics |
| CN107957956A (zh) * | 2017-12-26 | 2018-04-24 | 广州品唯软件有限公司 | 软件差异覆盖率的测试方法、装置及可读存储介质 |
| CN108519945A (zh) * | 2018-03-21 | 2018-09-11 | 腾讯科技(深圳)有限公司 | 覆盖率测试方法、装置及存储设备 |
| CN108829580A (zh) * | 2018-05-07 | 2018-11-16 | 百度在线网络技术(北京)有限公司 | 多版本测试数据处理方法、装置、设备及存储介质 |
| CN110262966A (zh) * | 2019-06-03 | 2019-09-20 | 深圳前海微众银行股份有限公司 | 一种覆盖信息获取方法及装置 |
Family Cites Families (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN104317706B (zh) * | 2014-10-15 | 2017-08-25 | 中国科学院软件研究所 | 一种基于预运算的程序变异软件错误定位方法 |
| US9639453B2 (en) * | 2015-03-04 | 2017-05-02 | Vmware, Inc. | Method and system for determining functional tests to execute based on code coverage |
-
2019
- 2019-06-03 CN CN201910477036.1A patent/CN110262966B/zh active Active
-
2020
- 2020-05-28 WO PCT/CN2020/093025 patent/WO2020244445A1/zh not_active Ceased
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20170132109A1 (en) * | 2015-11-11 | 2017-05-11 | International Business Machines Corporation | Automatic collection and presentation of runtime data semantics |
| CN105608011A (zh) * | 2016-03-01 | 2016-05-25 | 网易(杭州)网络有限公司 | 代码测试覆盖率统计结果的确定方法及装置 |
| CN107957956A (zh) * | 2017-12-26 | 2018-04-24 | 广州品唯软件有限公司 | 软件差异覆盖率的测试方法、装置及可读存储介质 |
| CN108519945A (zh) * | 2018-03-21 | 2018-09-11 | 腾讯科技(深圳)有限公司 | 覆盖率测试方法、装置及存储设备 |
| CN108829580A (zh) * | 2018-05-07 | 2018-11-16 | 百度在线网络技术(北京)有限公司 | 多版本测试数据处理方法、装置、设备及存储介质 |
| CN110262966A (zh) * | 2019-06-03 | 2019-09-20 | 深圳前海微众银行股份有限公司 | 一种覆盖信息获取方法及装置 |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113590173A (zh) * | 2021-06-25 | 2021-11-02 | 济南浪潮数据技术有限公司 | 一种代码统计方法、系统、设备以及介质 |
| CN113590173B (zh) * | 2021-06-25 | 2025-05-27 | 济南浪潮数据技术有限公司 | 一种代码统计方法、系统、设备以及介质 |
| CN115794606A (zh) * | 2022-10-25 | 2023-03-14 | 平安银行股份有限公司 | 一种代码覆盖率确定方法、装置、设备和可读存储介质 |
| CN119807041A (zh) * | 2024-12-17 | 2025-04-11 | 上海金融期货信息技术有限公司 | 一种面向发布的多维度集成测试质量实时观测方法和系统 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN110262966A (zh) | 2019-09-20 |
| CN110262966B (zh) | 2024-10-29 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2020244445A1 (zh) | 一种覆盖信息获取方法及装置 | |
| CN108932282B (zh) | 一种数据库迁移方法、装置和存储介质 | |
| CN102323945B (zh) | 一种基于sql的数据库管理方法和装置 | |
| CN104484269A (zh) | 一种自动生成测试脚本的方法 | |
| CN107665219B (zh) | 一种日志管理方法及装置 | |
| CN112965939A (zh) | 一种文件合并方法、装置和设备 | |
| CN108319711A (zh) | 数据库的事务一致性测试方法、装置、存储介质及设备 | |
| CN109271199B (zh) | 一种用于数据库持续集成与脚本文件管理的方法及系统 | |
| US20250199945A1 (en) | Parallel software testing based on annotations | |
| CN114896335B (zh) | 一种数据库的数据转储方法及系统 | |
| CN109710698A (zh) | 一种数据汇聚方法、装置、电子设备及介质 | |
| US10592400B2 (en) | System and method for creating variants in a test database during various test stages | |
| JP6293709B2 (ja) | ストレージシステムおよびストレージシステム用プログラム | |
| CN110543485B (zh) | 一种基于快照的区块链预约归档方法 | |
| EP4109287B1 (en) | A collaborative system and method for multi-user data management | |
| US20250321949A1 (en) | Extensive-dimensional solutions for data lineage | |
| US9442698B2 (en) | Migration between model elements of different types in a modeling environment | |
| CN117076431B (zh) | 一种用于系统升级数据迁移的方法 | |
| CN119988444A (zh) | 数据查询方法、系统、设备及存储介质 | |
| US10706012B2 (en) | File creation | |
| CN118643096A (zh) | 数据同步方法、装置、设备及存储介质 | |
| US8296336B2 (en) | Techniques for efficient dataloads into partitioned tables using swap tables | |
| CN113326268A (zh) | 一种数据写入、读取方法及装置 | |
| CN119806409B (zh) | 数据存储方法、装置、终端设备及计算机可读存储介质 | |
| CN114741666B (zh) | 一种权限控制方法及相关装置 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 20818811 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 20818811 Country of ref document: EP Kind code of ref document: A1 |
|
| 32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 18/03/2022) |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 20818811 Country of ref document: EP Kind code of ref document: A1 |