[go: up one dir, main page]

CN114647570B - Code increment coverage statistics method, device, computer equipment and storage medium - Google Patents

Code increment coverage statistics method, device, computer equipment and storage medium Download PDF

Info

Publication number
CN114647570B
CN114647570B CN202011521515.8A CN202011521515A CN114647570B CN 114647570 B CN114647570 B CN 114647570B CN 202011521515 A CN202011521515 A CN 202011521515A CN 114647570 B CN114647570 B CN 114647570B
Authority
CN
China
Prior art keywords
code
information
function
file
project
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.)
Active
Application number
CN202011521515.8A
Other languages
Chinese (zh)
Other versions
CN114647570A (en
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.)
SF Technology Co Ltd
Original Assignee
SF Technology Co Ltd
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 SF Technology Co Ltd filed Critical SF Technology Co Ltd
Priority to CN202011521515.8A priority Critical patent/CN114647570B/en
Publication of CN114647570A publication Critical patent/CN114647570A/en
Application granted granted Critical
Publication of CN114647570B publication Critical patent/CN114647570B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3672Test management
    • G06F11/3676Test management for coverage analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Stored Programmes (AREA)

Abstract

The application relates to a code increment coverage statistics method, a device, computer equipment and a storage medium. The method comprises the following steps: receiving a code increment coverage rate statistical request, wherein the code increment coverage rate statistical request carries a project system code; acquiring project source codes and project change information according to project system codes, and acquiring a full code coverage rate file and a code compiling file according to the project source codes; determining a compiled file change function corresponding to the project change information according to the project change information, the project source code and the code compiled file; inquiring a code compiling file according to the compiling file changing function, and determining changing function calling information; and screening the full code coverage rate file according to the change function call information to obtain the code increment coverage rate information. The method can improve the statistics efficiency of the increment coverage rate of the codes.

Description

