CN109766261B - Coverage test method, coverage test device, computer equipment and storage medium - Google Patents

Coverage test method, coverage test device, computer equipment and storage medium Download PDF

Info

Publication number
CN109766261B
CN109766261B CN201811533053.4A CN201811533053A CN109766261B CN 109766261 B CN109766261 B CN 109766261B CN 201811533053 A CN201811533053 A CN 201811533053A CN 109766261 B CN109766261 B CN 109766261B
Authority
CN
China
Prior art keywords
code data
original
coverage rate
coverage
detected
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
CN201811533053.4A
Other languages
Chinese (zh)
Other versions
CN109766261A (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.)
Ping An Property and Casualty Insurance Company of China Ltd
Original Assignee
Ping An Property and Casualty Insurance Company of China 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 Ping An Property and Casualty Insurance Company of China Ltd filed Critical Ping An Property and Casualty Insurance Company of China Ltd
Priority to CN201811533053.4A priority Critical patent/CN109766261B/en
Publication of CN109766261A publication Critical patent/CN109766261A/en
Application granted granted Critical
Publication of CN109766261B publication Critical patent/CN109766261B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The application relates to a coverage test method, a coverage test device, computer equipment and a storage medium in the field of test tools. The method comprises the following steps: acquiring a difference analysis instruction and code data to be detected, acquiring original coverage rate of the code data to be detected, inquiring to obtain original code data corresponding to an inquiry label according to a preset inquiry label in the difference analysis instruction, comparing the content of the code data to be detected with that of the original code data to obtain modified code data, calling a coverage rate analysis tool to analyze the coverage rate of the modified code data to obtain modified coverage rate corresponding to the modified code data, and obtaining a coverage test result of the code data to be detected according to the modified coverage rate and the original coverage rate. The method can improve the efficiency of code coverage test.

Description

