CN115934524A - Method and device for generating code coverage rate report, test equipment and storage medium - Google Patents

Method and device for generating code coverage rate report, test equipment and storage medium Download PDF

Info

Publication number
CN115934524A
CN115934524A CN202211520287.1A CN202211520287A CN115934524A CN 115934524 A CN115934524 A CN 115934524A CN 202211520287 A CN202211520287 A CN 202211520287A CN 115934524 A CN115934524 A CN 115934524A
Authority
CN
China
Prior art keywords
code coverage
code
report
test
condition
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211520287.1A
Other languages
Chinese (zh)
Inventor
杨俊�
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Qingdao Haier Technology Co Ltd
Haier Smart Home Co Ltd
Haier Uplus Intelligent Technology Beijing Co Ltd
Original Assignee
Qingdao Haier Technology Co Ltd
Haier Smart Home Co Ltd
Haier Uplus Intelligent Technology Beijing 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 Qingdao Haier Technology Co Ltd, Haier Smart Home Co Ltd, Haier Uplus Intelligent Technology Beijing Co Ltd filed Critical Qingdao Haier Technology Co Ltd
Priority to CN202211520287.1A priority Critical patent/CN115934524A/en
Publication of CN115934524A publication Critical patent/CN115934524A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The application relates to the technical field of software development and discloses a method for generating a code coverage report, which comprises the following steps: in the process of testing codes, obtaining a code coverage rate report request of a user; feeding back the code coverage report under the condition that the code coverage report is effective; and generating a code coverage report and feeding back the code coverage report in the case that the code coverage report is invalid. The user can check the code coverage rate report in real time according to needs in the test process, and does not need to wait for the code coverage rate report to be checked after the whole test is finished. Therefore, whether the test is sufficient or not can be judged in time, the weak points of the test can be found in time, test cases are added, and the like. The method can check the code coverage rate report in real time in the test process, and improves the test flexibility. The application also discloses a device for generating the code coverage rate report, test equipment and a storage medium.

Description