Code increment coverage statistics method, device, computer equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and apparatus for counting coverage of code increment, a computer device, and a storage medium.
Background
With the development of computer technology, the iteration of the project version is more and more frequent, and a code testing technology is developed, wherein the code testing technology can be used for confirming whether new errors are introduced or other code errors are caused by performing testing on the project version iteration after the project version iteration.
In the conventional technology, in order to obtain higher code increment coverage, a code test method is commonly adopted as a full-function regression test, namely, tests are carried out on all functions which can be realized by project codes, and the code increment coverage is counted after the test is completed.
However, although the full-function regression test can obtain higher code increment coverage, the full-function regression test has the problem of low code increment coverage statistics efficiency due to long test time and complicated coverage statistics.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a code increment coverage statistics method, apparatus, computer device, and storage medium that can improve the efficiency of code increment coverage statistics.
A method of code delta coverage statistics, the method comprising:
receiving a code increment coverage rate statistical request, wherein the code increment coverage rate statistical request carries a project system code;
Acquiring project source codes and project change information according to project system codes, and acquiring a full code coverage rate file and a code compiling file according to the project source codes;
Determining a compiled file change function corresponding to the project change information according to the project change information, the project source code and the code compiled file;
inquiring a code compiling file according to the compiling file changing function, and determining changing function calling information;
and screening the full code coverage rate file according to the change function call information to obtain the code increment coverage rate information.
In one embodiment, obtaining a full code coverage file and a code compilation file from project source code includes:
compiling the project source codes to obtain code compiling files, and obtaining test cases corresponding to the code increment coverage rate statistical requests;
And executing the test case according to the code compiling file, and calling a code coverage rate statistics tool to obtain a full code coverage rate file.
In one embodiment, determining a compiled file change function corresponding to project change information from project change information, project source code, and a code compiled file includes:
Comparing the project change information with the project source codes, and determining a source code change function corresponding to the project change information;
and traversing the code compiling file according to the source code changing function, and determining the compiling file changing function corresponding to the project changing information.
In one embodiment, comparing the project change information to the project source code, determining a source code change function corresponding to the project change information includes:
determining a project change file and a change code segment according to the project change information;
and comparing the project source codes according to the project change file and the change code segment, and determining a source code change function corresponding to the project change information.
In one embodiment, querying a code compilation file from a compilation file modification function, determining modification function call information includes:
according to the compiled file change function, inquiring the code compiled file, and determining related change function class and related change function interface;
Acquiring first function information corresponding to a related change function class and second function information corresponding to a related change function interface from a code compiling file;
Determining calling function information for calling the compiled file change function according to the first function information and the second function information;
and obtaining change function calling information according to the calling function information.
In one embodiment, after determining the change function call information, the method further comprises:
determining a corresponding external interface according to the change function call information;
And displaying the external interface.
In one embodiment, filtering the full code coverage file according to the change function call information to obtain the code delta coverage information includes:
traversing the full code coverage rate file according to calling function information in the change function calling information, and determining a calling function code coverage rate file corresponding to the calling function information;
And converting the calling function code coverage rate file to obtain code increment coverage rate information.
A code delta coverage statistics apparatus, the apparatus comprising:
The receiving module is used for receiving a code increment coverage rate statistical request, wherein the code increment coverage rate statistical request carries a project system code;
The acquisition module is used for acquiring project source codes and project change information according to project system codes and acquiring a full code coverage rate file and a code compiling file according to the project source codes;
the processing module is used for determining a compiled file change function corresponding to the project change information according to the project change information, the project source code and the code compiled file;
the query module is used for querying the code compiling file according to the compiling file changing function and determining changing function calling information;
And the screening module is used for screening the full-quantity code coverage rate file according to the change function call information to obtain the code increment coverage rate information.
A computer device comprising a memory storing a computer program and a processor which when executing the computer program performs the steps of:
receiving a code increment coverage rate statistical request, wherein the code increment coverage rate statistical request carries a project system code;
Acquiring project source codes and project change information according to project system codes, and acquiring a full code coverage rate file and a code compiling file according to the project source codes;
Determining a compiled file change function corresponding to the project change information according to the project change information, the project source code and the code compiled file;
inquiring a code compiling file according to the compiling file changing function, and determining changing function calling information;
and screening the full code coverage rate file according to the change function call information to obtain the code increment coverage rate information.
A computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of:
receiving a code increment coverage rate statistical request, wherein the code increment coverage rate statistical request carries a project system code;
Acquiring project source codes and project change information according to project system codes, and acquiring a full code coverage rate file and a code compiling file according to the project source codes;
Determining a compiled file change function corresponding to the project change information according to the project change information, the project source code and the code compiled file;
inquiring a code compiling file according to the compiling file changing function, and determining changing function calling information;
and screening the full code coverage rate file according to the change function call information to obtain the code increment coverage rate information.
According to the code increment coverage statistics method, the code increment coverage statistics device, the computer equipment and the storage medium, after a code increment coverage statistics request is received, the acquisition of the project source code and the project change information can be realized according to the project system code carried in the code increment coverage statistics request, so that a full-quantity code coverage file and a code compiling file can be obtained according to the project source code, a compiling file change function corresponding to the project change information is determined according to the project change information, the project source code and the code compiling file, the compiling file change function is used for inquiring the code compiling file, change function calling information is determined, the full-quantity code coverage file is screened by using the change function calling information, the code increment coverage information is obtained, the whole process can be realized without carrying out a full-function regression test, and the code increment coverage statistics efficiency can be improved.
Drawings
FIG. 1 is a flow chart of a method of code delta coverage statistics in one embodiment;
FIG. 2 is a flowchart of a method for counting code increment coverage in another embodiment;
FIG. 3 is a flowchart of a method for counting code increment coverage in yet another embodiment;
FIG. 4 is a block diagram of a code delta coverage statistics apparatus in one embodiment;
Fig. 5 is an internal structural diagram of a computer device in one embodiment.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
In one embodiment, as shown in fig. 1, a method for counting code increment coverage is provided, and this embodiment is applied to a terminal for illustration by using the method, it can be understood that the method can also be applied to a server, and can also be applied to a system including the terminal and the server, and implemented through interaction between the terminal and the server. In this embodiment, the method includes the steps of:
step 102, receiving a code increment coverage rate statistical request, wherein the code increment coverage rate statistical request carries a project system code.
After the project version iterates, the user initiates a request for counting the code increment coverage rate in the project, and the code increment refers to a code segment with update in the project version iterates, namely an update code. The project system codes are used for uniquely representing project versions, and the codes of different project versions are different. For example, the project system code may specifically be a character string of a preset length.
Specifically, after the project version iterates, a user initiates a code increment coverage statistics request to the terminal, and the terminal receives the code increment coverage statistics request to further perform code increment coverage statistics.
And 104, acquiring project source codes and project change information according to project system codes, and acquiring a full code coverage rate file and a code compiling file according to the project source codes.
The source code refers to an uncompiled text file written according to a certain programming language specification, and is a series of human-readable computer language instructions. The project change information refers to code information updated when project version iteration is performed, and the project change information comprises a project change file and a change code segment, wherein the project change file refers to a file related to code change, and the change code segment is used for representing the position of the updated code segment in the project change file. For example, the change code segment may specifically refer to the number of code lines of the update code in the project change file. The full code coverage file refers to the coverage file of all codes in the project, where all codes include updated codes and non-updated codes at the iteration of the project version. The code compiling file is a project code file obtained after compiling the project source code.
Specifically, the terminal can pull the project source code from a preset code warehouse according to project system codes, acquire project change information, compile the project source code in a preset configuration environment after the project source code is obtained, and obtain a code compiling file, and after the code compiling file is obtained, obtain a full code coverage rate file by executing test cases according to the code compiling file. The preset configuration environment can be set automatically as required, is mainly used for configuring project source codes, introducing functions, such as instrumentation, and the like, and test cases executable by code compiling files can be set automatically as required. Furthermore, in the preset code warehouse, each item version has start and stop time and version information, the item change information corresponding to each item version is correspondingly stored, and the terminal can pull the item source code from the preset code warehouse according to the item system codes and acquire the item change information.
And step 106, determining a compiled file change function corresponding to the project change information according to the project change information, the project source code and the code compiled file.
The compiled file change function is a function having a change in the code compiled file, and corresponds to the item change information.
Specifically, the terminal compares the project change information with the project source code, determines a source code change function with a change in the project source code, and then traverses the code compiling file according to the source code change function to determine a compiling file change function with a change in the code compiling file. Here, since the code compiling file is obtained by compiling the project source code, the file names and the function names in the code compiling file are in one-to-one correspondence with the file names and the function names of the project source code, and therefore after the source code changing function is determined, the compiled file changing function can be obtained by directly traversing the code compiling file according to the source code changing function.
And step 108, inquiring the code compiling file according to the compiling file changing function, and determining changing function calling information.
The change function calling information refers to called information of the compiled file change function in the code compiled file, and comprises calling function information of all the called compiled file change functions.
Specifically, the terminal queries the code compiling file according to the function changing compiling file, can determine the class and the interface related to the changing function, and can further acquire the function information included in the class and the interface related to the changing function from the code compiling file, and can determine the calling information of the changing function according to the function information.
And step 110, screening the full-quantity code coverage rate file according to the change function call information to obtain the code increment coverage rate information.
The code increment coverage information refers to coverage statistics corresponding to updated codes in project version iterations.
Specifically, the change function call information includes call function information of all call compiled file change functions, and all code coverage information related to the compiled file change functions is code increment coverage information, so that the terminal can obtain call function code coverage files corresponding to the call function information by traversing the full code coverage files according to the call function information, and further obtain code increment coverage information according to the call function code coverage files.
According to the code increment coverage statistics method, after a code increment coverage statistics request is received, the project source codes and project change information can be obtained according to project system codes carried in the code increment coverage statistics request, so that full-quantity code coverage files and code compiling files can be obtained according to the project source codes, compiling file change functions corresponding to the project change information are determined according to the project change information, the project source codes and the code compiling files, further, the compiling file change function compiling files can be utilized to inquire the code change function compiling files, change function calling information is determined, the full-quantity code coverage files are screened by utilizing the change function calling information, the code increment coverage information is obtained, the whole process can be achieved without carrying out full-function regression tests, and the code increment coverage statistics efficiency can be improved.
In one embodiment, obtaining a full code coverage file and a code compilation file from project source code includes:
compiling the project source codes to obtain code compiling files, and obtaining test cases corresponding to the code increment coverage rate statistical requests;
And executing the test case according to the code compiling file, and calling a code coverage rate statistics tool to obtain a full code coverage rate file.
The test cases refer to the cases for testing the functions realized by the project, and the test cases comprise the test cases corresponding to the updated codes and the test cases corresponding to the non-updated codes.
Specifically, a configuration environment is preset by a terminal, a file instrumentation function is introduced, project source codes are compiled in the preset configuration environment, so that instrumentation pointers are automatically inserted into the instrumentation function to obtain code compiling files, test cases corresponding to code increment coverage statistics requests are obtained from a preset database, the code compiling files are operated, the test cases are executed, and a code coverage statistics tool is called to conduct statistics on code coverage according to the inserted instrumentation pointers to obtain a full code coverage file.
In this embodiment, each probe pointer is a boolean variable (true indicates execution and false indicates no execution), the result of the probe pointer is changed when the code compiling file runs, when the code segment is executed, the probe pointer at the position corresponding to the code segment is wire, when the code segment is not executed, the probe pointer at the position corresponding to the code segment is false, therefore, the execution condition of the code can be detected by the result of the probe pointer, the behavior of the original code is not changed in this way, the execution coverage condition of each test case can be recorded by the probe pointer, and the full code coverage file can be obtained by carrying out different dimension statistics on the access records of the probe pointer.
For example, in this embodiment, the probe pointer may be a java probe, the code coverage rate statistics tool may be JavaAgent, the terminal presets a configuration environment, introduces JavaAgent and a file instrumentation function, compiles project source codes in the preset configuration environment, so that the instrumentation function automatically inserts the java probe to obtain a code compiling file, obtains a test case corresponding to the code increment coverage rate statistics request from a preset database, runs the code compiling file, executes the test case, and invokes JavaAgent to count the code coverage rate according to the inserted java probe, thereby obtaining a full code coverage rate file. Further, after obtaining the full-quantity code coverage rate file, the terminal also uses a preset open source tool to convert the full-quantity code coverage rate file, and then analyzes and matches the converted full-quantity code coverage rate file with the project source code to calculate full-quantity code coverage rate information. The full code coverage information comprises a cladding coverage condition, an intra-cladding function coverage condition, a function coverage code row and the like. The preset open source tool can be set automatically according to the requirement. For example, the preset open source tool may specifically be JaCoCo.
In this embodiment, a project source code is compiled to obtain a code compiling file, a test case corresponding to a code increment coverage statistics request is obtained, the test case is executed according to the code compiling file, a code coverage statistics tool is called to obtain a full code coverage file, and the acquisition of the full code coverage file can be realized.
In one embodiment, determining a compiled file change function corresponding to project change information from project change information, project source code, and a code compiled file includes:
Comparing the project change information with the project source codes, and determining a source code change function corresponding to the project change information;
and traversing the code compiling file according to the source code changing function, and determining the compiling file changing function corresponding to the project changing information.
The source code change function is a function updated in the item source code corresponding to the item change information.
Specifically, the terminal generates an abstract syntax tree corresponding to the project source code according to the project source code, and queries the abstract syntax tree according to the project change file and the change code segment in the project change information to determine a source code change function corresponding to the project change information. After the source code change function is obtained, the file names and the function names in the code compiling file are in one-to-one correspondence with the file names and the function names of the project source codes, and the terminal directly traverses the code compiling file according to the source code change function, so that the compiling file change function corresponding to the project change information can be obtained. The file name and function name of the compiled file change function are the same as those of the source code change function. For example, when the item source code is java source code, the terminal may use JavaParser to generate an abstract syntax tree for the java source code.
In this embodiment, the project change information and the project source code are compared to determine the source code change function corresponding to the project change information, the code compiled file is traversed according to the source code change function, and the compiled file change function corresponding to the project change information is determined, so that the determination of the compiled file change function can be realized.
In one embodiment, comparing the project change information to the project source code, determining a source code change function corresponding to the project change information includes:
determining a project change file and a change code segment according to the project change information;
and comparing the project source codes according to the project change file and the change code segment, and determining a source code change function corresponding to the project change information.
Specifically, when the source code change function corresponding to the project change information is determined by comparing the project source code according to the project change file and the change code segment, the terminal generates an abstract syntax tree according to the project source code, and then determines all the function information related to modification according to the project change file and the change code segment to obtain the source code change function corresponding to the project change information. It should be noted that, when the project change file is an XML (Extensible Markup Language ) file, that is, when the XML file is modified, the terminal needs to use a preset XML reader to read the XML file, determine a change code segment in the XML file, obtain a source file in the project source code mapped corresponding to the XML file, and determine a source code change function in the source file according to the change code segment in the XML file.
In this embodiment, the project change file and the change code segment are determined based on the project change information, and the project source code is compared based on the project change file and the change code segment, so that the source code change function corresponding to the project change information is determined.
In one embodiment, querying a code compilation file from a compilation file modification function, determining modification function call information includes:
according to the compiled file change function, inquiring the code compiled file, and determining related change function class and related change function interface;
Acquiring first function information corresponding to a related change function class and second function information corresponding to a related change function interface from a code compiling file;
Determining calling function information for calling the compiled file change function according to the first function information and the second function information;
and obtaining change function calling information according to the calling function information.
The related change function class refers to a parent class of the class where the compiled file change function is located, and the related change function interface refers to an external interface corresponding to the class where the compiled file change function is located. The first function information refers to information related to all functions under the change function class, and the second function information refers to function information related to the change function interface. The calling function information refers to information related to a function that makes a call to a compiled file change function, and the call includes a direct call, a call for signature demodulation, a call for reflection, and the like.
Specifically, after obtaining the compiled file change function, the terminal compares the code compiled file according to the compiled file change function, determines the class of the compiled file change function, and further determines the parent class and the abstract interface corresponding to the compiled file change function according to the class of the compiled file change function, thereby obtaining the related change function class and the related change function interface. After obtaining the related change function class and the related change function interface, the terminal obtains first function information corresponding to the related change function class and second function information corresponding to the related change function interface from the code compiling file, determines calling function information according to the first function information and the second function information, and obtains change function calling information according to the calling function information.
Further, since the calling modes include direct calling, injection demodulation, reflection calling and the like, when the calling function information is determined according to the first function information and the second function information, corresponding calling functions are required to be determined according to different calling modes by adopting different modes, and calling functions corresponding to each calling mode are collected to obtain the calling function information. And for the direct call and the reflection call, directly comparing whether the function names in the first function information and the second function information are the same as the function names of the compiled file change function. For the case of annotation call, the class related to the change function needs to be traversed firstly, the class attribute is searched, the target class of the compiling file change function is determined in the class attribute, and the function name of the compiling file change function is used for searching in the target class to determine the call function.
In this embodiment, the method includes determining the related change function class and the related change function interface according to the change function of the compiled file, acquiring first function information corresponding to the related change function class and second function information corresponding to the related change function interface from the code compiled file, determining call function information for calling the change function of the compiled file according to the first function information and the second function information, and acquiring change function call information according to the call function information.
In one embodiment, after determining the change function call information, the method further comprises:
determining a corresponding external interface according to the change function call information;
And displaying the external interface.
The external interface is an interface which is open to the outside and can be linked with the outside. For example, the external interface may specifically refer to an external URL (Uniform Resource Locator ) interface.
Specifically, the terminal searches a corresponding external interface in the abstract syntax tree generated according to the project source code according to the change function call information, wherein the external interface refers to an interface related to call function information in the change function call information. After the external interface is obtained, the terminal displays the external interface, so that a tester can add a required test case according to the external interface corresponding to the compiled file change function, and the test is emphasized.
In this embodiment, by determining the corresponding external interface according to the change function call information and displaying the external interface, the tester can be prompted to test the external interface again, so as to realize accurate testing.
In one embodiment, filtering the full code coverage file according to the change function call information to obtain the code delta coverage information includes:
traversing the full code coverage rate file according to calling function information in the change function calling information, and determining a calling function code coverage rate file corresponding to the calling function information;
And converting the calling function code coverage rate file to obtain code increment coverage rate information.
The calling function code coverage rate file refers to a code coverage rate file related to calling function information.
Specifically, the terminal traverses the full-quantity code coverage rate file according to the calling function information in the change function calling information, screens out the calling function code coverage rate file corresponding to the calling function information from the full-quantity code coverage rate file, converts the calling function code coverage rate file by using a preset open source tool, analyzes and matches the converted calling function code coverage rate file with the project source code, and counts out the code increment coverage rate information.
In this embodiment, the code increment coverage information is obtained by traversing the full code coverage file according to the call function information in the change function call information, determining the call function code coverage file corresponding to the call function information, and converting the call function code coverage file.
In one embodiment, as shown in fig. 2, the method for counting the coverage rate of the code increment according to the present application is illustrated by a schematic flow chart, and specifically includes the following steps:
S1, a terminal receives a code increment coverage rate statistics request, wherein the code increment coverage rate statistics request carries project system codes, acquires source codes (namely project source codes) according to the project system codes, compiles and inserts the source codes to obtain Class files (namely code compiling files), and executes the Class files to obtain target files (namely full code coverage rate files);
s2, acquiring Git change information (namely project change information) according to project system codes, and acquiring change function information (namely compiled file change function) according to the Git change information, source codes and Class files;
S3, determining a change information call chain and an external interface URL (namely change function call information) according to the change function information and the Class file;
and S4, filtering the code increment coverage file according to the target file (namely the full code coverage file), the Class file and the change information call chain, and obtaining an increment coverage report (namely the code increment coverage information) according to the code increment coverage file.
In one embodiment, as shown in fig. 3, the method for counting the coverage rate of the code increment according to the present application is illustrated by a schematic flow chart, and specifically includes the following steps:
step 302, receiving a code increment coverage rate statistical request, wherein the code increment coverage rate statistical request carries a project system code;
Step 304, acquiring project source codes and project change information according to project system codes;
step 306, compiling the project source code to obtain a code compiling file, and obtaining a test case corresponding to the code increment coverage rate statistics request;
step 308, executing test cases according to the code compiling file, and calling a code coverage rate statistics tool to obtain a full code coverage rate file;
Step 310, determining a project change file and a change code segment according to the project change information;
Step 312, comparing the project source codes according to the project change file and the change code segment, and determining a source code change function corresponding to the project change information;
Step 314, traversing the code compiling file according to the source code changing function, and determining a compiling file changing function corresponding to the project changing information;
Step 316, according to the compiled file change function, inquiring the code compiled file, determining related change function class and related change function interface;
Step 318, obtaining first function information corresponding to the related change function class and second function information corresponding to the related change function interface from the code compiling file;
step 320, determining calling function information for calling the compiled file change function according to the first function information and the second function information;
Step 322, obtaining change function call information according to the call function information;
step 324, determining a corresponding external interface according to the change function call information;
Step 326, displaying an external interface;
Step 328, traversing the full code coverage rate file according to the calling function information in the changed function calling information, and determining the calling function code coverage rate file corresponding to the calling function information;
And 330, converting the calling function code coverage rate file to obtain code increment coverage rate information.
It should be understood that, although the steps in the flowcharts related to the above embodiments are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least a part of the steps in the flowcharts related to the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages performed is not necessarily sequential, but may be performed alternately or alternately with at least a part of the steps or stages in other steps or other steps.
In one embodiment, as shown in fig. 4, there is provided a code delta coverage statistics apparatus, comprising: a receiving module 402, an obtaining module 404, a processing module 406, a querying module 408, and a screening module 410, wherein:
the receiving module 402 is configured to receive a code increment coverage statistics request, where the code increment coverage statistics request carries an item system code;
The acquiring module 404 is configured to acquire project source codes and project change information according to project system codes, and obtain a full code coverage rate file and a code compiling file according to the project source codes;
A processing module 406, configured to determine a compiled file modification function corresponding to the project modification information according to the project modification information, the project source code, and the code compiled file;
A query module 408, configured to query the code compilation file according to the compilation file modification function, and determine modification function call information;
And the screening module 410 is configured to screen the full-scale code coverage rate file according to the change function call information, so as to obtain code increment coverage rate information.
According to the code increment coverage statistics device, after a code increment coverage statistics request is received, the acquisition of project source codes and project change information can be realized according to project system codes carried in the code increment coverage statistics request, so that full-quantity code coverage files and code compiling files can be obtained according to the project source codes, compiling file change functions corresponding to the project change information are determined according to the project change information, the project source codes and the code compiling files, further, the compiling file change function can be utilized to inquire the code compiling files, change function calling information is determined, full-quantity code coverage files are screened by utilizing the change function calling information, and the code increment coverage information is obtained.
In one embodiment, the obtaining module is further configured to compile the project source code to obtain a code compiling file, obtain a test case corresponding to the code increment coverage statistics request, execute the test case according to the code compiling file, and call the code coverage statistics tool to obtain a full code coverage file.
In one embodiment, the processing module is further configured to compare the project change information with the project source code, determine a source code change function corresponding to the project change information, traverse the code compilation file according to the source code change function, and determine a compilation file change function corresponding to the project change information.
In one embodiment, the processing module is further configured to determine a project change file and a change code segment according to the project change information, compare project source codes according to the project change file and the change code segment, and determine a source code change function corresponding to the project change information.
In one embodiment, the query module is further configured to query the code compilation file, determine related change function classes and related change function interfaces according to the change function of the compilation file, obtain first function information corresponding to the related change function classes and second function information corresponding to the related change function interfaces from the code compilation file, determine call function information for calling the change function of the compilation file according to the first function information and the second function information, and obtain change function call information according to the call function information.
In one embodiment, the code increment coverage statistics device further comprises a display module, wherein the display module is used for determining a corresponding external interface according to the change function call information and displaying the external interface.
In one embodiment, the filtering module is further configured to traverse the full code coverage rate file according to the call function information in the change function call information, determine a call function code coverage rate file corresponding to the call function information, and convert the call function code coverage rate file to obtain code delta coverage rate information.
For specific limitations on the code increment coverage statistics means, reference may be made to the above limitations on the code increment coverage statistics method, and no further description is given here. The modules in the code increment coverage statistics device can be all or partially implemented by software, hardware and a combination thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a terminal, and the internal structure of which may be as shown in fig. 5. The computer device includes a processor, a memory, a communication interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The communication interface of the computer device is used for carrying out wired or wireless communication with an external terminal, and the wireless mode can be realized through WIFI, an operator network, NFC (near field communication) or other technologies. The computer program is executed by a processor to implement a code delta coverage statistics method. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, can also be keys, a track ball or a touch pad arranged on the shell of the computer equipment, and can also be an external keyboard, a touch pad or a mouse and the like.
It will be appreciated by those skilled in the art that the structure shown in FIG. 5 is merely a block diagram of some of the structures associated with the present inventive arrangements and is not limiting of the computer device to which the present inventive arrangements may be applied, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
In one embodiment, a computer device is provided comprising a memory and a processor, the memory having stored therein a computer program, the processor when executing the computer program performing the steps of:
receiving a code increment coverage rate statistical request, wherein the code increment coverage rate statistical request carries a project system code;
Acquiring project source codes and project change information according to project system codes, and acquiring a full code coverage rate file and a code compiling file according to the project source codes;
Determining a compiled file change function corresponding to the project change information according to the project change information, the project source code and the code compiled file;
inquiring a code compiling file according to the compiling file changing function, and determining changing function calling information;
and screening the full code coverage rate file according to the change function call information to obtain the code increment coverage rate information.
In one embodiment, the processor when executing the computer program further performs the steps of: compiling the project source codes to obtain code compiling files, obtaining test cases corresponding to the code increment coverage rate statistics requests, executing the test cases according to the code compiling files, and calling a code coverage rate statistics tool to obtain the full code coverage rate files.
In one embodiment, the processor when executing the computer program further performs the steps of: comparing the project change information with the project source code, determining a source code change function corresponding to the project change information, traversing the code compiled file according to the source code change function, and determining a compiled file change function corresponding to the project change information.
In one embodiment, the processor when executing the computer program further performs the steps of: and determining a project change file and a change code segment according to the project change information, comparing project source codes according to the project change file and the change code segment, and determining a source code change function corresponding to the project change information.
In one embodiment, the processor when executing the computer program further performs the steps of: according to the compiling file, the function is changed, the compiling file of the code is inquired, the related change function class and the related change function interface are determined, the first function information corresponding to the related change function class and the second function information corresponding to the related change function interface are obtained from the compiling file of the code, the calling function information for calling the change function of the compiling file is determined according to the first function information and the second function information, and the change function calling information is obtained according to the calling function information.
In one embodiment, the processor when executing the computer program further performs the steps of: and determining a corresponding external interface according to the change function call information, and displaying the external interface.
In one embodiment, the processor when executing the computer program further performs the steps of: and traversing the full code coverage rate file according to the calling function information in the change function calling information, determining the calling function code coverage rate file corresponding to the calling function information, and converting the calling function code coverage rate file to obtain the code increment coverage rate information.
In one embodiment, a computer readable storage medium is provided having a computer program stored thereon, which when executed by a processor, performs the steps of:
receiving a code increment coverage rate statistical request, wherein the code increment coverage rate statistical request carries a project system code;
Acquiring project source codes and project change information according to project system codes, and acquiring a full code coverage rate file and a code compiling file according to the project source codes;
Determining a compiled file change function corresponding to the project change information according to the project change information, the project source code and the code compiled file;
inquiring a code compiling file according to the compiling file changing function, and determining changing function calling information;
and screening the full code coverage rate file according to the change function call information to obtain the code increment coverage rate information.
In one embodiment, the computer program when executed by the processor further performs the steps of: compiling the project source codes to obtain code compiling files, obtaining test cases corresponding to the code increment coverage rate statistics requests, executing the test cases according to the code compiling files, and calling a code coverage rate statistics tool to obtain the full code coverage rate files.
In one embodiment, the computer program when executed by the processor further performs the steps of: comparing the project change information with the project source code, determining a source code change function corresponding to the project change information, traversing the code compiled file according to the source code change function, and determining a compiled file change function corresponding to the project change information.
In one embodiment, the computer program when executed by the processor further performs the steps of: and determining a project change file and a change code segment according to the project change information, comparing project source codes according to the project change file and the change code segment, and determining a source code change function corresponding to the project change information.
In one embodiment, the computer program when executed by the processor further performs the steps of: according to the compiling file, the function is changed, the compiling file of the code is inquired, the related change function class and the related change function interface are determined, the first function information corresponding to the related change function class and the second function information corresponding to the related change function interface are obtained from the compiling file of the code, the calling function information for calling the change function of the compiling file is determined according to the first function information and the second function information, and the change function calling information is obtained according to the calling function information.
In one embodiment, the computer program when executed by the processor further performs the steps of: and determining a corresponding external interface according to the change function call information, and displaying the external interface.
In one embodiment, the computer program when executed by the processor further performs the steps of: and traversing the full code coverage rate file according to the calling function information in the change function calling information, determining the calling function code coverage rate file corresponding to the calling function information, and converting the calling function code coverage rate file to obtain the code increment coverage rate information.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, or the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory. By way of illustration, and not limitation, RAM can be in various forms such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), etc.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The above examples illustrate only a few embodiments of the application, which are described in detail and are not to be construed as limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of protection of the present application is to be determined by the appended claims.