Coverage test method, coverage test device, computer equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a coverage test method, apparatus, computer device, and storage medium.
Background
With the development of computer technology, program development technology has also been developed. When testing a new program, the code coverage test is an important quality measurement index, and the problems in the program can be reflected through the code coverage rate of the program. Generally, a developer performs reverse checking of a program according to a code coverage test result, so that the program is iterated according to multiple program versions until the code coverage of the program meets the test requirement.
In the prior art, each time after the program is modified, the modified program needs to be subjected to coverage test, in the test mode, complicated codes lead to long test period, and in addition, the test result cannot intuitively embody the influence of modified content in the modified program on the code coverage rate of the program, so that the later modification of the program is not targeted, and the code coverage test efficiency of the program is low.
Disclosure of Invention
In view of the foregoing, it is desirable to provide an overlay test method, apparatus, computer device, and storage medium that can solve the problem of low code overlay test efficiency of a program.
A coverage testing method, the method comprising:
acquiring a difference analysis instruction and code data to be detected;
acquiring the original coverage rate of the code data to be detected, and inquiring to obtain the original code data corresponding to the inquiry label according to the preset inquiry label in the difference analysis instruction;
obtaining modified code data according to the code data to be detected and the original code data;
performing coverage rate analysis on the modified code data to obtain modified coverage rate corresponding to the modified code data;
And obtaining a coverage test result of the code data to be detected according to the change coverage rate and the original coverage rate.
In one embodiment, the method further comprises: analyzing the difference analysis instruction to obtain a preset query tag; the query tag comprises a data serial number of original code data; and determining the original code data corresponding to the data serial number according to the query tag.
In one embodiment, the method further comprises: setting a data serial number for the code data to be detected according to a preset rule; and converting the code data to be detected into original code data, and storing the original code data into a preset original code library.
In one embodiment, the method further comprises: inputting the code data to be detected and the original code data into a preset difference analysis script; compiling and analyzing the code data to be detected and the original code data through the difference analysis script to obtain difference code parts of the code data to be detected and the original code data; and determining the difference code part as change code data.
In one embodiment, the method further comprises: generating a change coverage rate chart according to the change coverage rate, and generating an original coverage rate chart according to the original coverage rate; storing the change coverage rate chart and the original coverage rate chart in a preset database; when a database call request of a visual platform is received, the change coverage rate chart and the original coverage rate chart in the database are sent to a preset visual platform, so that the visual platform visually displays a coverage test result of the code data to be detected.
In one embodiment, the method further comprises: compiling the code data to be detected to obtain a target file; and generating a change coverage rate chart by the code data to be detected, the target file and the change coverage rate.
In one embodiment, the method further comprises: filtering and calculating the original coverage rate to obtain a simplified original coverage rate; and generating an original coverage rate chart according to the simplified original coverage rate.
A coverage test apparatus, the apparatus comprising:
the interface module is used for acquiring a difference analysis instruction and code data to be detected;
The data acquisition module is used for acquiring the original coverage rate of the code data to be detected, and inquiring to obtain the original code data corresponding to the inquiry label according to the preset inquiry label in the difference analysis instruction;
the difference analysis module is used for obtaining modified code data according to the code data to be detected and the original code data
The coverage rate analysis module is used for carrying out coverage rate analysis on the modified code data to obtain modified coverage rate corresponding to the modified code data;
And the coverage test module is used for obtaining a coverage test result of the code data to be detected according to the change coverage rate and the original coverage rate.
A computer device comprising a memory storing a computer program and a processor which when executing the computer program performs the steps of:
acquiring a difference analysis instruction and code data to be detected;
acquiring the original coverage rate of the code data to be detected, and inquiring to obtain the original code data corresponding to the inquiry label according to the preset inquiry label in the difference analysis instruction;
obtaining modified code data according to the code data to be detected and the original code data;
performing coverage rate analysis on the modified code data to obtain modified coverage rate corresponding to the modified code data;
And obtaining a coverage test result of the code data to be detected according to the change coverage rate and the original coverage rate.
A computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of:
acquiring a difference analysis instruction and code data to be detected;
acquiring the original coverage rate of the code data to be detected, and inquiring to obtain the original code data corresponding to the inquiry label according to the preset inquiry label in the difference analysis instruction;
obtaining modified code data according to the code data to be detected and the original code data;
performing coverage rate analysis on the modified code data to obtain modified coverage rate corresponding to the modified code data;
And obtaining a coverage test result of the code data to be detected according to the change coverage rate and the original coverage rate.
According to the coverage test method, the coverage test device, the computer equipment and the storage medium, the original coverage rate of the code data to be detected is obtained, then the original code data of the history modification version is selected according to the difference analysis instruction, wherein the original code data corresponds to the code data to be detected, so that modified code data is further obtained according to the code data to be detected and the original code data, then the modified coverage rate of the modified code data is analyzed according to the modified code data, when the code coverage rate of the code data to be detected is analyzed, the code coverage rate of the code data to be detected can be analyzed according to the modified coverage rate and the original coverage rate at the same time, meanwhile, the influence of the modified code data on the code coverage rate of the code data to be detected can be reflected, and the direction for optimizing the code data to be detected is given.
Drawings
FIG. 1 is an application scenario diagram of an overlay test method in one embodiment;
FIG. 2 is a flow chart of an overlay test method according to one embodiment;
FIG. 3 is a flow chart illustrating steps for obtaining raw code data in one embodiment;
FIG. 4 is a flow chart of a coverage test method according to another embodiment;
FIG. 5 is a block diagram of an overlay test apparatus in one embodiment;
fig. 6 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.
The coverage test method provided by the application can be applied to an application environment shown in figure 1. Wherein the terminal 102 communicates with the server 104 via a network. The terminal 102 may be, but not limited to, various personal computers, notebook computers, smartphones, tablet computers, and portable wearable devices, and the server 104 may be implemented by a stand-alone server or a server cluster composed of a plurality of servers.
The program developer performs a coverage test of the program by operating the terminal 102, when performing the coverage test, the terminal 102 performs a network access to the server 104, the terminal 102 sends the code data to be detected to the server 104 through a network, and when receiving the code data to be detected, the server 104 performs coverage detection on the code data to be detected.
Specifically, the terminal 102 accesses the server 104 through a WEB page, and uploads the code data to be detected to the server 104 through an interface function of the WEB page.
In addition, according to the script file pre-configured in the server 104, it is also necessary to perform configuration of compiler parameters and plug-in parameters in the WEB page of the terminal 102.
Specifically, when the server 104 performs the coverage test of the code data to be detected, the code data to be detected is received, and whether the original code data of the code data to be detected is stored in the database corresponding to the server 104 is detected, where the original code data refers to a historical version of the code data to be detected. If the original code data exists, the compiler configured in the server 104 performs difference analysis on the code data to be detected and the original code data to obtain modified code data, and then the coverage analysis tool configured in the server performs coverage analysis on the code data to be detected to obtain the original coverage, and the server 104 also performs coverage analysis on the modified code data to obtain the modified coverage corresponding to the modified code data. Thus, the server 104 obtains a test result of the coverage rate of the code data to be detected according to the modified coverage rate and the original coverage rate.
In one embodiment, as shown in fig. 2, a coverage test method is provided, and the method is applied to the server in fig. 1 for illustration, and includes the following steps:
Step 202, obtaining a difference analysis instruction and code data to be detected.
The difference analysis instruction may be sent by a terminal, and when the program developer needs to perform coverage test, the difference analysis instruction is generated by the terminal, and at this time, the server receives the difference analysis instruction generated by the terminal. Meanwhile, the server also acquires code data to be detected, wherein the code data to be detected is the object of the coverage test and is also sent through the terminal.
Specifically, the difference analysis instruction is used for triggering the server to perform coverage test, and the code data to be detected can be a code file or a code fragment of a program developed by a program developer.
In addition, in a specific embodiment, in a code coverage rate detection period of a program, the server stores the code data to be detected received each time in the database as original code data, so that the code coverage rate detection period of the program can be directly invoked from the database next time.
Step 204, obtaining the original coverage rate of the code data to be detected, and inquiring to obtain the original code data corresponding to the inquiry label according to the preset inquiry label in the difference analysis instruction.
The original coverage rate is the coverage rate obtained by performing code coverage test on the code data to be detected, and the server can call a coverage rate analysis tool to perform coverage test on the code data to be detected to obtain the original coverage rate. The query tag may be a computer-identifiable tag, and the server may obtain the identification tag after receiving the variance analysis instruction.
In an embodiment, the coverage analysis tool may be deployed in a server, so that the server further includes a coverage detection sub-server, in which the Jacoco tool is integrated, the coverage detection sub-server receives the code data to be detected, and then performs coverage analysis on the band detection code data by the Jacoco tool.
When the server receives the original coverage rate, the coverage test of the code to be detected is started, the server analyzes the difference analysis instruction, and corresponding original code data is selected according to the analysis result. The code data to be detected is iterative data of original code data, and the original code data can be stored in a database corresponding to the server.
And 206, comparing the content of the code data to be detected with that of the original code data to obtain modified code data.
Because the code data to be detected is an iterative version of the original code data, the code data to be detected and the original code data are partially consistent, and therefore, the code data to be detected and the original code data are compared, and modified code data can be obtained. The modified code data is a code portion of the code data to be detected and the original code data, or may be difference information including a difference, and the code data to be detected may be obtained according to the difference information and the original code data.
And step 208, calling a coverage rate analysis tool to analyze the coverage rate of the changed code data, and obtaining the changed coverage rate corresponding to the changed code data.
The change coverage rate is obtained by analyzing the coverage rate of the change code data, and reflects the coverage rate condition of the codes in the change code data, so that the quality condition of the change part codes in the current modification can be obtained.
And 210, obtaining a coverage test result of the code data to be detected according to the change coverage rate and the original coverage rate.
The coverage rate test result comprises a modified coverage rate condition and an original coverage rate condition, the modified coverage rate can reflect the code quality condition of a modified part, the original coverage rate can reflect the overall quality condition of the code, the modified code quality condition can be determined through covering the test result, the modified overall code quality condition can be obtained from the whole, and therefore program developers can be guided to further improve the program code according to the test result.
In the coverage test method, when the original coverage rate of the code data to be detected is received, the original code data of the history modification version is selected according to the difference analysis instruction, wherein the original code data corresponds to the code data to be detected, so that modified code data is further obtained according to the code data to be detected and the original code data, then the modified coverage rate of the modified code data is analyzed according to the modified code data, and when the code coverage rate of the code data to be detected is analyzed, the code coverage rate of the code data to be detected can be analyzed according to the modified coverage rate and the original coverage rate at the same time, meanwhile, the influence of the modified code data on the code coverage rate of the code data to be detected can be reflected, and the direction for optimizing the code data to be detected is given.
In one embodiment, as shown in FIG. 3, a schematic flow chart of the steps of obtaining raw code data is provided, the specific steps being as follows:
Step 302, analyzing the difference analysis instruction to obtain a preset query tag; the query tag contains a data serial number of the original code data.
Step 304, according to the query tag, the original code data corresponding to the data serial number is determined.
In this embodiment, the original code data of the current coverage test can be determined by querying the data serial number in the tag and then querying the database through the data serial number, which is convenient and accurate and easy to configure.
In another embodiment, a GIT sub-server (distributed version control system) may be further included in the server, through which the original code data is marked with a data serial number.
In yet another embodiment, the method further comprises the step of updating the original code library, specifically as follows: and setting a data serial number for the code data to be detected according to a preset rule, converting the code data to be detected into original code data, and storing the original code data into a preset original code library. In this embodiment, the original code library is used to store original code data, and the data serial number of the original code data is unique.
In a specific embodiment, when the code data to be detected is obtained, the data serial number corresponding to the code data to be detected can be directly obtained, and the code data to be detected and the corresponding data serial number are correspondingly stored, so that when the coverage test is completed, the code data to be detected is stored in the original code library for the next coverage test.
In an embodiment, when the coverage test is performed, configuration information needs to be set, the configuration information includes a data serial number for selecting original code data, and the configuration information can be converted into a difference analysis instruction, so as to obtain the original code data.
In a specific embodiment, the data sequence number may be implemented by setting a commit_id in the GIT sub-server, and by submitting a commit_id of the code data to be detected and a commit_id of the original code data, the GIT sub-server may correspondingly acquire corresponding file data by identifying the commit_ids of the two files.
In one embodiment, the step of obtaining the altered code data may be as follows: inputting the code data to be detected and the original code data into a preset difference analysis script, performing compiling analysis on the code data to be detected and the original code data through the difference analysis script to obtain difference code parts of the code data to be detected and the original code data, and determining the difference code parts as modified code data.
Specifically, the difference analysis script may be implemented by a GIT sub-server, which obtains a file of code data to be detected and a file of original code data by identifying a commit_id of the code data to be detected and a commit_id of the original code data. And compiling the original code data and the code data to be detected respectively to obtain two target files, namely a first target file corresponding to the code data to be detected and a second target file corresponding to the original code data, and comparing the first target file and the second target file to obtain modified code data. Therefore, according to the technical scheme of the embodiment, the difference analysis among different files can be performed by submitting different commit_IDs, so that comprehensive coverage rate analysis can be performed according to requirements, and the test progress of code coverage rate can be accelerated.
In one embodiment, as shown in fig. 4, a schematic flowchart of a coverage test method is provided, and specific steps are as follows:
step 402, generating a change coverage rate chart according to the change coverage rate, and generating an original coverage rate chart according to the original coverage rate.
The change coverage rate chart and the original coverage rate chart are essentially chart data, namely, the chart data is input into chart display software, and charts corresponding to the chart data can be displayed in the chart display software.
And step 404, storing the changed coverage rate chart and the original coverage rate chart in a preset database.
The database is a database corresponding to the server and is used for storing data in the server.
Step 406, when receiving a database call request of the visualization platform, sending the changed coverage rate chart and the original coverage rate chart in the database to a preset visualization platform so that the visualization platform can visually display the coverage test result of the code data to be detected.
In this embodiment, the visualization platform may be deployed in a terminal of a program developer, and when the terminal sends a database call request, the change coverage rate chart and the original coverage rate chart may be displayed in the visualization platform in the terminal. Through visual display of the test result, the coverage rate condition of the code data to be detected can be obtained rapidly, and therefore the efficiency of code coverage test can be improved.
For step 402, the step of generating a change coverage chart may be: compiling the modified code data to obtain a target file, and generating a modified coverage rate chart by the modified code data, the target file and the modified coverage rate.
In this embodiment, the code data to be detected may be compiled by a compiler deployed in the server to obtain a target file corresponding to the code data to be detected, where compiling refers to converting a program code language into a language that can be identified by a computer, that is, a binary language.
Specifically, the total number of lines of the modified code data can be obtained according to the modified code data, so that the total number of lines covered can be calculated according to the modified code coverage rate, and the target file is identified by combining with the server, so that the lines which are not covered specifically can be known, and a modified coverage rate chart can be generated. The chart can reflect the code change information of the changed code data, the specific change condition of the changed code data and the coverage condition of the changed code.
When the GIT sub-server generates modified code data in specific application, the maven plug-in generates modified coverage according to the original coverage and the modified code data, so that a modified coverage chart and an original coverage chart are generated through the maven plug-in.
For step 402, in an embodiment, coverage analysis program may be used to perform coverage test on the original code data to obtain an original coverage, where the original coverage mainly includes coverage detection of a method, a class, a row, a branch, an instruction and a circle, so that the original coverage in the original code data can be obtained through the coverage detection.
Because the data size in the original coverage rate is larger, the original coverage rate can be filtered and calculated to obtain the simplified original coverage rate, and the part which has no influence on the changed coverage rate is removed from the simplified original coverage rate data, so that when the original coverage rate chart is generated, the original coverage rate chart can be generated according to the simplified original coverage rate, and the original coverage rate chart is more simplified.
In a specific embodiment, a specific coverage test analysis method is provided, and the method can be applied to a coverage test platform, where the coverage test platform includes: compiler, trigger, STG machine and database.
The overlay test platform is also provided with an interface for interaction with the terminal, the terminal accesses the overlay test platform address to enter a parameter configuration interface of the overlay test, and as a plurality of plug-ins are configured in the overlay test platform, a plurality of parameters need to be configured in the parameter configuration interface, for example: the maven plug-in and the environment parameters required by operation are sent to a compiler, the configured exp script and the ssh key are sent to a board hopping machine, the STG machine account number, the service path and jvm starting parameters are configured and sent to the STG machine, and finally the configuration parameters are sent to a database for dynamic modification in the terminal.
And the coverage test platform checks the configuration parameters, and enters an operation interface after the configuration parameters pass detection. Uploading code data to be detected in an operation interface, inputting a commit_ID of the code data to be detected and a commit_ID of original code data, acquiring the code data to be detected and the original code data from a database by a GIT sub-server according to the commit_ID, thereby acquiring modified code information of the code data to be detected and the original code data through the GIT sub-server, at the moment, executing a coverage rate collection script by an STG machine, collecting the original coverage rate of the code data to be detected, pushing the original coverage rate data into a compiler by the STG machine through a springboard machine, and at the moment, generating a coverage rate intermediate result by means of a maven plug-in, wherein the intermediate result comprises the modified coverage rate and the original coverage rate.
After the change coverage rate and the original coverage rate are obtained, a report interface is entered, each code file, change code data and an intermediate result are sent to a terminal in the report interface, an original coverage rate chart and a change coverage rate chart obtained through analysis are sent to the terminal, and the data are stored as a log in a database through the terminal so as to be conveniently called. If test analysis operation is performed on the report interface, the log file in the database and the data corresponding to the log file can be retrieved, and the data and the chart are visually displayed on a visual interface of the terminal.
It should be understood that, although the steps in the flowcharts of fig. 2-4 are shown in order as indicated by the arrows, these steps are not necessarily performed in order as 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 some of the steps in fig. 2-4 may include multiple sub-steps or stages that are not necessarily performed at the same time, but may be performed at different times, nor do the order in which the sub-steps or stages are performed necessarily occur sequentially, but may be performed alternately or alternately with at least a portion of the sub-steps or stages of other steps or steps.
In one embodiment, as shown in fig. 5, there is provided an overlay test apparatus comprising: an interface module 502, a data acquisition module 504, a variance analysis module 506, a coverage analysis module 508, and a coverage test module 510, wherein:
the interface module 502 is configured to obtain a difference analysis instruction and code data to be detected.
The data acquisition module 504 acquires the original coverage rate of the code data to be detected, and queries to obtain the original code data corresponding to the query tag according to the preset query tag in the difference analysis instruction.
The difference analysis module 506 is configured to compare the content of the code data to be detected with the content of the original code data, so as to obtain modified code data.
And the coverage analysis module 508 is used for calling a coverage analysis tool to perform coverage analysis on the modified code data so as to obtain the modified coverage corresponding to the modified code data.
And the coverage test module 510 is configured to obtain a coverage test result of the code data to be detected according to the modified coverage rate and the original coverage rate.
In one embodiment, the data obtaining module 504 is further configured to parse the difference analysis instruction to obtain a preset query tag; the query tag comprises a data serial number of original code data; and determining the original code data corresponding to the data serial number according to the query tag.
In one embodiment, the original code updating module is configured to set a data sequence number for the code data to be detected according to a preset rule; and converting the code data to be detected into original code data, and storing the original code data into a preset original code library.
In one embodiment, the difference analysis module 506 is further configured to input the code data to be detected and the original code data into a preset difference analysis script; compiling and analyzing the code data to be detected and the original code data through the difference analysis script to obtain difference code parts of the code data to be detected and the original code data; and determining the difference code part as change code data.
In one embodiment, the coverage test module 510 is further configured to generate a change coverage chart according to the change coverage, and generate an original coverage chart according to the original coverage; storing the change coverage rate chart and the original coverage rate chart in a preset database; when a database call request of a visual platform is received, the change coverage rate chart and the original coverage rate chart in the database are sent to a preset visual platform, so that the visual platform visually displays a coverage test result of the code data to be detected.
In one embodiment, the coverage test module 510 is further configured to compile the modified code data to obtain a target file; and generating a change coverage rate chart by the change code data, the target file and the change coverage rate.
In one embodiment, the coverage test module 510 is further configured to perform filtering calculation on the raw coverage rate to obtain a simplified raw coverage rate; and generating an original coverage rate chart according to the simplified original coverage rate.
For specific limitations of the coverage test apparatus, reference may be made to the above limitations of the coverage test method, and no further description is given here. The various modules in the overlay test apparatus described above may be implemented in whole or in part by software, hardware, and combinations 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 server, the internal structure of which may be as shown in fig. 6. The computer device includes a processor, a memory, a network interface, and a database 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, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is used for storing code data to be detected, original code data and the like. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement an overlay test method.
It will be appreciated by those skilled in the art that the structure shown in FIG. 6 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 storing a computer program and a processor that when executing the computer program performs the steps of:
acquiring a difference analysis instruction and code data to be detected;
acquiring the original coverage rate of the code data to be detected, and inquiring to obtain the original code data corresponding to the inquiry label according to the preset inquiry label in the difference analysis instruction;
content comparison is carried out on the code data to be detected and the original code data to obtain modified code data;
calling a coverage rate analysis tool to analyze the coverage rate of the modified code data to obtain a modified coverage rate corresponding to the modified code data;
And obtaining a coverage test result of the code data to be detected according to the change coverage rate and the original coverage rate.
In one embodiment, the processor when executing the computer program further performs the steps of: analyzing the difference analysis instruction to obtain a preset query tag; the query tag comprises a data serial number of original code data; and determining the original code data corresponding to the data serial number according to the query tag.
In one embodiment, the processor when executing the computer program further performs the steps of: setting a data serial number for the code data to be detected according to a preset rule; and converting the code data to be detected into original code data, and storing the original code data into a preset original code library.
In one embodiment, the processor when executing the computer program further performs the steps of: inputting the code data to be detected and the original code data into a preset difference analysis script; compiling and analyzing the code data to be detected and the original code data through the difference analysis script to obtain difference code parts of the code data to be detected and the original code data; and determining the difference code part as change code data.
In one embodiment, the processor when executing the computer program further performs the steps of: generating a change coverage rate chart according to the change coverage rate, and generating an original coverage rate chart according to the original coverage rate; storing the change coverage rate chart and the original coverage rate chart in a preset database; when a database call request of a visual platform is received, the change coverage rate chart and the original coverage rate chart in the database are sent to a preset visual platform, so that the visual platform visually displays a coverage test result of the code data to be detected.
In one embodiment, the processor when executing the computer program further performs the steps of: compiling the modified code data to obtain a target file; and generating a change coverage rate chart by the change code data, the target file and the change coverage rate.
In one embodiment, the processor when executing the computer program further performs the steps of: filtering and calculating the original coverage rate to obtain a simplified original coverage rate; and generating an original coverage rate chart according to the simplified original coverage rate.
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:
acquiring a difference analysis instruction and code data to be detected;
acquiring the original coverage rate of the code data to be detected, and inquiring to obtain the original code data corresponding to the inquiry label according to the preset inquiry label in the difference analysis instruction;
content comparison is carried out on the code data to be detected and the original code data to obtain modified code data;
calling a coverage rate analysis tool to analyze the coverage rate of the modified code data to obtain a modified coverage rate corresponding to the modified code data;
And obtaining a coverage test result of the code data to be detected according to the change coverage rate and the original coverage rate.
In one embodiment, the computer program when executed by the processor further performs the steps of: analyzing the difference analysis instruction to obtain a preset query tag; the query tag comprises a data serial number of original code data; and determining the original code data corresponding to the data serial number according to the query tag.
In one embodiment, the computer program when executed by the processor further performs the steps of: setting a data serial number for the code data to be detected according to a preset rule; and converting the code data to be detected into original code data, and storing the original code data into a preset original code library.
In one embodiment, the computer program when executed by the processor further performs the steps of: inputting the code data to be detected and the original code data into a preset difference analysis script; compiling and analyzing the code data to be detected and the original code data through the difference analysis script to obtain difference code parts of the code data to be detected and the original code data; and determining the difference code part as change code data.
In one embodiment, the computer program when executed by the processor further performs the steps of: generating a change coverage rate chart according to the change coverage rate, and generating an original coverage rate chart according to the original coverage rate; storing the change coverage rate chart and the original coverage rate chart in a preset database; when a database call request of a visual platform is received, the change coverage rate chart and the original coverage rate chart in the database are sent to a preset visual platform, so that the visual platform visually displays a coverage test result of the code data to be detected.
In one embodiment, the computer program when executed by the processor further performs the steps of: compiling the modified code data to obtain a target file; and generating a change coverage rate chart by the change code data, the target file and the change coverage rate.
In one embodiment, the computer program when executed by the processor further performs the steps of: filtering and calculating the original coverage rate to obtain a simplified original coverage rate; and generating an original coverage rate chart according to the simplified original coverage rate.
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 non-volatile and/or volatile memory. The nonvolatile memory can include Read Only Memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (SYNCHLINK) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), among others.
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 coverage test method applied to a coverage test platform, the method comprising:
acquiring a difference analysis instruction and code data to be detected;
Acquiring the original coverage rate of the code data to be detected, and inquiring to obtain the original code data corresponding to the inquiry label according to the preset inquiry label in the difference analysis instruction; the configuration information during coverage test comprises a data serial number of original code data, and the configuration information is used for being converted into a difference analysis instruction so as to acquire the original code data;
content comparison is carried out on the code data to be detected and the original code data to obtain modified code data;
calling a coverage rate analysis tool to analyze the coverage rate of the modified code data to obtain a modified coverage rate corresponding to the modified code data;
Obtaining a coverage test result of the code data to be detected according to the change coverage rate and the original coverage rate; the coverage rate of the change is used for reflecting the code quality condition of the changed part, the original coverage rate is used for reflecting the code quality condition of the changed whole code, and the coverage test result is used for determining the direction of optimizing the code data to be detected;
Wherein, coverage test platform includes: the system comprises a compiler, a trigger, an STG machine, a database and an interface for interaction with a terminal, wherein the terminal accesses an address of a coverage test platform, enters a parameter configuration interface of the coverage test, and configures various parameters in the parameter configuration interface; the compiler is used for receiving a maven plug-in and environment parameters required by operation, the springboard machine is used for receiving a configured exp script and ssh key, the STG machine is used for receiving a configured STG machine account number, a service path and jvm starting parameters, and the database is used for receiving each configuration parameter and realizing dynamic modification; the STG machine is used for executing a coverage rate collection script, collecting the original coverage rate of code data to be detected, pushing the original coverage rate data to the compiler through the springboard machine, and generating a coverage rate intermediate result by the compiler through the maven plug-in according to the original coverage rate and the changed code data, wherein the coverage rate intermediate result comprises the changed coverage rate and the original coverage rate.
2. The method of claim 1, wherein querying, according to a preset query tag in the variance analysis instruction, obtains original code data corresponding to the query tag, including:
Analyzing the difference analysis instruction to obtain a preset query tag; the query tag comprises a data serial number of original code data;
And determining the original code data corresponding to the data serial number according to the query tag.
3. The method according to claim 2, further comprising, after obtaining a test result of the coverage of the code data to be detected according to the change coverage and the original coverage:
Setting a data serial number for the code data to be detected according to a preset rule;
And converting the code data to be detected into original code data, and storing the original code data into a preset original code library.
4. The method of claim 1, wherein comparing the content of the code data to be detected with the content of the original code data to obtain modified code data comprises:
inputting the code data to be detected and the original code data into a preset difference analysis script;
compiling and analyzing the code data to be detected and the original code data through the difference analysis script to obtain difference code parts of the code data to be detected and the original code data;
And determining the difference code part as change code data.
5. The method according to any one of claims 1 to 4, wherein obtaining the coverage test result of the code data to be detected according to the change coverage and the original coverage includes:
Generating a change coverage rate chart according to the change coverage rate, and generating an original coverage rate chart according to the original coverage rate;
storing the change coverage rate chart and the original coverage rate chart in a preset database;
When a database call request of a visual platform is received, the change coverage rate chart and the original coverage rate chart in the database are sent to a preset visual platform, so that the visual platform visually displays a coverage test result of the code data to be detected.
6. The method of claim 5, wherein the generating a change coverage chart from the change coverage comprises:
Compiling the modified code data to obtain a target file;
and generating a change coverage rate chart by the change code data, the target file and the change coverage rate.
7. The method of claim 5, further comprising, prior to generating a raw coverage chart from the raw coverage:
filtering and calculating the original coverage rate to obtain a simplified original coverage rate;
the generating the original coverage rate chart according to the original coverage rate comprises the following steps:
And generating an original coverage rate chart according to the simplified original coverage rate.
8. A coverage test apparatus for use with a coverage test platform, the apparatus comprising:
the interface module is used for acquiring a difference analysis instruction and code data to be detected;
The data acquisition module is used for acquiring the original coverage rate of the code data to be detected, and inquiring to obtain the original code data corresponding to the inquiry label according to the preset inquiry label in the difference analysis instruction; the configuration information during coverage test comprises a data serial number of original code data, and the configuration information is used for being converted into a difference analysis instruction so as to acquire the original code data;
The difference analysis module is used for comparing the content of the code data to be detected with the content of the original code data to obtain modified code data;
The coverage rate analysis module is used for calling a coverage rate analysis tool to conduct coverage rate analysis on the modified code data so as to obtain modified coverage rate corresponding to the modified code data;
The coverage test module is used for obtaining a test result of the coverage rate of the code data to be detected according to the change coverage rate and the original coverage rate; the change coverage rate is used for reflecting the code quality condition of a changed part, the original coverage rate is used for reflecting the code quality condition of the changed whole code, and the coverage test result is used for determining the direction of optimizing the code data to be detected;
Wherein, coverage test platform includes: the system comprises a compiler, a trigger, an STG machine, a database and an interface for interaction with a terminal, wherein the terminal accesses an address of a coverage test platform, enters a parameter configuration interface of the coverage test, and configures various parameters in the parameter configuration interface; the compiler is used for receiving a maven plug-in and environment parameters required by operation, the springboard machine is used for receiving a configured exp script and ssh key, the STG machine is used for receiving a configured STG machine account number, a service path and jvm starting parameters, and the database is used for receiving each configuration parameter and realizing dynamic modification; the STG machine is used for executing a coverage rate collection script, collecting the original coverage rate of code data to be detected, pushing the original coverage rate data to the compiler through the springboard machine, and generating a coverage rate intermediate result by the compiler through the maven plug-in according to the original coverage rate and the changed code data, wherein the coverage rate intermediate result comprises the changed coverage rate and the original coverage rate.
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 7 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 7.
CN201811533053.4A 2018-12-14 2018-12-14 Coverage test method, coverage test device, computer equipment and storage medium Active CN109766261B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811533053.4A CN109766261B (en) 2018-12-14 2018-12-14 Coverage test method, coverage test device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811533053.4A CN109766261B (en) 2018-12-14 2018-12-14 Coverage test method, coverage test device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN109766261A CN109766261A (en) 2019-05-17
CN109766261B true CN109766261B (en) 2024-05-24