Method and device for generating code coverage rate report, test equipment and storage medium
Technical Field
The present application relates to the field of software development technologies, and for example, to a method and an apparatus for generating a code coverage report, a test device, and a storage medium.
Background
Code Coverage (Code Coverage) is an important index reflecting the Coverage degree of a test case to a tested program, and is also a reference value for measuring the test integrity. Whether it is a unit test, an API (application Program Interface) test, or a functionality test, the code that calls the Program is the end. After the test is finished, whether the test is sufficient or not and what aspects the weak points of the test are can be known through the code coverage rate data, and then a developer or an auxiliary tester can be guided to increase the test case of the coverage rate.
The related art discloses a code coverage report generation method, which comprises the following steps: acquiring a project source code, and locally constructing and compiling the project source code to obtain a compiled class file; reading a resource file required by the class s file, and packaging and deploying the class file and the resource file to an application server; sh script is executed, and code coverage rate data is collected from an application server; and generating a readable code coverage report according to the code coverage data, the project source code and the class file in a combined mode.
In the process of implementing the embodiments of the present disclosure, it is found that at least the following problems exist in the related art:
although the technology can realize automatic generation of the code coverage rate report, the method needs to generate the final code coverage rate report after all the test cases are executed, so that a user can analyze the code and the test cases according to the final code coverage rate report, and cannot check the execution condition of the code in real time. Therefore, the related art cannot check the code coverage report in real time in the test process, and the test flexibility is low.
It is to be noted that the information disclosed in the above background section is only for enhancement of understanding of the background of the present application and therefore may include information that does not constitute prior art known to a person of ordinary skill in the art.
Disclosure of Invention
The following presents a simplified summary in order to provide a basic understanding of some aspects of the disclosed embodiments. This summary is not an extensive overview nor is intended to identify key/critical elements or to delineate the scope of such embodiments but rather as a prelude to the more detailed description that is presented later.
The embodiment of the disclosure provides a method and a device for generating a code coverage report, a test device and a storage medium, which can check the code coverage report in real time in the test process and improve the test flexibility.
In some embodiments, a method for generating a code coverage report is applied to a test device, the method comprising: in the process of testing codes, obtaining a code coverage rate report request of a user; feeding back the code coverage report under the condition that the code coverage report is effective; and generating a code coverage report and feeding back the code coverage report in the case that the code coverage report is invalid.
Optionally, the case where the code coverage report is valid includes: there is a code coverage report and the code coverage report is not marked as expired.
Optionally, the case of invalid code coverage report includes: no code coverage report exists or the code coverage report is marked as expired.
Optionally, generating a code coverage report comprises: sending a request for acquiring code execution conditions to all servers; receiving code execution conditions sent by all servers; and generating a code coverage rate report according to the code execution conditions sent by all the servers.
Optionally, generating a code coverage report according to the code execution conditions sent by all servers includes: merging the code execution conditions sent by all servers to obtain a code execution result; generating a full code coverage rate report according to the code execution result and the source code of the test version; generating an incremental code coverage rate report according to the code execution result, the test version source code and the last version source code; the full amount of code coverage reports and the incremental code coverage reports are merged to generate code coverage reports.
Optionally, in a case that a code coverage reporting request of the user is not obtained, the method further includes: receiving the code execution condition sent by the server; wherein the code execution condition is intercepted by the intercepting tool at the server and sent from the corresponding server if a first condition is met; under the condition that a second condition is met, sending a request for acquiring the code execution condition to the rest servers; receiving code execution conditions sent by the rest servers; generating a code coverage rate report according to the code execution conditions sent by all the servers, and acquiring an updated code coverage rate report; in the event that the second condition is not satisfied, the existing code coverage report is treated as an updated code coverage report.
Optionally, the first condition comprises: the data volume of the newly added and stored code execution condition is greater than or equal to the preset data volume; or the time length from the sending time of the last code execution condition is greater than or equal to a first preset time length.
Optionally, the second condition comprises: there is no code coverage report; or, there is a report of code coverage rate and the execution condition of the received code at this time is different from the execution condition of the code received at the last time; or, the code coverage rate report exists, and the time difference between the receiving time of the code execution situation of this time and the last time of generating the code coverage rate report is greater than or equal to a second preset time length.
Optionally, after receiving the execution condition of the code sent by the server, the method further includes: in the case of a code coverage report, the existing code coverage report is marked as expired.
Optionally, the code coverage report includes analysis results of one or more of line coverage, class coverage, branch coverage, method coverage, instruction level coverage, circle complexity, and statement block coverage.
In some embodiments, an apparatus for generating a code coverage report includes a processor and a memory storing program instructions, the processor being configured to, upon execution of the program instructions, perform the method for generating a code coverage report described above.
In some embodiments, a test apparatus includes a test apparatus body; and the device for generating the code coverage report is arranged on the test equipment body.
In some embodiments, a storage medium stores program instructions that, when executed, perform the above-described method for generating a code coverage report.
The method and the device for generating the code coverage rate report, the test equipment and the storage medium provided by the embodiment of the disclosure can realize the following technical effects:
in the process of testing the codes, under the condition of obtaining a code coverage report request of a user, if the code coverage report is judged to be effective, the code coverage report is fed back immediately. And if the code coverage rate report is judged to be invalid, generating the code coverage rate report and feeding back the code coverage rate report. Therefore, the user can check the code coverage rate report in real time according to needs in the test process, and does not need to wait for the code coverage rate report to be checked after the whole test is finished. Therefore, whether the test is sufficient or not can be judged in time, the weak points of the test can be found in time, test cases are added, and the like. Compared with the related art, the code coverage rate report can be checked in real time in the test process, and the test flexibility is improved.
The foregoing general description and the following description are exemplary and explanatory only and are not restrictive of the application.
Drawings
One or more embodiments are illustrated by way of example in the accompanying drawings, which correspond to the accompanying drawings and not in limitation thereof, in which elements having the same reference numeral designations are shown as like elements and not in limitation thereof, and wherein:
FIG. 1 is a schematic diagram of an application scenario provided by an embodiment of the present disclosure;
fig. 2 is a schematic diagram of another application scenario provided by an embodiment of the present disclosure;
FIG. 3 is a schematic diagram of a method for generating a code coverage report provided by an embodiment of the present disclosure;
FIG. 4 is a schematic diagram of another method for generating a code coverage report provided by an embodiment of the present disclosure;
FIG. 5 is a schematic diagram of another method for generating a code coverage report provided by an embodiment of the present disclosure;
FIG. 6 is a schematic diagram of another method for generating a code coverage report provided by an embodiment of the present disclosure;
FIG. 7 is a schematic diagram of another method for generating a code coverage report provided by an embodiment of the present disclosure;
FIG. 8 is a schematic diagram of another method for generating a code coverage report provided by an embodiment of the present disclosure;
FIG. 9 is a schematic diagram of an apparatus for generating a code coverage report according to an embodiment of the present disclosure;
FIG. 10 is a schematic diagram of a test apparatus provided by an embodiment of the present disclosure.
Detailed Description
So that the manner in which the features and elements of the disclosed embodiments can be understood in detail, a more particular description of the disclosed embodiments, briefly summarized above, may be had by reference to the embodiments, some of which are illustrated in the appended drawings. In the following description of the technology, for purposes of explanation, numerous details are set forth in order to provide a thorough understanding of the disclosed embodiments. However, one or more embodiments may be practiced without these details. In other instances, well-known structures and devices may be shown in simplified form in order to simplify the drawing.
The terms "first," "second," and the like in the description and in the claims, and the above-described drawings of embodiments of the present disclosure, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It should be understood that the data so used may be interchanged under appropriate circumstances such that embodiments of the present disclosure described herein may be made. Furthermore, the terms "include" and "have," as well as any variations thereof, are intended to cover a non-exclusive inclusion.
In the embodiments of the present disclosure, the terms "upper", "lower", "inner", "middle", "outer", "front", "rear", and the like indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings. These terms are used primarily to better describe the disclosed embodiments and their examples and are not intended to limit the indicated devices, elements or components to a particular orientation or to be constructed and operated in a particular orientation. Moreover, some of the above terms may be used in other meanings besides orientation or positional relationship, for example, the term "upper" may also be used in some cases to indicate a certain attaching or connecting relationship. The specific meanings of these terms in the embodiments of the present disclosure can be understood by those of ordinary skill in the art as appropriate.
The term "plurality" means two or more unless otherwise specified.
In the embodiment of the present disclosure, the character "/" indicates that the preceding and following objects are in an or relationship. For example, A/B represents: a or B.
The term "and/or" is an associative relationship that describes objects, meaning that three relationships may exist. For example, a and/or B, represents: a or B, or A and B.
The term "correspond" may refer to an association or binding relationship, and a corresponds to B refers to an association or binding relationship between a and B.
In addition, the term "set" should be interpreted broadly.
It should be noted that, in the case of no conflict, the embodiments and features in the embodiments of the present disclosure may be combined with each other.
FIG. 1 is a schematic diagram of one application scenario of an embodiment of the present disclosure. As shown in fig. 1, the application scenario includes a test tool 101, a test device 102, and a server 103.
The test tool 101 may be a code test tool device developed according to its own requirements, or may be an electronic device that installs or uses a test tool such as a JMeter (stress test tool), a Postman (application programming interface debug tool), or the like online. The testing tool 101 may also be a physical device related to code testing, such as a physical device like a mobile phone, a personal computer, a smart home device, etc. The test tool 101 is used to test the test application code. The testing device 102 may be, but is not limited to, a personal computer, a mobile phone, a tablet computer, etc., and related services such as recording, code coverage processing, code compiling, etc. need to be deployed in the testing device 102. Of course, the test equipment 102 may also configure a separate server, and deploy the relevant service in the server. The test equipment 102 is used to record code, code versions, generate deployment packages, collect code coverage data, generate code coverage reports, and the like. The server 103 is an application server required for the test code, and is used for deploying the test application code, executing the code according to the test, and the like, and the number of the servers 103 may be plural as necessary. The test tool 101, the test device 102, and the server 103 are communicatively connected via a network, which may be a wireless network or a wired network.
Fig. 2 is a schematic diagram of another application scenario of an embodiment of the present disclosure. As shown in fig. 2, the application scenario includes a test device 102 and a server 103.
The testing device 102 may be, but is not limited to, a personal computer, a mobile phone, a tablet computer, etc., and related services such as record deployment, code coverage processing, code compiling, etc. are required to be deployed in the testing device 102. Meanwhile, a testing tool such as JMeter, postman, etc. is also installed or used in the testing device 102 in an online manner for testing the testing application code. Of course, the test equipment 102 may also configure a separate server, and deploy the relevant service in the server. The test equipment 102 is also used to record code, code versions, generate deployment packages, collect code coverage data, generate code coverage reports, and the like. The server 103 is an application server required for the test code, and is used for deploying the test application code, executing the code according to the test, and the like, and the number of the servers 103 may be plural as necessary. The communication connection between the test device 102 and the server 103 is a network, which may be a wireless network or a wired network.
In combination with the application scenario, the embodiment of the present disclosure provides a method for generating a code coverage report, which is applied to a test device. As shown in fig. 3, the method includes:
s301, in the process of testing codes, the testing equipment obtains a code coverage rate report request of a user.
And S302, under the condition that the code coverage rate report is effective, the test equipment feeds back the code coverage rate report.
And S303, under the condition that the code coverage rate report is invalid, generating the code coverage rate report by the test equipment, and feeding back the code coverage rate report.
In the disclosed embodiment, during the process of testing code, a user may issue a request to obtain a code coverage report from a test tool or test equipment. Under the condition that the test equipment obtains a code coverage report request of a user, if the code coverage report is judged to be effective, the code coverage report is fed back to a test tool or a test equipment interface immediately for display. And if the code coverage rate report is judged to be invalid, generating a code coverage rate report, and feeding back the code coverage rate report to a test tool or a test equipment interface for display. Therefore, the user can check the code coverage rate report in real time according to needs in the test process, and does not need to wait for the code coverage rate report to be checked after the whole test is finished. Therefore, whether the test is sufficient or not can be judged in time, the weak points of the test can be found in time, test cases are added, and the like. Compared with the related art, the code coverage rate report can be checked in real time in the test process, and the test flexibility is improved.
Optionally, the case where the code coverage report is valid includes: there is a code coverage report and the code coverage report is not marked as expired. In this way, the fed back code coverage report is the latest valid code coverage report, and the latest validity of the code coverage report seen by the user can be ensured. Therefore, the result of the judgment of the code coverage rate report by the user is more accurate.
Optionally, the case of invalid code coverage report includes: no code coverage report exists or the code coverage report is marked as expired. For example, an existing code coverage report is marked as expired before the code coverage report needs to be updated; or, the existing code coverage report is not updated within a preset time period, and the existing code coverage report is marked as expired. In this way, expired code coverage reports are not fed back, and the latest validity of the code coverage reports seen by the user can be guaranteed. Therefore, the result of the judgment of the code coverage rate report by the user is more accurate.
Optionally, the test device generates a code coverage report, including: the test equipment sends a request for acquiring the code execution condition to all the servers; the test equipment receives the code execution conditions sent by all the servers; and the test equipment generates a code coverage rate report according to the code execution conditions sent by all the servers. The application code to be tested is deployed in a plurality of servers, and in the case that a code coverage report needs to be generated, the code execution conditions in the plurality of servers need to be acquired. JaCoCo (Java-oriented open source code coverage tool) deployed in the test equipment can analyze and process the code execution conditions in a plurality of servers and generate a code coverage report. Therefore, the execution condition of the code can be obtained in real time, the code coverage rate report can be generated, and the user can see the latest and effective code coverage rate report. Therefore, the result of the judgment of the code coverage rate report by the user is more accurate.
In conjunction with fig. 4, another method for generating a code coverage report is provided in an embodiment of the present disclosure, which includes:
s401, in the process of testing the code, the testing equipment obtains a code coverage rate report request of a user.
S402, the test equipment judges whether the code coverage rate report is effective. If yes, go to step S403; otherwise, steps S404 to S407 are performed.
And S403, feeding back a code coverage report by the test equipment.
S404, the test equipment sends a request for acquiring the code execution condition to all the servers.
S405, the test equipment receives all code execution conditions sent by the server.
S406, the test equipment generates a code coverage rate report according to the code execution conditions sent by all the servers.
And S407, feeding back a code coverage report by the test equipment.
According to the code coverage rate report request of the user, the execution condition of the code can be obtained in real time, the code coverage rate report can be generated, and the user can see the latest and effective code coverage rate report. Therefore, the result of the judgment of the code coverage rate report by the user is more accurate.
Optionally, the generating, by the test device, a code coverage report according to the code execution conditions sent by all the servers includes: the test equipment combines the code execution conditions sent by all the servers to obtain a code execution result; the test equipment generates a full code coverage rate report according to the code execution result and the test version source code; the test equipment generates an incremental code coverage rate report according to the code execution result, the test version source code and the previous version source code; the test equipment combines the full amount of code coverage reports and the incremental code coverage reports to generate code coverage reports. The JaCoCo deployed in the test equipment can combine the execution conditions of the codes sent by all the servers and generate a code coverage rate report by combining the test version source code and the previous version source code. Therefore, the user can analyze the full code coverage rate report and the incremental code coverage rate report of the test version in detail, and the user can find the code to be tested in time conveniently. Therefore, the test case can be adjusted in time, and the test missing is avoided.
Optionally, in a case where a code coverage report request of the user is not obtained, the method further includes: the test equipment receives the code execution condition sent by the server; wherein the code execution condition is intercepted by the intercepting tool at the server and sent from the corresponding server if a first condition is met; under the condition that a second condition is met, the test equipment sends a request for obtaining the code execution condition to the rest servers; the test equipment receives the code execution condition sent by the rest servers; the test equipment generates a code coverage rate report according to the code execution conditions sent by all the servers, and obtains an updated code coverage rate report; in the event that the second condition is not satisfied, the test equipment reports the existing code coverage as an updated code coverage report. The interception tool can adopt Java (computer programming language) Agent (Agent) technology, and the Java Agent can record the code execution condition. And carrying out secondary development on the Java agents, setting a trigger condition for feeding back the code execution condition, and sending the code execution condition from the corresponding server under the condition of meeting a certain condition. The code execution condition sent by each server is the total code execution condition recorded from the test start to the current time node. In the process of testing the codes, the interception tool is always in an interception state at each server, and under the condition that the first condition is met each time, the interception tool can send the code execution condition to the test equipment from the corresponding server meeting the condition once. The test equipment can update the code coverage report by judging whether the second condition is met after receiving the code execution condition. In this way, latency may be reduced in the event that a user needs to view a code coverage report during testing. Thus, the feedback speed of the user for viewing the latest code coverage report is improved.
As shown in fig. 5, another method for generating a code coverage report is provided in an embodiment of the present disclosure, including:
s501, when the code coverage report request of the user is not obtained, the test equipment receives the code execution condition sent by the server. Wherein the code execution condition is intercepted by the interception tool at the server and is sent from the corresponding server if a first condition is met.
S502, the test equipment judges whether a second condition is met. If yes, executing steps S503 to S505; otherwise, step S506 is executed.
S503, the test equipment sends a request for obtaining the code execution condition to the rest servers.
S504, the test equipment receives the code execution condition sent by the rest servers.
And S505, the test equipment generates a code coverage rate report according to the code execution conditions sent by all the servers, and obtains an updated code coverage rate report.
S506, the test equipment takes the existing code coverage report as an updated code coverage report.
In the embodiment of the disclosure, after receiving the code execution condition, the test device may update the code coverage report by determining whether the second condition is satisfied. In this way, latency may be reduced in the event that a user needs to view a code coverage report during testing. Thus, the feedback speed of the user for viewing the latest code coverage report is improved.
Optionally, the first condition comprises: the data volume of the newly added and stored code execution condition is greater than or equal to the preset data volume; or the time length from the sending time of the last code execution condition is greater than or equal to the first preset time length. Therefore, when the data volume of the newly-added and stored code execution condition is larger than the preset data volume, a certain amount of codes are executed, and the latest code execution condition can be fed back timely to update the code coverage rate report. And under the condition that the time length from the sending time of the last code execution condition is greater than or equal to a first preset time length, the code execution condition is not fed back for a long time, a certain amount of codes are executed in the period, and the latest code execution condition can be fed back timely to update the code coverage rate report. Therefore, the code coverage rate report can be ensured to be updated in time, and the feedback speed of a user for checking the latest code coverage rate report is improved.
Optionally, the second condition comprises: there is no code coverage report; or, there is a report of code coverage rate and the execution condition of the received code at this time is different from the execution condition of the code received at the last time; or, the code coverage rate report exists, and the time difference between the receiving time of the code execution situation of this time and the time of the last generation of the code coverage rate report is greater than or equal to a second preset time length. In this way, when there is a code coverage report and the execution condition of the currently received code is different from the execution condition of the last received code, it is described that a new code is executed and the code coverage report needs to be updated. And under the condition that the code coverage rate report exists and the time difference between the receiving time of the code execution situation of the time and the time of the last generation of the code coverage rate report is greater than or equal to a second preset time length, the code coverage rate report is not updated for a longer time, and the code coverage rate report needs to be updated. Therefore, the code coverage rate report can be ensured to be updated in time, and the feedback speed of a user for checking the latest code coverage rate report is improved.
Optionally, after the test device receives the code execution condition sent by the server, the method further includes: in the event that there is a code coverage report, the test equipment marks the existing code coverage report as expired. After receiving the code execution condition sent by the server, the code coverage report needs to be updated to indicate that the code in the server has a new test execution. Marking existing code coverage reports as expired may ensure that the code coverage reports obtained by the user are the most up-to-date code coverage reports. Thus, the timeliness of the code coverage reports acquired by the user is improved.
In conjunction with fig. 6, another method for generating a code coverage report is provided in an embodiment of the present disclosure, including:
s601, under the condition that a code coverage rate report request of a user is not obtained, the test equipment receives the code execution condition sent by the server. Wherein the code execution condition is intercepted by the interception tool at the server and sent from the corresponding server if the first condition is satisfied.
S602, in case there is a code coverage report, the test device marks the existing code coverage report as expired.
S603, the test equipment judges whether a second condition is met. If yes, go to step S604 to S606; otherwise, step S607 is executed.
S604, the test equipment sends a request for obtaining the code execution condition to the rest servers.
And S605, the test equipment receives the code execution condition sent by the rest servers.
And S606, generating a code coverage rate report by the test equipment according to the code execution conditions sent by all the servers, and obtaining an updated code coverage rate report.
S607, the test equipment takes the existing code coverage report as an updated code coverage report.
In the embodiment of the disclosure, after receiving the code execution condition sent by the server, it is described that the code in the server has a new test execution and the code coverage report needs to be updated. Marking an existing code coverage report as expired may ensure that the code coverage report acquired by the user is the most up-to-date code coverage report. Thus, the effectiveness of user code coverage report acquisition is improved.
Optionally, the code coverage report includes analysis results of one or more of line coverage, class coverage, branch coverage, method coverage, instruction level coverage, circle complexity, and statement block coverage. Therefore, the user can select different report display contents according to different test requirements to analyze the code coverage rate. Therefore, the user can accurately analyze and judge the test condition of the code.
Another method for generating a code coverage report during actual testing of code is shown in fig. 7, which includes:
s701, the user sends a request for obtaining a code coverage report to the test equipment from the test tool.
S702, the test equipment judges whether the code coverage rate report is effective. If yes, go to step S703; otherwise, steps S704 to S710 are performed. Wherein a code coverage report is considered valid if there is a code coverage report and the code coverage report is not marked as expired. If no code coverage report exists or the code coverage report is marked as expired, the code coverage report is considered invalid.
S703, the test equipment sends a code coverage report to the test tool.
S704, the test equipment sends a request for obtaining the code execution condition to the server.
S705, the server sends the code execution condition to the test equipment.
S706, the test equipment combines the code execution conditions sent by all the servers to obtain a code execution result.
And S707, the test equipment generates a full code coverage report according to the code execution result and the test version source code.
And S708, the test equipment generates an incremental code coverage report according to the code execution result, the test version source code and the last version source code.
And S709, combining the full code coverage report and the incremental code coverage report by the test equipment to generate a code coverage report.
S710, the test equipment sends a code coverage report to the test tool.
In the process of actually testing codes, another method for generating a code coverage report is shown in fig. 8, which includes:
s801, the server sends the code execution condition to the test equipment under the condition that the first condition is met. Wherein the first condition comprises: the data volume of the newly-added and stored code execution condition is larger than or equal to the preset data volume; or the time length from the sending time of the last code execution condition is greater than or equal to the first preset time length.
S802, in case there is a code coverage report, the test equipment marks the existing code coverage report as expired.
S803, the test equipment judges whether a second condition is met. If yes, go to step S804 to step S806; otherwise, step S807 is executed. Wherein the second condition comprises: there is no code coverage report; or, there is a report of code coverage rate and the execution condition of the received code at this time is different from the execution condition of the code received at the last time; or, the code coverage rate report exists, and the time difference between the receiving time of the code execution situation of this time and the time of the last generation of the code coverage rate report is greater than or equal to a second preset time length.
S804, the test equipment sends a request for obtaining the code execution condition to the rest servers.
S805, the remaining servers send the code execution status to the test device.
And S806, the test equipment generates a code coverage report according to the code execution conditions sent by all the servers, and obtains an updated code coverage report.
S807, the test equipment takes the existing code coverage report as an updated code coverage report.
As shown in fig. 9, another apparatus 300 for generating a code coverage report according to an embodiment of the present disclosure includes a processor (processor) 100 and a memory (memory) 101 storing program instructions. Optionally, the apparatus may also include a Communication Interface (Communication Interface) 102 and a bus 103. The processor 100, the communication interface 102, and the memory 101 may communicate with each other via a bus 103. The communication interface 102 may be used for information transfer. The processor 100 may call logic instructions in the memory 101 to perform the method for generating a code coverage report of the above-described embodiment.
In addition, the logic instructions in the memory 101 may be implemented in the form of software functional units and stored in a computer readable storage medium when the logic instructions are sold or used as independent products.
The memory 101 is a storage medium and can be used for storing software programs, computer executable programs, such as program instructions/modules corresponding to the methods in the embodiments of the present disclosure. The processor 100 executes functional applications and data processing, i.e. implements the method for generating a code coverage report in the above embodiments, by executing program instructions/modules stored in the memory 101.
The memory 101 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal device, and the like. In addition, the memory 101 may include a high-speed random access memory, and may also include a nonvolatile memory.
As shown in fig. 10, an embodiment of the present disclosure provides a test apparatus, including: a test equipment body, and the apparatus 300 for generating a code coverage report described above. The apparatus 300 for generating a code coverage report is installed at a test equipment body. The installation relationship stated herein is not limited to being placed inside the product, but also includes installation connection with other components of the product, including but not limited to physical connection, electrical connection, or signal transmission connection. Those skilled in the art will appreciate that the apparatus 300 for generating code coverage reports may be adapted to a feasible product body, thereby enabling other feasible embodiments.
Embodiments of the present disclosure provide a computer-readable storage medium storing computer-executable instructions configured to perform the above-described method for generating a code coverage report.
The computer-readable storage medium described above may be a transitory computer-readable storage medium or a non-transitory computer-readable storage medium.
The technical solution of the embodiments of the present disclosure may be embodied in the form of a software product, which is stored in a storage medium and includes one or more instructions for enabling 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 of the embodiments of the present disclosure. And the aforementioned storage medium may be a non-transitory storage medium comprising: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes, and may also be a transient storage medium.
The above description and drawings sufficiently illustrate embodiments of the disclosure to enable those skilled in the art to practice them. Other embodiments may incorporate structural, logical, electrical, process, and other changes. The examples merely typify possible variations. Individual components and functions are optional unless explicitly required, and the sequence of operations may vary. Portions and features of some embodiments may be included in or substituted for those of others. Furthermore, the words used in the specification are words of description only and are not intended to limit the claims. As used in the description of the embodiments and the claims, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. Similarly, the term "and/or" as used in this application is meant to encompass any and all possible combinations of one or more of the associated listed. Furthermore, the terms "comprises" and/or "comprising," when used in this application, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof. Without further limitation, an element defined by the phrase "comprising one" does not exclude the presence of other like elements in a process, method or device that comprises the element. In this document, each embodiment may be described with emphasis on differences from other embodiments, and the same and similar parts between the respective embodiments may be referred to each other. For methods, products, etc. of the embodiment disclosures, reference may be made to the description of the method section for relevance if it corresponds to the method section of the embodiment disclosure.
Those of skill in the art would appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software may depend upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the disclosed embodiments. It can be clearly understood by the skilled person that, for convenience and brevity of description, the specific working processes of the system, the apparatus and the unit described above may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the embodiments disclosed herein, the disclosed methods, products (including but not limited to devices, apparatuses, etc.) may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units may be merely 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, devices or units, and may be in an electrical, mechanical 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 network units. Some or all of the units can be selected according to actual needs to implement the present embodiment. In addition, functional units in the embodiments of the present disclosure 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 flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. In the description corresponding to the flowcharts and block diagrams in the figures, operations or steps corresponding to different blocks may also occur in different orders than disclosed in the description, and sometimes there is no specific order between the different operations or steps. For example, two sequential operations or steps may in fact be executed substantially concurrently, or they may sometimes be executed in the reverse order, depending upon the functionality involved. Each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations, can be implemented by special purpose hardware-based systems that perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.

