CN107480066B - Code coverage rate statistical method, device, storage medium, processor and terminal - Google Patents

Code coverage rate statistical method, device, storage medium, processor and terminal Download PDF

Info

Publication number
CN107480066B
CN107480066B CN201710710668.9A CN201710710668A CN107480066B CN 107480066 B CN107480066 B CN 107480066B CN 201710710668 A CN201710710668 A CN 201710710668A CN 107480066 B CN107480066 B CN 107480066B
Authority
CN
China
Prior art keywords
code
server
coverage rate
task
file
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
CN201710710668.9A
Other languages
Chinese (zh)
Other versions
CN107480066A (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.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network 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 Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN201710710668.9A priority Critical patent/CN107480066B/en
Publication of CN107480066A publication Critical patent/CN107480066A/en
Application granted granted Critical
Publication of CN107480066B publication Critical patent/CN107480066B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

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

Abstract

The invention discloses a code coverage rate statistical method, a device, a storage medium, a processor and a terminal. The method comprises the following steps: triggering a first server to send a notification message to a second server, wherein the first server is used for carrying out version management on the modified code file, the second server is used for establishing and updating a coverage rate statistical task set associated with the modified code file, and the notification message is used for notifying the second server to determine the coverage rate statistical task set; acquiring a coverage rate statistic task to be tested from a coverage rate statistic task set; and carrying out code coverage rate statistics on the modified codes or the files after the codes are compiled according to the coverage rate statistic tasks to be tested, and uploading the code coverage rate statistical results to a second server. The invention solves the technical problems that the establishment and the update of the code coverage rate test scheme tasks provided in the related technology need manual participation, the operation process is complex and the test efficiency is low.

Description

Code coverage rate statistical method, device, storage medium, processor and terminal
Technical Field
The invention relates to the field of computers, in particular to a code coverage rate statistical method, a device, a storage medium, a processor and a terminal.
Background
Coverage testing is an important indicator for measuring the quality of a test. After a software product is subjected to a plurality of tests such as unit test, assembly test, integration test, interface test, and the like, the test quality needs to be examined. If the testing process only covers a small portion of the code of the software product, it is difficult to ensure the quality of the test no matter how many test cases are written. Conversely, if the testing process has covered a substantial portion of the code of the software product, then the quality of the software product may be measured based on the test results.
The currently widely used code coverage methods mainly include: statement override and judgment override.
The first method, Statement overlay (also called Line overlay), Segment overlay (Segment overlay) or Basic Block overlay (Basic Block overlay), is the most commonly used overlay method for measuring whether each executable Statement in the tested code is executed completely. An "executable statement" as referred to herein does not contain a header declaration such as C + +, a code comment, an empty line, etc., but merely counts how many lines of code that can be executed have been executed.
It should be noted that the curly braces { } of a single row are also counted from time to time. The statement overlay is often regarded as the "weakest overlay", which only focuses on the execution statements in the overlay code, but does not consider other situations such as the combination of various branches, thereby causing a limitation on the test effect and difficulty in sufficiently finding the problems in the code.
The second method is to measure whether each determined Branch in the tested code is completely tested, and the second method is to determine Coverage (precision Coverage), also called Branch Coverage (Branch Coverage), All boundary Coverage (All-Edges Coverage), Basic Path Coverage (Basic Path Coverage) or determination Path Coverage (precision-Path).
Based on the above introduction, the related art provides a judgment coverage policy based on native code, which may include the following steps:
step one, establishing a task, wherein a task name, a responsibility program, a responsibility test engineer (QA) and a specific version number (svn _ ver) of an associated project version management system are required to be input so as to manually establish the task. When a tester submits local code modification to a project version management system (svn), the related svn _ ver needs to be added manually to update task information.
Step two, covering record, wherein the file modified by the associated svn _ ver needs to be set as a tracking object of the covering test in the step, and which codes are executed in the tracked file are recorded.
And step three, uploading the coverage rate, wherein the uploading operation needs to be manually triggered in the step to upload the task information, the local code file and the coverage rate result to the server.
And fourthly, checking the coverage rate at the server, checking a statistical result about the coverage rate in the step, and displaying a modified function, wherein the font of the uncovered code is red, and the font of the covered code is blue.
However, the above code coverage test scheme has the following technical drawbacks:
(1) the operations of establishing an updating task, uploading coverage rate and the like can be completed only by manual triggering. If the test terminal restarts, the test task also needs to be manually resumed.
(2) A large amount of test logics are arranged at a test terminal, the code updating cost is high, and forced updating cannot be realized.
(3) A plurality of responsibility programs and responsibility QAs cannot be set, coverage rate results of a plurality of test terminals only can be mutually covered and cannot be combined, and cooperation is not facilitated.
In view of the above problems, no effective solution has been proposed.
Disclosure of Invention
One embodiment of the invention provides a code coverage rate statistical method, a device, a storage medium, a processor and a terminal, which are used for at least solving the technical problems that manual participation is needed for establishing and updating a code coverage rate test scheme task provided in the related technology, the operation process is complex and the test efficiency is low.
According to an embodiment of the present invention, there is provided a code coverage statistical method, including:
triggering a first server to send a notification message to a second server, wherein the first server is used for carrying out version management on the modified code file, the second server is used for establishing and updating a coverage rate statistical task set associated with the modified code file, and the notification message is used for notifying the second server to determine the coverage rate statistical task set; acquiring a coverage rate statistic task to be tested from a coverage rate statistic task set; and carrying out code coverage rate statistics on the modified codes or the files after the codes are compiled according to the coverage rate statistic tasks to be tested, and uploading the code coverage rate statistical results to a second server.
Optionally, the obtaining of the coverage statistic task to be tested from the coverage statistic task set includes one of: selecting a coverage rate statistic task corresponding to the task identifier from a coverage rate statistic task set according to the received task identifier; setting part or all of the coverage rate counting tasks in the coverage rate counting task set as coverage rate counting tasks to be tested according to the test end identification; each coverage rate statistic task in the coverage rate statistic task set meets the following conditions: the code branch processed locally by the testing terminal is the same as the code branch processed by each coverage rate statistical task, the code version number processed locally by the testing terminal is greater than or equal to the initial version number of each coverage rate statistical task in the coverage rate statistical task set, part or all of the coverage rate statistical tasks are in a testing state, and the initial version number refers to the previous version number adjacent to the version number when each coverage rate statistical task is established on the branch to which each coverage rate statistical task belongs.
Optionally, performing code coverage statistics on the modified code or the compiled file of the code according to the coverage statistical task to be tested, and uploading the code coverage statistical result to the second server includes: monitoring the detection process of the coverage rate of the code or the file after the code is compiled on the test end in real time according to the coverage rate statistic task to be tested; reporting a current latest code coverage rate statistical result to a second server every interval of a preset time; uploading the code coverage rate statistical result to a second server when the execution of the coverage rate detection process is finished; the information carried in the code coverage rate statistical result reported each time at least comprises the following information: the file identification of the modified code file, the task identification of the coverage rate statistic task to be tested, the version number of the code running on the testing end and the coverage range related to the code coverage rate statistic.
Optionally, performing code coverage statistics on the modified code or the compiled file of the code according to the coverage statistics task to be tested, and uploading the code coverage statistics result to the second server further includes: determining that there is currently a modified portion of code that is not sent to the first server; and reporting the file identification of the modified code part and the file difference content to a second server, wherein the file difference content is obtained by comparing the modified code part with a corresponding file stored on the first server.
Optionally, after performing code coverage statistics on the modified code or the compiled file of the code according to the coverage statistics task to be tested, and uploading the code coverage statistics result to the second server, the method further includes: accessing a second server, and inquiring a code coverage statistical result, wherein the code coverage statistical result corresponding to each test terminal on the second server is separated from each other, the code file associated with the code coverage statistical result is completely displayed, the background of a first part of codes associated with the code coverage statistical result is displayed as a first color, the background of a second part of codes not associated with the code coverage statistical result is displayed as a second color, the codes covered in the first part of codes are displayed as a third color, the codes uncovered in the first part of codes are displayed as a fourth color, the codes covered in the second part of codes are displayed as a fifth color, and the codes uncovered in the second part of codes are displayed as a sixth color.
Optionally, the second server is further configured to extract the task identifier from the notification message after the notification message is obtained, obtain, according to the task identifier, a test object file associated with the coverage rate statistics task to be tested from the first server, obtain, from the third server, tester information and task description information associated with the coverage rate statistics task to be tested, and establish the coverage rate statistics task to be tested based on the test object file and the tester information.
According to an embodiment of the present invention, there is provided another code coverage statistical method, including:
receiving a code coverage rate statistical result uploaded by the testing end, wherein the code coverage rate statistical result is recorded by a code file which is associated with a task and distributed to the testing end from the second server by the testing end in the running process of the testing end; and adjusting the uploaded code coverage statistical result or the code coverage statistical result stored on the second server.
Optionally, adjusting the uploaded code coverage statistics or the code coverage statistics stored on the second server includes one of: determining a modified code part which is not sent to a first server currently exists, and adjusting a code coverage rate statistical result according to the position information of the modified code part; adjusting the code coverage rate statistical result according to the synchronization result of the first version number of the code file on the test end and the second version number of the corresponding file on the second server; and adjusting the code coverage rate statistical result according to the modified code file on the first server, wherein the first server is used for performing version management on the modified code file.
Optionally, adjusting the code coverage statistical result according to the synchronization result of the first version number of the code file on the test end and the second version number of the corresponding file on the second server includes at least one of: when the first version number is the same as the second version number, adding the code coverage rate statistical result to a code coverage rate statistical result of the second server; when the first version number is smaller than the second version number, acquiring file difference content between the second version number and the first version number, adjusting the code coverage rate statistical result according to the file difference content, and adding the adjusted code coverage rate statistical result to the code coverage rate statistical result of the second server; when the first version number is larger than the second version number, acquiring first file difference content between the first version number and the initial version number, and adjusting the content required to be covered by the code according to the first file difference content; and acquiring second file difference content between the first version number and the second version number, adjusting the code coverage rate statistical result on the second server according to the first file difference content and the second file difference content, adding the newly uploaded code coverage rate statistical result into the adjusted code coverage rate statistical result on the second server, and simultaneously replacing the code file version on the second server with the first version number.
Optionally, the adjusting the code coverage statistics according to the modified code file on the first server includes: setting the version number of the code file on the second server as a first version number and setting the version number of the code file updated on the first server as a second version number; acquiring first file difference content between the second version number and the initial version number, and adjusting the content to be covered by the code according to the first file difference content; and acquiring second file difference content between the second version number and the first version number, and adjusting the code coverage rate statistical result on the second server according to the second file difference content.
According to an embodiment of the present invention, there is also provided a code coverage statistic apparatus, including:
the system comprises a triggering module, a first server and a second server, wherein the triggering module is used for triggering the first server to send a notification message to the second server, the first server is used for carrying out version management on a modified code file, the second server is used for establishing and updating a coverage rate statistical task set associated with the modified code file, and the notification message is used for notifying the second server to determine the coverage rate statistical task set; the acquisition module is used for acquiring a coverage rate statistical task to be tested from the coverage rate statistical task set; and the counting module is used for carrying out code coverage rate counting on the modified codes or the files after the codes are compiled according to the coverage rate counting tasks to be tested and uploading the code coverage rate counting results to the second server.
Optionally, the obtaining module is configured to obtain, from the coverage rate statistics task set, a coverage rate statistics task to be tested, where the coverage rate statistics task to be tested includes one of: selecting a coverage rate statistic task corresponding to the task identifier from a coverage rate statistic task set according to the received task identifier; setting part or all of the coverage rate counting tasks in the coverage rate counting task set as coverage rate counting tasks to be tested according to the test end identification; each coverage rate statistic task in the coverage rate statistic task set meets the following conditions: the code branch processed locally by the testing terminal is the same as the code branch processed by each coverage rate statistical task, the code version number processed locally by the testing terminal is greater than or equal to the initial version number of each coverage rate statistical task in the coverage rate statistical task set, part or all of the coverage rate statistical tasks are in a testing state, and the initial version number refers to the previous version number adjacent to the version number when each coverage rate statistical task is established on the branch to which each coverage rate statistical task belongs.
Optionally, the statistics module comprises: the monitoring unit is used for monitoring the code on the testing end or the coverage rate detection process of the file after the code is compiled in real time according to the coverage rate statistic task to be tested; the first reporting unit is used for reporting the current latest code coverage rate statistical result to the second server every interval preset time length and uploading the code coverage rate statistical result to the second server when the execution of the coverage rate detection process is finished; the information carried in the code coverage rate statistical result reported each time at least comprises the following information: the file identification of the modified code file, the task identification of the coverage rate statistic task to be tested, the version number of the code running on the testing end and the coverage range related to the code coverage rate statistic.
Optionally, the statistic module further comprises: a determining unit for determining that there is currently a modified code portion that is not sent to the first server; and the second reporting unit is used for reporting the file identification of the modified code part and the file difference content to a second server, wherein the file difference content is obtained by comparing the modified code part with a corresponding file stored on the first server.
Optionally, the apparatus further comprises: and the query module is used for accessing the second server and querying the code coverage statistical result, wherein the code coverage statistical result corresponding to each test terminal on the second server is mutually separated, the code file associated with the code coverage statistical result is completely displayed, the background of a first part of codes associated with the code coverage statistical result is displayed as a first color, the background of a second part of codes not associated with the code coverage statistical result is displayed as a second color, the codes covered in the first part of codes are displayed as a third color, the codes uncovered in the first part of codes are displayed as a fourth color, the codes covered in the second part of codes are displayed as a fifth color, and the codes uncovered in the second part of codes are displayed as a sixth color.
According to an embodiment of the present invention, there is provided another code coverage statistic apparatus, including:
the receiving module is used for receiving a code coverage rate statistical result uploaded by the testing end, wherein the code coverage rate statistical result is recorded in the process that a code file related to a task distributed by the testing end from the second server to the testing end runs on the testing end; and the adjusting module is used for adjusting the uploaded code coverage rate statistical result or the code coverage rate statistical result stored in the second server.
Optionally, the adjusting module is configured to adjust the uploaded code coverage statistical result or the code coverage statistical result stored in the second server, and the adjusting module is configured to: determining a modified code part which is not sent to a first server currently exists, and adjusting a code coverage rate statistical result according to the position information of the modified code part; adjusting the code coverage rate statistical result according to the synchronization result of the first version number of the code file on the test end and the second version number of the corresponding file on the second server; and adjusting the code coverage rate statistical result according to the modified code file on the first server, wherein the first server is used for performing version management on the modified code file.
Optionally, the adjusting module is configured to adjust the code coverage statistical result according to a synchronization result between the first version number of the code file on the test end and the second version number of the corresponding file on the second server, where the adjusting includes at least one of: when the first version number is the same as the second version number, adding the code coverage rate statistical result to a code coverage rate statistical result of the second server; when the first version number is smaller than the second version number, acquiring file difference content between the second version number and the first version number, adjusting the code coverage rate statistical result according to the file difference content, and adding the adjusted code coverage rate statistical result to the code coverage rate statistical result of the second server; when the first version number is larger than the second version number, acquiring first file difference content between the first version number and the initial version number, and adjusting the content required to be covered by the code according to the first file difference content; and acquiring second file difference content between the first version number and the second version number, adjusting the code coverage rate statistical result on the second server according to the first file difference content and the second file difference content, adding the newly uploaded code coverage rate statistical result into the adjusted code coverage rate statistical result on the second server, and simultaneously replacing the code file version on the second server with the first version number.
Optionally, the adjusting module, configured to adjust the code coverage statistical result according to the modified code file on the first server, includes the following steps: setting the version number of the code file on the second server as a first version number and setting the version number of the code file updated on the first server as a second version number; acquiring first file difference content between the second version number and the initial version number, and adjusting the content to be covered by the code according to the first file difference content; and acquiring second file difference content between the second version number and the first version number, and adjusting the code coverage rate statistical result on the second server according to the second file difference content.
According to an embodiment of the present invention, there is further provided a storage medium including a stored program, where the apparatus on which the storage medium is located is controlled to execute the code coverage statistical method when the program runs.
According to an embodiment of the present invention, there is further provided a processor, configured to execute a program, where the program executes the code coverage statistical method.
In the embodiment of the invention, a first server is triggered to send a notification message to a second server, wherein the first server is used for carrying out version management on a modified code file, the second server is used for establishing and updating a coverage rate statistical task set associated with the modified code file, and the notification message is used for notifying the second server of determining the coverage rate statistical task set, and acquiring a coverage rate statistical task to be tested from the coverage rate statistical task set; the method comprises the steps of conducting code coverage rate statistics on modified codes or files after code compilation according to coverage rate statistics tasks to be tested, and uploading code coverage rate statistics results to a second server, so that the technical effects of reducing labor cost and improving code coverage rate test efficiency and accuracy are achieved, and the technical problems that manual participation is needed for establishment and updating of code coverage rate test scheme tasks provided in the related technology, the operation process is complex, and the test efficiency is low are solved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
FIG. 1 is a flow diagram of a code coverage statistics method according to one embodiment of the invention;
FIG. 2 is a diagram of a code coverage statistics method in accordance with a preferred embodiment of the present invention;
FIG. 3 is a flow diagram of another code coverage statistics method according to one embodiment of the invention;
FIG. 4 is a block diagram of a code coverage statistic apparatus according to an embodiment of the present invention;
FIG. 5 is a block diagram of a code coverage statistic apparatus according to a preferred embodiment of the present invention;
fig. 6 is a block diagram of another code coverage statistic apparatus according to an embodiment of the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
In accordance with one embodiment of the present invention, there is provided an embodiment of a code coverage statistics method, it is noted that the steps illustrated in the flowchart of the figure may be performed in a computer system such as a set of computer-executable instructions, and that while a logical order is illustrated in the flowchart, in some cases the steps illustrated or described may be performed in an order different than here.
Fig. 1 is a flowchart of a code coverage statistical method according to an embodiment of the present invention, as shown in fig. 1, the method includes the following steps:
step S12, triggering a first server to send a notification message to a second server, wherein the first server is used for performing version management on the modified code file, the second server is used for establishing and updating a coverage rate statistics task set associated with the modified code file, and the notification message is used for notifying the second server to determine the coverage rate statistics task set;
step S14, obtaining a coverage rate statistic task to be tested from a coverage rate statistic task set;
and step S16, carrying out code coverage rate statistics on the modified code or the file after the code is compiled according to the coverage rate statistic task to be tested, and uploading the code coverage rate statistical result to the second server.
Through the steps, a first server is triggered to send a notification message to a second server, wherein the first server is used for carrying out version management on the modified code file, the second server is used for establishing and updating a coverage rate statistical task set associated with the modified code file, and the notification message is used for notifying the second server of determining the coverage rate statistical task set, and acquiring a coverage rate statistical task to be tested from the coverage rate statistical task set; the method comprises the steps of conducting code coverage rate statistics on modified codes or files after code compilation according to coverage rate statistics tasks to be tested, and uploading code coverage rate statistics results to a second server, so that the technical effects of reducing labor cost and improving code coverage rate test efficiency and accuracy are achieved, and the technical problems that manual participation is needed for establishment and updating of code coverage rate test scheme tasks provided in the related technology, the operation process is complex, and the test efficiency is low are solved.
It should be noted that the code coverage policy adopted by at least some embodiments of the present invention is mainly to determine coverage.
In a preferred implementation process, the second server is further configured to extract the task identifier from the notification message after the notification message is obtained, obtain, according to the task identifier, a test object file associated with the coverage rate statistical task to be tested from the first server, obtain, from the third server, tester information and task description information associated with the coverage rate statistical task to be tested, and establish the coverage rate statistical task to be tested based on the test object file and the tester information.
The coverage rate statistical task to be tested comprises three elements: test object files, tester information, and code that the task needs to cover. In the specific implementation process, the establishment and the updating of the coverage rate statistical task to be tested can be triggered by the action of submitting and modifying the code file by a local programmer of the terminal.
Fig. 2 is a schematic diagram of a code coverage statistical method according to a preferred embodiment of the present invention, as shown in fig. 2, first, after a test end locally submits a modified code file to a first server (for example, a version management server), the first server is triggered to send a notification message to a second server, where the notification message may include, but is not limited to: the file identification of the modified code file, the version number (e.g., version 1) of the modified code file, and log information. Secondly, the second server extracts the task identification from the log information. If the task identification # 1 indicates no over-commit is required, no processing may be done. And thirdly, the second server can acquire a test object file associated with the coverage rate statistical task to be tested from the first server according to the task identifier and acquire tester information and task description information associated with the coverage rate statistical task to be tested from the third server. If the relevant information cannot be acquired or the query fails, recording the query process and sending an alarm. Then, if the coverage rate statistic task to be tested corresponding to the task identifier is not established, setting a previous version 0 of the version 1 as an initial version, submitting the modified code file to add into a task tracking list, setting the ending version of the task as the version 1, and generating the content to be covered by the modified code file according to the difference content between the initial version and the ending version.
In a specific implementation process, a library ply of python can be used for simple lexical analysis to obtain a participle (token) of a code file of version 1 so as to extract a start line and an end line of a judgment branch such as if, while, for and the like. If a particular line of valid code is modified, then the entire decision branch to which it belongs needs to be covered. For example:
2215 if ITEM_SHOW_NUM_ECP[iTcon]then
2216 self.Label_Num:setVisible(true)
2217 (newly added) self, Label _ Num, setText (ITEM _ SHOW _ NUM _ ECP [ iTcon ])
The 2217 th line is newly added in the modified code file, and the 2215 th-2217 th lines of the whole judgment branch need to be covered.
Optionally, in step S14, obtaining the coverage rate statistics task to be tested from the coverage rate statistics task set may include one of the following ways:
selecting a coverage rate statistic task corresponding to a task identifier from a coverage rate statistic task set according to the received task identifier;
setting part or all of the coverage rate counting tasks in the coverage rate counting task set as coverage rate counting tasks to be tested according to the test end identification;
each coverage rate statistic task in the coverage rate statistic task set meets the following conditions: the code branch processed locally by the testing terminal is the same as the code branch processed by each coverage rate statistical task, the code version number processed locally by the testing terminal is greater than or equal to the initial version number of each coverage rate statistical task in the coverage rate statistical task set, part or all of the coverage rate statistical tasks are in a testing state, and the initial version number refers to the previous version number adjacent to the version number when each coverage rate statistical task is established on the branch to which each coverage rate statistical task belongs.
In the execution process of the coverage rate statistical task to be tested, the attribution of the testing end needs to be determined first, so that the coverage rate statistical results submitted by different testing personnel are distinguished. A common way of distinguishing is according to the Internet Protocol (IP) address of the access. For the test end of terminal types such as a smart phone, a personal computer and the like, each terminal shares an IP address, the IP address in a local area network is relatively stable, and the IP address is a certificate which can be used by the test end to access a service end without logging in. However, if the test end is built on a server, for example: if a plurality of game servers are built on one virtual machine, the game servers share the same IP address. In this case, the attribution may be determined according to a socket (sokent) port opened to the outside by the game server, and the attribution identification information is uploaded to the server by the testing terminal.
After the attribution problem is determined, the second server can be accessed to obtain the coverage rate task information belonging to the second server. Specifically, the testing end may select to input a specific task identifier to test a corresponding single coverage rate statistical task, or may not input a specific task identifier to test a part or all of the coverage rate statistical tasks to be tested. And each testable coverage statistic task meets the following conditions: the code branch processed locally by the testing end is the same as the code branch processed by each coverage rate statistical task, the code version number processed locally by the testing end is greater than or equal to the initial version number of each coverage rate statistical task in the coverage rate statistical task set, and part or all of the coverage rate statistical tasks are in a testing state (the coverage rate statistical tasks are in testing, hanging and closing states). Finally, the information obtained by the testing end from the second server may include, but is not limited to: the task tracking method comprises the steps of task identification, submitted branch information, an initial version number and a task tracking list, and further monitoring the covering execution result of a modified code file contained in the task tracking list.
Optionally, in step S16, performing code coverage statistics on the modified code or the compiled file of the code according to the coverage statistics task to be tested, and uploading the code coverage statistics result to the second server may include the following steps:
step S161, monitoring the detection process of the coverage rate of the code or the file after the code is compiled on the test end in real time according to the coverage rate statistic task to be tested;
step S162, reporting the current latest code coverage rate statistical result to a second server at intervals of preset duration;
step S163, uploading the statistical result of the code coverage rate to the second server when the execution of the coverage rate detection process is finished;
the information carried in the code coverage rate statistical result reported each time at least comprises the following information: the file identification of the modified code file, the task identification of the coverage rate statistic task to be tested, the version number of the code running on the testing end and the coverage range related to the code coverage rate statistic.
In the process of monitoring the execution result of the coverage rate, the coverage rate result needs to be automatically uploaded to the second server every preset time (for example, 5 minutes) to prevent the loss of the coverage rate statistical result due to abnormal exit of the testing terminal. In addition, a coverage rate statistical result is uploaded once when the test terminal is normally quitted (the server is shut down and the test terminal application is quitted). After the uploading of the coverage rate statistical result is finished, the task under test on the second server can be updated, and whether a tracking file or a branch to be tested is newly added or not is determined. If the test task has been closed or suspended, tracking of the task may be suspended.
It should be noted that, if the code of the test end is updated (for example, the code is updated in a hot state, the client is upgraded, and the server is restarted), the coverage statistics result uploading operation needs to be performed once, because: subsequent code may change. For this purpose, the relevant program for recovering the test task can be added in the callback process of the code update. If the test end allows data archiving, the data archiving can be performed according to the task information when the task is set for the first time, and whether the original test task meets the branch and version requirements of the newly added code or not is detected. If the requirements are met, continuing to track the task; if the requirements are not met, the task is suspended from being tracked. If the testing end does not want to archive the data, the second server can be accessed after the updating so as to obtain the coverage rate statistical task to be tested belonging to the testing end and automatically set the tracking.
In addition, the information carried in the code coverage statistics of each report may include, but is not limited to: the file identification of the modified code file, the task identification of the coverage rate statistic task to be tested, the version number of the modified code file and the coverage range related to the code coverage rate statistic.
Optionally, in step S16, performing code coverage statistics on the modified code or the compiled file of the code according to the coverage statistics task to be tested, and uploading the code coverage statistics result to the second server may further include the following steps:
step S164, determining that there is currently a modified code portion that is not sent to the first server;
step S165, reporting the file identifier of the modified code portion and the file difference content to the second server, wherein the file difference content is obtained by comparing the modified code portion with a corresponding file stored on the first server.
If the modified code file which is not uploaded to the first server exists in the test end, the test end needs to report the file identification of the modified code part, the identification information of the first server and the file difference content obtained by comparing the modified code part with the corresponding file stored in the first server to the second server.
Optionally, in step S16, after performing code coverage statistics on the modified code or the compiled file of the code according to the coverage statistics task to be tested, and uploading the code coverage statistics result to the second server, the method may further include the following steps:
and step S17, accessing a second server, and inquiring a code coverage statistical result, wherein the code coverage statistical result corresponding to each test terminal on the second server is separated from each other, the code file associated with the code coverage statistical result is completely displayed, the background of a first part of codes associated with the code coverage statistical result is displayed as a first color, the background of a second part of codes not associated with the code coverage statistical result is displayed as a second color, the codes covered in the first part of codes are displayed as a third color, the codes not covered in the first part of codes are displayed as a fourth color, the codes covered in the second part of codes are displayed as a fifth color, and the codes not covered in the second part of codes are displayed as a sixth color.
During the process of accessing the second server, a coverage statistics task associated with the visitor is displayed by default, and clicking on the task may enter a task overview page. Then after clicking on a particular tracking task, a coverage statistics view page is entered. When displaying, the uppermost branch of a code file is taken as a minimum display block (function, judgment branch outside the function), as long as the minimum display block is changed, the content of the whole minimum display block is displayed, otherwise, the content of the minimum display block is not displayed. The presentation page may incorporate a code difference display and a coverage result display to facilitate viewing whether the content that needs to be covered is correct. And if the test end is proprietary, respectively displaying the coverage rate result for the attributed test end. There may be other parts of the task modification in the code or it may not be possible to run to fault tolerant code, for which graying out can be ignored, and mere addition or deletion of an annotation line or an empty line does not require overwriting of the current branch. In addition, the branch background that needs to be covered is displayed in a first color (e.g., gray), and the branch background that does not need to be covered is displayed in a second color (e.g., white). The code in the branch that needs to be covered that is not covered is displayed in a third color (e.g., red), and the code in the branch that needs to be covered that is covered is displayed in a fourth color (e.g., blue). The uncovered codes in the branch that need not be covered are displayed in a fifth color (e.g., gray) and the covered codes in the branch that need not be covered are displayed in a sixth color (e.g., light blue).
Based on the analysis, if the second server is accessed mistakenly when the first server is updated, the original version information which is recorded last time is recorded, and when the first server hook transmits new version information, the log record between the original version information and the new version information is inquired, and whether unprocessed versions are missed or not is determined. And if the second server queries the third server wrongly, recording the version number of the query mistake, and querying again at intervals. If the associated task is forgotten to be marked in the log record submitted by the programmer, the corresponding version number needs to be recorded and the task list number association can be manually filled in. If the programmer associates an incorrect single number, resulting in either an excessively large starting version setting or an excessively small ending version setting for the task, then the repair may be done manually. If the second server records the coverage rate statistical result corresponding to each version submitted by the testing end, and finds that the specific coverage rate calculation is wrong, the coverage rate statistical result can be repaired and recalculated in a manual mode.
Through the embodiment provided by the invention, the following technical effects can be achieved: automatically establishing, updating and recovering a coverage rate statistical task, and automatically uploading a code coverage rate statistical result so as to reduce labor cost and possible omission; for a multi-person cooperation project, merging and affiliation checking of coverage rates are supported, so that the coverage rate statistical result can be better monitored; the logic of the test end is simplified, and the function implementation is arranged at the service end as much as possible, so that the cost of code updating is reduced.
There is also provided, in accordance with an embodiment of the present invention, another embodiment of a method for code coverage statistics, including the steps illustrated in the flowchart of the figure as being executable on a computer system, such as a set of computer-executable instructions, and although a logical order is illustrated in the flowchart, in some cases the steps illustrated or described may be executed in an order different than that presented herein.
Fig. 3 is a flowchart of another code coverage statistics method according to an embodiment of the present invention, as shown in fig. 3, the method includes the following steps:
step S32, receiving a code coverage rate statistical result uploaded by the testing end, wherein the code coverage rate statistical result is recorded by the testing end in the running process of a code file associated with a task distributed to the testing end from the second server;
and step S34, adjusting the uploaded code coverage rate statistical result or the code coverage rate statistical result stored in the second server.
Optionally, in step S34, the adjusting the uploaded code coverage statistics or the code coverage statistics stored on the second server may include one of the following:
determining a modified code part which does not exist at present and is not sent to a first server, and adjusting a code coverage rate statistical result according to position information of the modified code part;
adjusting the code coverage rate statistical result according to the synchronization result of the first version number of the code file on the test end and the second version number of the corresponding file on the second server;
and thirdly, adjusting the code coverage rate statistical result according to the modified code file on the first server, wherein the first server is used for performing version management on the modified code file.
In the first method, before uploading the code coverage statistics to the second server, the influence caused by the local difference content needs to be removed. Considering that code coverage rate test is not required to be performed on code which is not submitted to the first server, and local difference content is usually debugging statements added to meet test requirements, for this purpose, the number of rows of the coverage rate statistical result is translated. For example: the difference between the local modified code and the version code on the first server is as follows:
1 if ITEM_SHOW_NUM_ECP[iTcon]then
2 (newly added) debug xxx
3 self.Label_Num:setText(ITEM_SHOW_NUM_ECP[iTcon])
Originally, the statistical result of the code coverage rate required to be uploaded comprises three lines of codes (namely, line 1, line 2 and line 3), but because the line 2 code "debug xxxx" is the local modification content, after the local difference content is abandoned, the statistical result of the code coverage rate required to be uploaded comprises two lines of codes (namely, line 1 and line 2), namely, line 2 is abandoned, and the original line 3 now becomes line 2.
Optionally, as for the second mode, adjusting the code coverage statistical result according to the synchronization result of the first version number of the code file on the testing end and the second version number of the corresponding file on the second server may include one of the following:
(1) when the first version number is the same as the second version number, adding the code coverage rate statistical result to a code coverage rate statistical result of the second server;
(2) when the first version number is smaller than the second version number, acquiring file difference content between the second version number and the first version number, adjusting the code coverage rate statistical result according to the file difference content, and adding the adjusted code coverage rate statistical result to the code coverage rate statistical result of the second server;
(3) when the first version number is larger than the second version number, acquiring first file difference content between the first version number and the initial version number, and adjusting the content required to be covered by the code according to the first file difference content; and acquiring second file difference content between the first version number and the second version number, adjusting the code coverage rate statistical result on the second server according to the first file difference content and the second file difference content, adding the newly uploaded code coverage rate statistical result into the adjusted code coverage rate statistical result on the second server, and simultaneously replacing the code file version on the second server with the first version number.
If the first version number is the same as the second version number, the coverage rate statistical result can be directly added.
And if the first version number is smaller than the second version number, firstly performing line number translation on the coverage rate statistical result according to the file difference content between the second version number and the first version number and discarding the coverage result based on the determined coverage strategy. For example:
2214 echo xxxx
2215 if ITEM_SHOW_NUM_ECP[iTcon]then
2216 self.Label_Num:setVisible(true)
2217 (newly added) self, Label _ Num, setText (ITEM _ SHOW _ NUM _ ECP [ iTcon ])
2218 else
The first version covers rows 2214, 2215, 2216 and 2217, and after the translation process, rows 2214, 2215, 2216 and 2218 are covered, and because the coverage is determined to need to cover rows 2215 and 2216 again, the newly added coverage results are rows 2214 and 2218, and the coverage rate version is the second version.
If the first version number is larger than the second version number, the content to be covered needs to be generated again according to the difference between the first version number and the initial version number of the task, and the content to be covered of the code needs to be adjusted according to the difference content of the first file. Then, the second server records the coverage rate result of the second version, and performs line number translation and coverage result discarding based on the difference between the first version number and the second version number, wherein the coverage rate version is the first version.
Optionally, for the third mode, the adjusting the code coverage statistics according to the modified code file on the first server may include the following steps:
the method comprises the following steps that firstly, the version number of a code file on a second server is set to be a first version number, and the version number of a code file updated on a first server is set to be a second version number;
secondly, acquiring the first file difference content between the second version number and the initial version number, and adjusting the content required to be covered by the code according to the first file difference content; and acquiring second file difference content between the second version number and the first version number, and adjusting the code coverage rate statistical result on the second server according to the second file difference content.
According to an embodiment of the present invention, there is further provided an embodiment of a code coverage statistical apparatus, and fig. 4 is a block diagram of a structure of a code coverage statistical apparatus according to an embodiment of the present invention, as shown in fig. 4, the apparatus includes: a triggering module 10, configured to trigger a first server to send a notification message to a second server, where the first server is configured to perform version management on a modified code file, the second server is configured to establish and update a coverage statistics task set associated with the modified code file, and the notification message is configured to notify the second server to determine the coverage statistics task set; an obtaining module 20, configured to obtain a coverage rate statistics task to be tested from a coverage rate statistics task set; and the counting module 30 is configured to perform code coverage counting on the modified code or the file after the code is compiled according to the coverage counting task to be tested, and upload the code coverage counting result to the second server.
Optionally, the obtaining module 20 is configured to obtain the coverage rate statistics task to be tested from the coverage rate statistics task set, where the coverage rate statistics task to be tested includes one of: selecting a coverage rate statistic task corresponding to the task identifier from a coverage rate statistic task set according to the received task identifier; setting part or all of the coverage rate counting tasks in the coverage rate counting task set as coverage rate counting tasks to be tested according to the test end identification; each coverage rate statistic task in the coverage rate statistic task set meets the following conditions: the code branch processed locally by the testing terminal is the same as the code branch processed by each coverage rate statistical task, the code version number processed locally by the testing terminal is greater than or equal to the initial version number of each coverage rate statistical task in the coverage rate statistical task set, part or all of the coverage rate statistical tasks are in a testing state, and the initial version number refers to the previous version number adjacent to the version number when each coverage rate statistical task is established on the branch to which each coverage rate statistical task belongs.
Optionally, the statistics module 30 comprises: a monitoring unit (not shown in the figure) for monitoring the coverage rate detection process of the code or the file after the code is compiled on the testing end in real time according to the coverage rate statistic task to be tested; a first reporting unit (not shown in the figure), configured to report a current latest code coverage statistical result to the second server at intervals of a preset duration, and when the execution of the coverage detection process is completed, upload the code coverage statistical result to the second server; the information carried in the code coverage rate statistical result reported each time at least comprises the following information: the file identification of the modified code file, the task identification of the coverage rate statistic task to be tested, the version number of the code running on the testing end and the coverage range related to the code coverage rate statistic.
Optionally, the statistic module 30 further includes: a determining unit (not shown in the figure) for determining that there is currently a modified code portion that is not sent to the first server; a second reporting unit (not shown in the figure), configured to report the file identifier of the modified code portion and the file difference content to the second server, where the file difference content is obtained by comparing the modified code portion with a corresponding file stored in the first server.
Optionally, fig. 5 is a block diagram of a code coverage rate statistics apparatus according to a preferred embodiment of the present invention, and as shown in fig. 5, the apparatus further includes: and the query module 40 is used for accessing the second server and querying the code coverage statistical result, wherein the code coverage statistical result corresponding to each test terminal on the second server is separated from each other, the code file associated with the code coverage statistical result is completely displayed, the background of a first part of codes associated with the code coverage statistical result is displayed as a first color, the background of a second part of codes not associated with the code coverage statistical result is displayed as a second color, the codes covered in the first part of codes are displayed as a third color, the codes uncovered in the first part of codes are displayed as a fourth color, the codes covered in the second part of codes are displayed as a fifth color, and the codes uncovered in the second part of codes are displayed as a sixth color.
According to an embodiment of the present invention, there is provided another embodiment of a code coverage statistical apparatus, and fig. 6 is a block diagram of another code coverage statistical apparatus according to an embodiment of the present invention, as shown in fig. 6, the apparatus includes: a receiving module 50, configured to receive a code coverage statistical result uploaded by the testing end, where the code coverage statistical result is recorded by a code file associated with a task distributed by the testing end from the second server to the testing end in an operation process of the testing end; and an adjusting module 60, configured to adjust the uploaded code coverage statistical result or the code coverage statistical result stored in the second server.
Optionally, the adjusting module 60 is configured to adjust the uploaded code coverage statistics or the code coverage statistics stored on the second server, where the adjusting includes one of: determining a modified code part which is not sent to a first server currently exists, and adjusting a code coverage rate statistical result according to the position information of the modified code part; adjusting the code coverage rate statistical result according to the synchronization result of the first version number of the code file on the test end and the second version number of the corresponding file on the second server; and adjusting the code coverage rate statistical result according to the modified code file on the first server, wherein the first server is used for performing version management on the modified code file.
Optionally, the adjusting module 60 is configured to adjust the code coverage statistical result according to a synchronization result between the first version number of the code file on the testing end and the second version number of the corresponding file on the second server, where the adjustment includes at least one of: when the first version number is the same as the second version number, adding the code coverage rate statistical result to a code coverage rate statistical result of the second server; when the first version number is smaller than the second version number, acquiring file difference content between the second version number and the first version number, adjusting the code coverage rate statistical result according to the file difference content, and adding the adjusted code coverage rate statistical result to the code coverage rate statistical result of the second server; when the first version number is larger than the second version number, acquiring first file difference content between the first version number and the initial version number, and adjusting the content required to be covered by the code according to the first file difference content; and acquiring second file difference content between the first version number and the second version number, adjusting the code coverage rate statistical result on the second server according to the first file difference content and the second file difference content, adding the newly uploaded code coverage rate statistical result into the adjusted code coverage rate statistical result on the second server, and simultaneously replacing the code file version on the second server with the first version number.
Optionally, the adjusting module 60, configured to adjust the code coverage statistics according to the modified code file on the first server, includes the following steps: setting the version number of the code file on the second server as a first version number and setting the version number of the code file updated on the first server as a second version number; acquiring first file difference content between the second version number and the initial version number, and adjusting the content to be covered by the code according to the first file difference content; and acquiring second file difference content between the second version number and the first version number, and adjusting the code coverage rate statistical result on the second server according to the second file difference content.
According to an embodiment of the present invention, there is further provided a storage medium including a stored program, where the apparatus on which the storage medium is located is controlled to execute the code coverage statistical method when the program runs. The storage medium may include, but is not limited to: various media capable of storing program codes, such as a U disk, a Read Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk.
According to an embodiment of the present invention, there is further provided a processor, configured to execute a program, where the program executes the code coverage statistical method. The processor may include, but is not limited to: a Microprocessor (MCU) or a programmable logic device (FPGA), etc.
According to an embodiment of the present invention, there is also provided a terminal, including: one or more processors, a memory, a display device, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs for performing the code coverage statistics method. In some embodiments, the terminal may be a terminal device such as a smart phone (e.g., an Android phone, an iOS phone, etc.), a tablet computer, a palmtop computer, and a Mobile Internet Device (MID), a PAD, and the like. The display device may be a touch screen type Liquid Crystal Display (LCD) that enables a user to interact with a user interface of the terminal. In addition, the terminal may further include: an input/output interface (I/O interface), a Universal Serial Bus (USB) port, a network interface, a power source, and/or a camera.
According to an embodiment of the present invention, there is also provided a server, including: one or more processors, a memory, a display device, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs for performing the code coverage statistics method. In some embodiments, the server is configured to receive or transmit data via a network. The specific example of the network may include a wireless network provided by a communication provider of the service end. In one example, the server includes a network adapter (NIC) that can be connected to other network devices through the base station to communicate with the internet. In one example, the server may include a Radio Frequency (RF) module, which is used to communicate with the internet in a wireless manner. The test terminal may be connected via a data network connection or electronically to a server (e.g., game server, security server, resource server). The data network connection may be a local area network connection, a wide area network connection, an internet connection, or other type of data network connection.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
In the above embodiments of the present invention, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed technology can be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units may be a logical division, and in actual implementation, there may be another division, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

Claims (20)

1. A code coverage statistics method, comprising:
triggering a first server to send a notification message to a second server, wherein the first server is used for performing version management on a modified code file, the second server is used for establishing and updating a coverage rate statistics task set associated with the modified code file, and the notification message is used for notifying the second server to determine the coverage rate statistics task set;
acquiring a coverage rate statistic task to be tested from the coverage rate statistic task set;
performing code coverage rate statistics on the modified code or the file after the code is compiled according to the coverage rate statistics task to be tested, and uploading a code coverage rate statistical result to the second server;
the second server is further configured to extract a task identifier from the notification message after the notification message is obtained, obtain a test object file associated with the coverage rate statistical task to be tested from the first server according to the task identifier, obtain tester information and task description information associated with the coverage rate statistical task to be tested from a third server, and establish the coverage rate statistical task to be tested based on the test object file and the tester information.
2. The method of claim 1, wherein obtaining the coverage statistics task to be tested from the set of coverage statistics tasks comprises one of:
selecting the coverage rate statistic task corresponding to the task identifier from the coverage rate statistic task set according to the received task identifier;
setting part or all of the coverage rate statistic tasks in the coverage rate statistic task set as the coverage rate statistic tasks to be tested according to the test end identification;
wherein each coverage statistic task in the coverage statistic task set satisfies the following conditions: the code branch processed locally by the testing terminal is the same as the code branch processed by each coverage rate statistical task, the code version number processed locally by the testing terminal is greater than or equal to the initial version number of each coverage rate statistical task in the coverage rate statistical task set, all or part of the coverage rate statistical tasks are in a testing state, and the initial version number refers to the previous version number adjacent to the version number when each coverage rate statistical task is established on the branch to which each coverage rate statistical task belongs.
3. The method of claim 1, wherein performing code coverage statistics on the modified code or the compiled file of code according to the coverage statistics task to be tested, and uploading the code coverage statistics result to the second server comprises:
monitoring the detection process of the coverage rate of the code or the file compiled by the code on the test end in real time according to the coverage rate statistic task to be tested;
reporting a current latest code coverage rate statistical result to the second server every interval preset time;
uploading the code coverage rate statistical result to the second server when the execution of the coverage rate detection process is finished;
the information carried in the code coverage rate statistical result reported each time at least comprises the following information: the file identification of the modified code file, the task identification of the coverage rate statistic task to be tested, the version number of the code running on the testing end and the coverage range related to the code coverage rate statistics.
4. The method of claim 1, wherein performing code coverage statistics on the modified code or the compiled file of code according to the coverage statistics task to be tested, and uploading the code coverage statistics result to the second server further comprises:
determining that there is currently a modified portion of code that is not sent to the first server;
and reporting the file identifier of the modified code part and the file difference content to the second server, wherein the file difference content is obtained by comparing the modified code part with a corresponding file stored on the first server.
5. The method of claim 1, wherein after performing code coverage statistics on the modified code or the compiled file of the code according to the coverage statistics task to be tested and uploading the code coverage statistics result to the second server, the method further comprises:
accessing the second server, and inquiring the code coverage statistical result, wherein the code coverage statistical result corresponding to each test terminal on the second server is separated from each other, the code file associated with the code coverage statistical result is completely displayed, the background of a first part of codes associated with the code coverage statistical result is displayed as a first color, the background of a second part of codes not associated with the code coverage statistical result is displayed as a second color, the codes covered in the first part of codes are displayed as a third color, the codes uncovered in the first part of codes are displayed as a fourth color, the codes covered in the second part of codes are displayed as a fifth color, and the codes uncovered in the second part of codes are displayed as a sixth color.
6. A code coverage statistics method, characterized by:
receiving a code coverage rate statistical result uploaded by a testing end, wherein the code coverage rate statistical result is recorded by the testing end in the running process of a code file associated with a task distributed to the testing end from a second server, the second server is used for establishing and updating a coverage rate statistical task set associated with the modified code file, and the task distributed to the testing end by the second server is obtained from the coverage rate statistical task set;
adjusting the uploaded code coverage rate statistical result or the code coverage rate statistical result stored on the second server;
the second server is further used for extracting a task identifier from the notification message after the notification message sent by the first server is obtained, obtaining a test object file associated with the coverage rate statistical task to be tested from the first server according to the task identifier, obtaining tester information and task description information associated with the coverage rate statistical task to be tested from a third server, and establishing the coverage rate statistical task to be tested based on the test object file and the tester information.
7. The method of claim 6, wherein adjusting the uploaded code coverage statistics or the code coverage statistics stored on the second server comprises one of:
determining that a modified code part which is not sent to the first server exists currently, and adjusting the code coverage rate statistical result according to the position information of the modified code part;
adjusting the code coverage rate statistical result according to the synchronization result of the first version number of the code file on the test terminal and the second version number of the corresponding file on the second server;
and adjusting the code coverage rate statistical result according to a modified code file on a first server, wherein the first server is used for performing version management on the modified code file.
8. The method of claim 7, wherein adjusting the code coverage statistics based on synchronization of the first version number of the code file on the test side with the second version number of the corresponding file on the second server comprises at least one of:
when the first version number is the same as the second version number, adding the code coverage statistical result to a code coverage statistical result of the second server;
when the first version number is smaller than the second version number, acquiring file difference content between the second version number and the first version number, adjusting the code coverage rate statistical result according to the file difference content, and adding the adjusted code coverage rate statistical result to the code coverage rate statistical result of the second server;
when the first version number is larger than the second version number, acquiring first file difference content between the first version number and the initial version number, and adjusting code coverage content required by the code according to the first file difference content; and acquiring second file difference content between the first version number and the second version number, adjusting the code coverage rate statistical result on the second server according to the first file difference content and the second file difference content, adding a newly uploaded code coverage rate statistical result into the adjusted code coverage rate statistical result on the second server, and replacing the code file version on the second server with the first version number.
9. The method of claim 7, wherein adjusting the code coverage statistics based on the modified code file on the first server comprises:
setting the version number of the code file on the second server as a first version number and setting the version number of the code file updated on the first server as a second version number;
acquiring first file difference content between the second version number and the initial version number, and adjusting code content needing to be covered according to the first file difference content; and acquiring second file difference content between the second version number and the first version number, and adjusting the code coverage rate statistical result on the second server according to the second file difference content.
10. A code coverage statistics apparatus, comprising:
the system comprises a triggering module, a first server and a second server, wherein the triggering module is used for triggering the first server to send a notification message to the second server, the first server is used for carrying out version management on a modified code file, the second server is used for establishing and updating a coverage rate statistical task set associated with the modified code file, and the notification message is used for notifying the second server to determine the coverage rate statistical task set;
the acquisition module is used for acquiring a coverage rate statistical task to be tested from the coverage rate statistical task set;
the statistical module is used for carrying out code coverage rate statistics on the modified codes or the files after the codes are compiled according to the coverage rate statistical tasks to be tested and uploading the code coverage rate statistical results to the second server;
the second server is further configured to extract a task identifier from the notification message after the notification message is obtained, obtain a test object file associated with the coverage rate statistical task to be tested from the first server according to the task identifier, obtain tester information and task description information associated with the coverage rate statistical task to be tested from a third server, and establish the coverage rate statistical task to be tested based on the test object file and the tester information.
11. The apparatus of claim 10, wherein the obtaining module, configured to obtain the coverage statistics task to be tested from the set of coverage statistics tasks, comprises one of:
selecting the coverage rate statistic task corresponding to the task identifier from the coverage rate statistic task set according to the received task identifier;
setting part or all of the coverage rate statistic tasks in the coverage rate statistic task set as the coverage rate statistic tasks to be tested according to the test end identification;
wherein each coverage statistic task in the coverage statistic task set satisfies the following conditions: the code branch processed locally by the testing terminal is the same as the code branch processed by each coverage rate statistical task, the code version number processed locally by the testing terminal is greater than or equal to the initial version number of each coverage rate statistical task in the coverage rate statistical task set, all or part of the coverage rate statistical tasks are in a testing state, and the initial version number refers to the previous version number adjacent to the version number when each coverage rate statistical task is established on the branch to which each coverage rate statistical task belongs.
12. The apparatus of claim 10, wherein the statistics module comprises:
the monitoring unit is used for monitoring the detection process of the coverage rate of the code or the file after the code is compiled on the testing end in real time according to the coverage rate statistic task to be tested;
the first reporting unit is used for reporting the current latest code coverage rate statistical result to the second server every interval preset time length and uploading the code coverage rate statistical result to the second server when the execution of the coverage rate detection process is finished;
the information carried in the code coverage rate statistical result reported each time at least comprises the following information: the file identification of the modified code file, the task identification of the coverage rate statistic task to be tested, the version number of the code running on the testing end and the coverage range related to the code coverage rate statistics.
13. The apparatus of claim 10, wherein the statistics module further comprises:
a determining unit for determining that there is currently a modified code portion that is not sent to the first server;
a second reporting unit, configured to report the file identifier of the modified code portion and the file difference content to the second server, where the file difference content is obtained by comparing the modified code portion with a corresponding file stored in the first server.
14. The apparatus of claim 10, further comprising:
the query module is used for accessing the second server and querying the code coverage statistical result, wherein the code coverage statistical results corresponding to each test terminal on the second server are separated from each other, the code file associated with the code coverage statistical result is completely displayed, the background of a first part of codes associated with the code coverage statistical result is displayed as a first color, the background of a second part of codes not associated with the code coverage statistical result is displayed as a second color, the codes covered in the first part of codes are displayed as a third color, the codes uncovered in the first part of codes are displayed as a fourth color, the codes covered in the second part of codes are displayed as a fifth color, and the codes uncovered in the second part of codes are displayed as a sixth color.
15. A code coverage statistics apparatus, characterized by:
the system comprises a receiving module, a processing module and a processing module, wherein the receiving module is used for receiving a code coverage rate statistical result uploaded by a testing end, the code coverage rate statistical result is recorded by the testing end in the running process of a code file associated with a task distributed to the testing end from a second server, the second server is used for establishing and updating a coverage rate statistical task set associated with a modified code file, and the second server is used for obtaining the task distributed to the testing end from the coverage rate statistical task set;
the adjusting module is used for adjusting the uploaded code coverage rate statistical result or the code coverage rate statistical result stored in the second server;
the second server is further used for extracting a task identifier from the notification message after the notification message sent by the first server is obtained, obtaining a test object file associated with the coverage rate statistical task to be tested from the first server according to the task identifier, obtaining tester information and task description information associated with the coverage rate statistical task to be tested from a third server, and establishing the coverage rate statistical task to be tested based on the test object file and the tester information.
16. The apparatus of claim 15, wherein the adjustment module configured to adjust the uploaded code coverage statistics or the code coverage statistics stored on the second server comprises one of:
determining that a modified code part which is not sent to the first server exists currently, and adjusting the code coverage rate statistical result according to the position information of the modified code part;
adjusting the code coverage rate statistical result according to the synchronization result of the first version number of the code file on the test terminal and the second version number of the corresponding file on the second server;
and adjusting the code coverage rate statistical result according to a modified code file on a first server, wherein the first server is used for performing version management on the modified code file.
17. The apparatus of claim 16, wherein the adjusting module, configured to adjust the code coverage statistics according to a synchronization result between a first version number of a code file on the testing side and a second version number of a corresponding file on the second server, comprises at least one of:
when the first version number is the same as the second version number, adding the code coverage statistical result to a code coverage statistical result of the second server;
when the first version number is smaller than the second version number, acquiring file difference content between the second version number and the first version number, adjusting the code coverage rate statistical result according to the file difference content, and adding the adjusted code coverage rate statistical result to the code coverage rate statistical result of the second server;
when the first version number is larger than the second version number, acquiring first file difference content between the first version number and the initial version number, and adjusting code coverage content required by the code according to the first file difference content; and acquiring second file difference content between the first version number and the second version number, adjusting the code coverage rate statistical result on the second server according to the first file difference content and the second file difference content, adding a newly uploaded code coverage rate statistical result into the adjusted code coverage rate statistical result on the second server, and replacing the code file version on the second server with the first version number.
18. The apparatus of claim 16, wherein the adjusting module for adjusting the code coverage statistics based on the modified code file on the first server comprises the following steps:
setting the version number of the code file on the second server as a first version number and setting the version number of the code file updated on the first server as a second version number;
acquiring first file difference content between the second version number and the initial version number, and adjusting code content needing to be covered according to the first file difference content; and acquiring second file difference content between the second version number and the first version number, and adjusting the code coverage rate statistical result on the second server according to the second file difference content.
19. A storage medium, characterized in that the storage medium comprises a stored program, wherein when the program runs, a device in which the storage medium is located is controlled to execute the code coverage statistical method of any one of claims 1 to 5 or claims 6 to 9.
20. A processor, configured to run a program, wherein the program is configured to perform the code coverage statistical method of any one of claims 1 to 5 or 6 to 9 when the program is run.
CN201710710668.9A 2017-08-18 2017-08-18 Code coverage rate statistical method, device, storage medium, processor and terminal Active CN107480066B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710710668.9A CN107480066B (en) 2017-08-18 2017-08-18 Code coverage rate statistical method, device, storage medium, processor and terminal

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710710668.9A CN107480066B (en) 2017-08-18 2017-08-18 Code coverage rate statistical method, device, storage medium, processor and terminal

Publications (2)

Publication Number Publication Date
CN107480066A CN107480066A (en) 2017-12-15
CN107480066B true CN107480066B (en) 2020-10-30

Family

ID=60601855

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710710668.9A Active CN107480066B (en) 2017-08-18 2017-08-18 Code coverage rate statistical method, device, storage medium, processor and terminal

Country Status (1)

Country Link
CN (1) CN107480066B (en)

Families Citing this family (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107967216B (en) * 2017-12-18 2020-07-10 网易(杭州)网络有限公司 Code detection method and device, equipment and computer readable storage medium
CN108170610A (en) * 2018-01-17 2018-06-15 北京网信云服信息科技有限公司 The method and apparatus for determining test coverage
CN108519945A (en) * 2018-03-21 2018-09-11 腾讯科技(深圳)有限公司 Coverage rate test method, apparatus and storage device
CN110209568B (en) * 2018-04-24 2022-07-01 腾讯科技(深圳)有限公司 Coverage rate test method and device and storage equipment
CN110399287B (en) * 2018-04-24 2024-03-01 阿里巴巴集团控股有限公司 Coverage rate collection method and coverage rate collection device for application test
CN109062152B (en) * 2018-07-26 2021-04-13 中核控制系统工程有限公司 Local variable online monitoring method based on logic configuration generation
CN109117368A (en) * 2018-07-27 2019-01-01 平安科技(深圳)有限公司 A kind of interface test method, electronic equipment and storage medium
CN109460357B (en) * 2018-10-19 2021-10-29 北京新能源汽车股份有限公司 Method, device and equipment for testing code coverage rate
CN109766261A (en) * 2018-12-14 2019-05-17 中国平安财产保险股份有限公司 Coverage test method, device, computer equipment and storage medium
CN109684226A (en) * 2018-12-29 2019-04-26 携程计算机技术(上海)有限公司 Java code coverage rate statistical system
CN110633208A (en) * 2019-08-22 2019-12-31 浙江大搜车软件技术有限公司 Incremental code coverage rate testing method and system
CN110990265B (en) * 2019-11-12 2023-10-03 苏州洞察云信息技术有限公司 Coverage rate determining method, coverage rate determining device and storage medium
CN110968507B (en) * 2019-11-20 2023-07-25 北京创鑫旅程网络技术有限公司 Coverage rate statistics method and coverage rate statistics device
CN111897737B (en) * 2020-08-21 2024-03-26 中国工商银行股份有限公司 Missing detection method and device for program test of micro-service system
CN112597041B (en) * 2020-12-28 2023-01-20 上海品顺信息科技有限公司 Cross-branch merging method, system, equipment and storage medium for code coverage rate
CN113190448B (en) * 2021-05-06 2022-11-04 网易(杭州)网络有限公司 Test code updating method and device, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103077109A (en) * 2009-12-28 2013-05-01 中兴通讯股份有限公司 Method and system for scheduling test plan
CN105302716A (en) * 2014-07-30 2016-02-03 腾讯科技(深圳)有限公司 Method and apparatus for test in joint development mode
CN105608011A (en) * 2016-03-01 2016-05-25 网易(杭州)网络有限公司 Determination method and device for code testing coverage rate statistical results
CN106155900A (en) * 2015-04-17 2016-11-23 腾讯科技(深圳)有限公司 A kind of code tester monitoring method, device and equipment

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9405662B2 (en) * 2013-12-18 2016-08-02 Google Inc. Process for displaying test coverage data during code reviews

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103077109A (en) * 2009-12-28 2013-05-01 中兴通讯股份有限公司 Method and system for scheduling test plan
CN105302716A (en) * 2014-07-30 2016-02-03 腾讯科技(深圳)有限公司 Method and apparatus for test in joint development mode
CN106155900A (en) * 2015-04-17 2016-11-23 腾讯科技(深圳)有限公司 A kind of code tester monitoring method, device and equipment
CN105608011A (en) * 2016-03-01 2016-05-25 网易(杭州)网络有限公司 Determination method and device for code testing coverage rate statistical results

Also Published As

Publication number Publication date
CN107480066A (en) 2017-12-15

Similar Documents

Publication Publication Date Title
CN107480066B (en) Code coverage rate statistical method, device, storage medium, processor and terminal
CN107391379B (en) Automatic interface testing method and device
CN105404581B (en) A kind of evaluating method and device of database
CN109165170B (en) Method and system for automatic request test
CN110543420B (en) Software testing method, system, terminal and storage medium
CN107807877A (en) A kind of method and apparatus of code performance test
EP2902908A1 (en) System operation trace method in distributed system
CN109669798B (en) Crash analysis method, crash analysis device, electronic equipment and storage medium
CN112016708A (en) Multi-dimensional data display method and device for intelligent cable
CN105577472A (en) Data acquisition test method and device
CN109067605B (en) Storage subsystem fault diagnosis method and device, terminal and storage medium
CN106557419B (en) Program testing method and device
CN109101394B (en) Data processing method and device
CN105391602B (en) A kind of data acquisition test method and apparatus
CN114595089A (en) Hard disk remote diagnosis method, system, terminal and storage medium
CN115757107A (en) Embedded point detection method, device, server and storage medium
CN115185778A (en) Database monitoring method and device
CN112131090B (en) Service system performance monitoring method, device, equipment and medium
CN109688025B (en) Test monitoring method, device, terminal and storage medium based on digital KVM
CN111143138A (en) PCIe Bus fault positioning method, system, terminal and storage medium
CN112816933A (en) Maintenance diagnosis method and system for electric energy meter terminal
CN111538666A (en) Method and device for collecting test results in batches, computer equipment and storage medium
CN112416896A (en) Data abnormity warning method and device, storage medium and electronic device
CN113489708B (en) Detection method and device, electronic equipment and computer readable storage medium
CN103678375A (en) Test state presentation and anomaly indexing system and method

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