Family

ID=66450711

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811533053.4A Active CN109766261B (en) 2018-12-14 2018-12-14 Coverage test method, coverage test device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN109766261B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110347381A (en) * 2019-05-22 2019-10-18 平安证券股份有限公司 The management method and device of data mart modeling code
CN110532174B (en) * 2019-07-24 2024-05-31 平安科技(深圳)有限公司 Method, device, computer equipment and storage medium for calculating increment code coverage rate
CN110781071B (en) * 2019-09-09 2022-10-14 中国平安财产保险股份有限公司 Method and device for testing application program upgrade version and computer equipment
CN111813412B (en) * 2020-06-28 2023-03-24 中国科学院计算机网络信息中心 Method and system for constructing test data set for evaluating binary code comparison tool
CN112597041B (en) * 2020-12-28 2023-01-20 上海品顺信息科技有限公司 Cross-branch merging method, system, equipment and storage medium for code coverage rate
CN114706749A (en) * 2022-03-03 2022-07-05 网宿科技股份有限公司 Method and device for determining code coverage rate, electronic equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105608011A (en) * 2016-03-01 2016-05-25 网易(杭州)网络有限公司 Determination method and device for code testing coverage rate statistical results
CN106201863A (en) * 2016-06-22 2016-12-07 广州唯品会信息科技有限公司 A kind of method and apparatus obtaining code coverage
CN107480066A (en) * 2017-08-18 2017-12-15 网易(杭州)网络有限公司 Code coverage statistical method, device, storage medium, processor and terminal
CN108829580A (en) * 2018-05-07 2018-11-16 百度在线网络技术(北京)有限公司 Multi version test data processing method, device, equipment and storage medium
CN108829593A (en) * 2018-06-05 2018-11-16 平安壹钱包电子商务有限公司 Code coverage calculation and analysis methods, device, equipment and storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9317410B2 (en) * 2013-03-15 2016-04-19 International Business Machines Corporation Testing functional correctness and idempotence of software automation scripts

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105608011A (en) * 2016-03-01 2016-05-25 网易(杭州)网络有限公司 Determination method and device for code testing coverage rate statistical results
CN106201863A (en) * 2016-06-22 2016-12-07 广州唯品会信息科技有限公司 A kind of method and apparatus obtaining code coverage
CN107480066A (en) * 2017-08-18 2017-12-15 网易(杭州)网络有限公司 Code coverage statistical method, device, storage medium, processor and terminal
CN108829580A (en) * 2018-05-07 2018-11-16 百度在线网络技术(北京)有限公司 Multi version test data processing method, device, equipment and storage medium
CN108829593A (en) * 2018-06-05 2018-11-16 平安壹钱包电子商务有限公司 Code coverage calculation and analysis methods, device, equipment and storage medium