Claims (11)

1. A method for generating a code coverage report for use in a test device, comprising:
in the process of testing codes, obtaining a code coverage rate report request of a user;
feeding back a code coverage report in case the code coverage report is valid;
and generating a code coverage report and feeding back the code coverage report in the case that the code coverage report is invalid.
2. The method of claim 1, wherein reporting the validity of the code coverage comprises:
there is a code coverage report and the code coverage report is not marked as expired.
3. The method of claim 1, wherein reporting the invalid code coverage comprises:
no code coverage report exists or a code coverage report is marked as expired.
4. The method of claim 1, wherein generating the code coverage report comprises:
sending a request for acquiring code execution conditions to all servers;
receiving code execution conditions sent by all the servers;
and generating a code coverage rate report according to the code execution conditions sent by all the servers.
5. The method according to any of claims 1 to 4, wherein in case no code coverage reporting request is obtained for a user, the method further comprises:
receiving the code execution condition sent by the server; wherein the code execution condition is intercepted by the intercepting tool at the server and sent from the corresponding server if a first condition is met;
under the condition that a second condition is met, sending a request for acquiring the code execution condition to the rest servers; receiving code execution conditions sent by the rest servers; generating a code coverage rate report according to the code execution conditions sent by all servers, and obtaining an updated code coverage rate report;
if the second condition is not satisfied, the existing code coverage report is treated as an updated code coverage report.
6. The method of claim 5, wherein the first condition comprises:
the data volume of the newly added and stored code execution condition is greater than or equal to the preset data volume; or the like, or a combination thereof,
the time length from the sending time of the last code execution situation is larger than or equal to a first preset time length.
7. The method of claim 5, wherein the second condition comprises:
there is no code coverage report; or the like, or a combination thereof,
a code coverage rate report exists, and the execution condition of the code received this time is different from the execution condition of the code received last time; or the like, or, alternatively,
and the time difference between the receiving time of the code coverage report existing and the receiving time of the code execution situation of this time and the time of the last generation of the code coverage report is greater than or equal to a second preset time length.
8. The method of claim 5, wherein after the receiving the code sent by the server executes, the method further comprises:
in the case where there is a code coverage report, the existing code coverage report is marked as expired.
9. An apparatus for generating a code coverage report, comprising a processor and a memory having stored thereon program instructions, wherein the processor is configured to, upon execution of the program instructions, perform the method for generating a code coverage report according to any of claims 1 to 8.
10. A test apparatus, comprising:
a test equipment body; and the combination of (a) and (b),
the apparatus for generating a code coverage report of claim 9 installed at said test equipment body.
11. A storage medium storing program instructions, characterized in that said program instructions, when executed, perform the method for generating a code coverage report according to any of claims 1 to 8.
CN202211520287.1A 2022-11-30 2022-11-30 Method and device for generating code coverage rate report, test equipment and storage medium Pending CN115934524A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211520287.1A CN115934524A (en) 2022-11-30 2022-11-30 Method and device for generating code coverage rate report, test equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211520287.1A CN115934524A (en) 2022-11-30 2022-11-30 Method and device for generating code coverage rate report, test equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115934524A true CN115934524A (en) 2023-04-07