Claims (10)

1. A method of code delta coverage statistics, the method comprising:
receiving a code increment coverage rate statistical request, wherein the code increment coverage rate statistical request carries a project system code;
acquiring project source codes and project change information according to the project system codes, and acquiring a full code coverage rate file and a code compiling file according to the project source codes;
Determining a compiled file change function corresponding to the project change information according to the project change information, the project source code and the code compiled file;
Inquiring the code compiling file according to the compiling file changing function, and determining related changing function class and related changing function interface;
acquiring first function information corresponding to the related change function class and second function information corresponding to the related change function interface from the code compiling file;
determining calling function information for calling the compiled file change function according to the first function information and the second function information;
obtaining change function calling information according to the calling function information; the change function calling information refers to called information of a compiled file change function in a code compiled file, and comprises calling function information of all the called compiled file change functions;
and screening the full-quantity code coverage rate file according to the change function call information to obtain code increment coverage rate information.
2. The method of claim 1, wherein obtaining a full code coverage file and a code compilation file from the project source code comprises:
compiling the project source code to obtain a code compiling file, and obtaining a test case corresponding to the code increment coverage rate statistical request;
And executing the test case according to the code compiling file, and calling a code coverage rate statistics tool to obtain a full code coverage rate file.
3. The method of claim 1, wherein determining a compiled file change function corresponding to the item change information based on the item change information, the item source code, and the code compiled file comprises:
Comparing the project change information with the project source codes, and determining a source code change function corresponding to the project change information;
And traversing the code compiling file according to the source code changing function, and determining a compiling file changing function corresponding to the project changing information.
4. The method of claim 3, wherein the comparing the project change information to the project source code, determining a source code change function corresponding to the project change information comprises:
determining a project change file and a change code segment according to the project change information;
And comparing the project source codes according to the project change file and the change code segment, and determining a source code change function corresponding to the project change information.
5. The method of claim 1, wherein the querying the code compilation file according to the compilation file modification function, after determining modification function call information, further comprises:
Determining a corresponding external interface according to the change function call information;
and displaying the external interface.
6. The method of claim 1, wherein the filtering the full code coverage file according to the change function call information to obtain code delta coverage information comprises:
Traversing the full code coverage rate file according to calling function information in the changing function calling information, and determining a calling function code coverage rate file corresponding to the calling function information;
And converting the calling function code coverage rate file to obtain code increment coverage rate information.
7. A code delta coverage statistics apparatus, the apparatus comprising:
The receiving module is used for receiving a code increment coverage rate statistical request, wherein the code increment coverage rate statistical request carries a project system code;
the acquisition module is used for acquiring project source codes and project change information according to the project system codes and acquiring a full code coverage rate file and a code compiling file according to the project source codes;
the processing module is used for determining a compiled file change function corresponding to the project change information according to the project change information, the project source code and the code compiled file;
The query module is used for querying the code compiling file according to the compiling file changing function, determining related changing function classes and related changing function interfaces, acquiring first function information corresponding to the related changing function classes and second function information corresponding to the related changing function interfaces from the code compiling file, determining calling function information for calling the compiling file changing function according to the first function information and the second function information, and obtaining changing function calling information according to the calling function information; the change function calling information refers to called information of a compiled file change function in a code compiled file, and comprises calling function information of all the called compiled file change functions;
And the screening module is used for screening the full-quantity code coverage rate file according to the change function call information to obtain code increment coverage rate information.
8. The apparatus of claim 7, wherein the obtaining module is further configured to compile the project source code to obtain a code compiled file, and obtain a test case corresponding to the code delta coverage statistics request;
And executing the test case according to the code compiling file, and calling a code coverage rate statistics tool to obtain a full code coverage rate file.
9. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any of claims 1 to 6 when the computer program is executed.
10. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
CN202011521515.8A 2020-12-21 2020-12-21 Code increment coverage statistics method, device, computer equipment and storage medium Active CN114647570B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011521515.8A CN114647570B (en) 2020-12-21 2020-12-21 Code increment coverage statistics method, device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011521515.8A CN114647570B (en) 2020-12-21 2020-12-21 Code increment coverage statistics method, device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN114647570A CN114647570A (en) 2022-06-21
CN114647570B true CN114647570B (en) 2024-08-20