Also Published As

Publication number Publication date
CN109766261A (en) 2019-05-17

Similar Documents

Publication Publication Date Title
CN109766261B (en) Coverage test method, coverage test device, computer equipment and storage medium
CN110399293B (en) System test method, device, computer equipment and storage medium
CN106844217B (en) Method and device for embedding point of applied control and readable storage medium
CN109446068B (en) Interface test method, device, computer equipment and storage medium
CN108427613B (en) Abnormal interface positioning method and device, computer equipment and storage medium
US20060294503A1 (en) Code coverage analysis
CN111475324B (en) Log information analysis method, device, computer equipment and storage medium
CN111026647B (en) Method and device for acquiring code coverage rate, computer equipment and storage medium
CN110825619A (en) Automatic generation method and device of interface test case and storage medium
CN112559365A (en) Test case screening method and device, computer equipment and storage medium
CN112559354A (en) Front-end code specification detection method and device, computer equipment and storage medium
CN108874661B (en) Test mapping relation library generation method and device, computer equipment and storage medium
CN110321284B (en) Test data entry method, device, computer equipment and storage medium
CN113342685A (en) Precise test method and device, computer equipment and storage medium
CN110362479B (en) System upgrade test method and system
US11816479B2 (en) System and method for implementing a code audit tool
CN108399125B (en) Automatic testing method and device, computer equipment and storage medium
CN112380130A (en) Application testing method and device based on call dependency relationship
CN111897727A (en) Software testing method and device, computer equipment and storage medium
CN112540924A (en) Interface automation test method, device, equipment and storage medium
CN110750443A (en) Webpage testing method and device, computer equipment and storage medium
CN111124894B (en) Code coverage rate processing method and device and computer equipment
CN111597069A (en) Program processing method, program processing apparatus, electronic device, and storage medium
CN111459796B (en) Automated testing method, apparatus, computer device and storage medium
CN111444093B (en) Method and device for determining quality of project development process and computer equipment

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