Family

ID=86697115

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211520287.1A Pending CN115934524A (en) 2022-11-30 2022-11-30 Method and device for generating code coverage rate report, test equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115934524A (en)

Similar Documents

Publication Publication Date Title
CN108959059B (en) Test method and test platform
CN109408375B (en) Method and device for generating interface document
CN105302710A (en) Method and apparatus for determining test case in need of regression testing
CN107145437B (en) Java annotation test method and device
CN110290212A (en) Service call recording method, device, computer equipment and storage medium
US9558055B2 (en) System level memory leak detection
CN111026601A (en) Monitoring method and device for Java application system, electronic equipment and storage medium
CN111045921A (en) Automatic interface testing method and device, computer equipment and storage medium
CN110347545A (en) A kind of test method and device of business platform cache policy
CN109491663A (en) Code inspection method and device
CN112241360A (en) Test case generation method, device, equipment and storage medium
CN113448854A (en) Regression testing method and device
CN113111000A (en) Continuous integration automation test system and method, electronic device and storage medium
CN111506358B (en) Method and device for updating container configuration
CN112181813A (en) Interface automation test method, system and computer readable storage medium
CN106201864A (en) A kind of application programming interface API method of testing, device and mobile device
CN106294114A (en) A kind of code coverage acquisition methods, server and application apparatus to be measured
CN109002305A (en) A kind of update method and its system of device program
CN110069406A (en) The TPC-DS test method and system of automatic trigger
CN113448844A (en) Method and device for regression testing and electronic equipment
CN110908708B (en) Code release method, device and system
CN115934524A (en) Method and device for generating code coverage rate report, test equipment and storage medium
CN108647139B (en) System test method, device, storage medium and electronic device
CN113704114A (en) Automatic testing method, device, equipment and medium for functional interface
CN114003250A (en) Software deployment method and device

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