Family

ID=81991067

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011521515.8A Active CN114647570B (en) 2020-12-21 2020-12-21 Code increment coverage statistics method, device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114647570B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104714882A (en) * 2013-12-17 2015-06-17 腾讯科技(深圳)有限公司 Code information processing method and device
CN108197036A (en) * 2018-02-06 2018-06-22 百度在线网络技术(北京)有限公司 For determining the method and apparatus of the coverage rate information of incremental code

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7519953B2 (en) * 2003-09-30 2009-04-14 Microsoft Corporation Method and system for automatically testing a software build
CN108829593B (en) * 2018-06-05 2023-12-05 平安壹钱包电子商务有限公司 Code coverage rate calculation and analysis method, device, equipment and storage medium
CN109002395B (en) * 2018-07-06 2020-11-24 京东数字科技控股有限公司 Code coverage rate management method and device
CN109271322B (en) * 2018-09-25 2021-09-28 杭州群核信息技术有限公司 Software testing range determining method, software testing method and device

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104714882A (en) * 2013-12-17 2015-06-17 腾讯科技(深圳)有限公司 Code information processing method and device
CN108197036A (en) * 2018-02-06 2018-06-22 百度在线网络技术(北京)有限公司 For determining the method and apparatus of the coverage rate information of incremental code

Also Published As

Publication number Publication date
CN114647570A (en) 2022-06-21

Similar Documents

Publication Publication Date Title
CN103631720B (en) The generation method and apparatus of test case
US20200019494A1 (en) Method and apparatus for performing test by using test case
US8145655B2 (en) Generating information on database queries in source code into object code compiled from the source code
US8276126B2 (en) Determining causes of software regressions based on regression and delta information
Stefan et al. Unit testing performance in java projects: Are we there yet?
US9880832B2 (en) Software patch evaluator
US10445225B2 (en) Command coverage analyzer
CN104679500B (en) Method and device for realizing automatic generation of entity class
CN110489319B (en) Interface performance test analysis method and storage medium
CN116016270B (en) Switch test management method, device, electronic device and storage medium
CN110716874A (en) Method for testing hardware compatibility of domestic operating system
CN111026670A (en) Test case generation method, test case generation device and storage medium
CN116991736A (en) Static code analysis method, device, system and storage medium
Torunski et al. Code style analytics for the automatic setting of formatting rules in ides: A solution to the tabs vs. spaces debate
CN108399125A (en) Automated testing method, device, computer equipment and storage medium
CN114647570B (en) Code increment coverage statistics method, device, computer equipment and storage medium
CN113220586A (en) Automatic interface pressure test execution method, device and system
JP6955162B2 (en) Analytical equipment, analysis method and analysis program
JP7318704B2 (en) Test equipment, test method and program
CN118069479A (en) Performance evaluation method, device and equipment of SQL (structured query language) sentences and storage medium
CN112015633A (en) Test excitation multi-platform multiplexing method, device, equipment and storage medium
US20050055612A1 (en) Design supporting apparatus
US20240045658A1 (en) Reducing code path permutations
CN116594883A (en) Code testing method, device, computer equipment and storage medium
CN116955140A (en) SDK test method, device, equipment and storage medium

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
GR01 Patent grant
GR01 Patent grant