Code coverage generation method, device, server, medium and program product

By obtaining the compiled code of the tested application in the compiled dataset and generating code coverage with the test coverage data, the problem of high failure rate of the code coverage generation process in the existing technology is solved, and the stability and success rate of the generated code coverage are improved.

CN119739619APending Publication Date: 2025-04-01CONTEMPORARY AMPEREX FUTURE ENERGY RES INST (SHANGHAI) LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311267171.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-27
Publication Date
2025-04-01

AI Technical Summary

Technical Problem

In the prior art, the code coverage generation process has the problem of high failure rate, which reduces the stability of code coverage generation.

Method used

By obtaining the compiled code of the tested application in the pre-built compiled data set, and generating code coverage with the test coverage data, reducing the number of compiled times and reducing the probability of compilation exceptions.

Benefits of technology

It improves the success rate and stability of the generated code coverage, reduces the probability of compilation exceptions, and enhances the reliability of code coverage generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119739619A_ABST
    Figure CN119739619A_ABST
Patent Text Reader

Abstract

The present application relates to a method, device, server, medium and program product for generating code coverage. The method comprises: in response to a data reporting request of the application under test at the current moment, obtaining the compiled code of the source code of the application under test in the compiled data set; generating the code coverage of the application under test according to the test coverage data and the compiled code. The data reporting request includes the test coverage data generated by the source code test of the application under test at the current moment; the compiled data set includes the compiled code of the source code of multiple different application programs pre-stored. The use of this method can reduce the probability of compilation anomalies and improve the success rate and stability of generating code coverage.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of software testing technology, and in particular to a code coverage generation method, device, server, medium and program product. Background Art

[0002] Code coverage is an important metric in software testing, which is used to describe the proportion and extent of the source code of the application being tested.

[0003] In the related art, in the process of source code testing of the application under test, each time a set of test coverage data is obtained, it is necessary to obtain the source code of the application under test once, compile it to obtain the compiled code, and then generate the code coverage of the application under test based on the test coverage data and the compiled code.

[0004] However, in the related art, the code coverage generation process of the tested application has a high failure rate, which reduces the stability of the code coverage generation. Summary of the invention

[0005] Based on this, it is necessary to provide a code coverage generation method, device, server, medium and program product to address the above technical problems.

[0006] In a first aspect, the present application provides a method for generating code coverage, comprising:

[0007] In response to a data reporting request of the application under test at the current moment, the compiled code of the source code of the application under test is obtained in the compiled data set; the data reporting request includes test coverage data generated by the source code test of the application under test at the current moment; the compiled data set includes the compiled code of the source code of multiple different application programs pre-stored;

[0008] Generate code coverage of the application under test based on the test coverage data and compiled code.

[0009] In an embodiment of the present application, compiled codes of multiple different applications are pre-stored in the compilation data set. After receiving the data reporting request of the application under test at the current moment, there is no need to compile the source code of the application under test. The compiled code of the application under test can be directly obtained in the compilation data set, and the code coverage rate can be generated in combination with the reported test coverage data, so that the probability of compilation exceptions is greatly reduced, thereby improving the success rate and stability of generating code coverage rate.

[0010] In one embodiment, the data reporting request also includes identity information of the application under test; obtaining compiled code of the source code of the application under test in the compiled data set includes:

[0011] Determine the identity of the application under test according to the identity information of the application under test;

[0012] Obtain the compiled code that matches the identity of the application under test from the compiled data set as the compiled code of the application under test.

[0013] In the embodiment of the present application, the data reporting request includes the identity information of the application under test, and the identity information of the application under test can determine the identity of the application under test. The compiled code matching the identity of the application under test is obtained in the compiled data set as the compiled code of the application under test. The acquisition of the compiled code based on the identity is not only convenient and fast, but also improves the acquisition efficiency. In addition, the identity can uniquely characterize the application program, which correspondingly increases the matching between the obtained compiled code and the application under test, thereby improving the accuracy of the obtained compiled code of the application under test.

[0014] In one embodiment, the identity information of the tested application includes the application name and application version of the tested application; and determining the identity identifier of the tested application according to the identity information of the tested application includes:

[0015] Generate an identity of the application under test based on the application name and application version of the application under test.

[0016] In an embodiment of the present application, the application name and application version of the tested application are used to comprehensively generate an identity identifier of the tested application, which is adapted to the iterative update of the application program. When determining the identity identifier of the tested application, the application name and application version of the tested application are taken into consideration, thereby improving the strong correlation between the generated identity identifier and the tested application, and also strengthening the uniqueness of the identity identifier of the tested application.

[0017] In one embodiment, generating code coverage of the application under test based on the test coverage data and the compiled code includes:

[0018] According to the test coverage data and the historical test coverage data of the tested application, obtaining the coverage amount of at least one data type that needs to be generated by the tested application at the current moment;

[0019] According to the compiled code, determine the total amount of each data type to be covered;

[0020] Determine the code coverage of each data type based on the covered amounts and the total amounts to be covered.

[0021] In an embodiment of the present application, the code coverage of a corresponding data type is determined based on the covered amount and the total amount to be covered of at least one data type, so that the code coverage of the corresponding data type is generated in a targeted manner, so that the code coverage can be generated on demand, and at the same time, the types of the generated code coverage are enriched and the diversity is improved.

[0022] In one embodiment, obtaining the coverage amount of at least one data type that needs to be generated by the application under test at the current moment according to the test coverage data and the historical test coverage data of the application under test includes:

[0023] The test coverage data and historical test coverage data are combined and deduplicated to obtain a deduplicated data set;

[0024] The number of data corresponding to each data type in the deduplicated data set is taken as the coverage amount of each data type.

[0025] In an embodiment of the present application, the merged deduplication process improves the uniqueness of the data in the deduplication data set, providing an accurate data basis for the subsequent determination of the coverage amount, and the amount of data can accurately measure the testing progress of the source code test, thereby improving the accuracy of the coverage amount of each data type obtained.

[0026] In one embodiment, the process of constructing the compiled dataset includes:

[0027] Obtaining source code indication information of multiple applications; the source code indication information is used to represent the storage path of the application source code;

[0028] Generates a compilation data set based on source code instructions for multiple applications.

[0029] In an embodiment of the present application, a compilation data set including compiled codes of multiple applications is generated based on the acquired source code indication information of multiple applications, thereby improving the data richness of the compilation data set to cover more applications, thereby correspondingly improving the scope of application of the code coverage generation method.

[0030] In one embodiment, generating a compilation data set based on source code indication information of a plurality of applications includes:

[0031] Determine the storage location of the source code of each application according to the storage path of the source code of each application;

[0032] Obtaining the source code of each application from a storage location of the source code of each application;

[0033] The source code of each application is compiled, and a compiled data set is generated according to the compiled code of each application.

[0034] In an embodiment of the present application, the storage path can locate the storage location and obtain the source code directly from the storage location, which is not only convenient and efficient and has a low error probability, but also the obtained source code has high reliability. The source code of each application is compiled in advance and stored in the compilation data set, which greatly reduces the number of subsequent compilations, reduces the compilation time, and correspondingly reduces the probability of compilation exceptions. While improving the generation efficiency, it also improves the success rate and stability of the generated code coverage.

[0035] In one embodiment, the method further comprises:

[0036] Get the identity information of each application;

[0037] Generate an identity tag for each application program according to the identity information of each application program;

[0038] Associating the identity of each application with the compiled code of the corresponding application to obtain an association relationship;

[0039] Store the associations in a compiled dataset.

[0040] In an embodiment of the present application, an identity identifier of an application is generated based on the identity information of the application, and the uniqueness of the identity identifier is improved by virtue of the uniqueness of the identity information, thereby improving the accuracy and convenience of subsequently locating the application under test, and associating the compiled code of the application with the identity identifier, thereby improving the correlation between the compiled code and the corresponding application, and improving the accuracy and convenience of subsequently locating the compiled code of the application under test.

[0041] In one embodiment, the method further comprises:

[0042] Generates a coverage report including the code coverage at the current moment;

[0043] Display coverage reports via web pages.

[0044] In an embodiment of the present application, a coverage report including the code coverage of the application under test at the current moment is displayed in real time on a web page, thereby improving the timeliness of the code coverage display, so that testers / developers can timely understand the test status of the application under test and make timely test adjustments when necessary.

[0045] In a second aspect, the present application also provides a code coverage generation device, comprising:

[0046] A response module, configured to respond to a data reporting request of the application under test at the current moment, and obtain the compiled code of the source code of the application under test in the compiled data set; the data reporting request includes the test coverage data generated by the source code test of the application under test at the current moment; the compiled data set includes the compiled code of the source code of multiple different application programs pre-stored;

[0047] The generation module is used to generate the code coverage of the application under test based on the test coverage data and the compiled code.

[0048] In a third aspect, the present application further provides a server, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of any one of the above-mentioned code coverage generation methods when executing the computer program.

[0049] In a fourth aspect, the present application also provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of any of the above-mentioned code coverage generation methods when the computer program is executed by a processor.

[0050] In a fifth aspect, the present application also provides a computer program product, including a computer program, which implements the steps of any of the above-mentioned code coverage generation methods when executed by a processor.

[0051] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] Figure 1 An application environment diagram of a code coverage generation method in an embodiment;

[0053] Figure 2 A schematic diagram of a flow chart of a method for generating code coverage in one embodiment;

[0054] Figure 3 A schematic diagram of a process of obtaining compiled code of an application under test in one embodiment;

[0055] Figure 4 A schematic diagram of a process for generating code coverage of a tested application in one embodiment;

[0056] Figure 5 A schematic diagram of a process of obtaining the coverage amount of a tested application in one embodiment;

[0057] Figure 6 A schematic diagram of a process for constructing a compiled data set in one embodiment;

[0058] Figure 7 A schematic diagram of a process for generating a compilation data set according to source code indication information in one embodiment;

[0059] Figure 8 A schematic diagram of a process for constructing a compiled data set in another embodiment;

[0060] Fig. 9 A schematic diagram of a process for generating and displaying a coverage report in an embodiment;

[0061] Fig.10 A schematic diagram of a flow chart of a method for generating code coverage in another embodiment;

[0062] Fig.11 A code coverage generation process in one embodiment;

[0063] Fig.12 A modular schematic diagram of a coverage collection device in one embodiment;

[0064] Fig.13 is a structural block diagram of a code coverage generating device in one embodiment;

[0065] Fig.14 FIG. 4 is a diagram showing the internal structure of a server in one embodiment. DETAILED DESCRIPTION

[0066] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0067] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by technicians in the technical field to which this application belongs; the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit this application; the term "including" and any variations thereof in the specification and claims of this application and the above-mentioned figure descriptions are intended to cover non-exclusive inclusions.

[0068] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0069] In the description of the embodiments of the present application, the term "and / or" is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist at the same time, and B exists alone. In the description of the embodiments of the present application, the term "plurality" refers to more than two (including two), unless otherwise clearly and specifically defined.

[0070] Code coverage is an important metric in software testing, which is used to describe the proportion and degree of source code testing of the application under test. For testers / developers, code coverage can be used as a basis for risk assessment of software development projects. Therefore, code coverage is one of the key areas of focus for testers / developers during software testing / development.

[0071] Software testing can also be called source code testing, which is a process of running the application under test manually or automatically, and gradually executing / covering the source code of the application under test to generate test coverage data. Usually, the test coverage data of the application under test is continuously generated as the source code testing is carried out. In the related art, in the process of source code testing of the application under test, each time a set of test coverage data is obtained, it is necessary to obtain the source code of the application under test once, compile it to obtain the compiled code, and then generate the code coverage of the application under test based on the test coverage data and the compiled code.

[0072] In actual applications, the process of source code testing of the application under test will generate a large amount of test coverage data. The relevant technology requires obtaining the source code of the application under test multiple times and compiling it multiple times accordingly, which not only increases the time cost, but also increases the probability of compilation exceptions. Compilation exceptions cannot obtain the compiled code, and code coverage cannot be generated, which leads to technical problems such as high failure rate and poor stability in the process of generating code coverage of the application under test.

[0073] Therefore, the embodiments of the present application provide a code coverage generation method, device, server, medium and program product, which obtain the compiled code of the application under test from the pre-built compilation data set when receiving the test coverage data of the application under test, so as to generate the code coverage of the application under test according to the compiled code and test coverage data of the application under test. Thereby reducing the number of compilations, not only saving the compilation time, but also reducing the probability of compilation exceptions, and correspondingly achieving the technical effect of improving the success rate and stability of the generated code coverage.

[0074] The code coverage generation method provided in the embodiment of the present application can be applied to Figure 1In the application environment shown. Among them, the terminal 100 communicates with the server 200 through the network. The data storage system can store the data that the server 200 needs to process. The data storage system can be integrated on the server 200, or it can be placed on the cloud or other network servers. In the process of source code testing of the application under test on the terminal 100, the application under test can send a data reporting request at the current moment to the server 200 through the terminal 100, and the server 200 responds to the data request at the current moment, and obtains the compiled code of the source code of the application under test in the compiled data set, so as to generate the code coverage rate of the application under test according to the test coverage data generated by the source code test of the application under test at the current moment included in the data reporting request, and the compiled code. Among them, the terminal 100 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices, and the Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 200 can be implemented with an independent server or a server cluster consisting of multiple servers. The above-mentioned compiled data set can be stored in a data storage system.

[0075] In one embodiment, Figure 2 As shown, a code coverage generation method is provided, which is applied to Figure 1 The server in the example is used to illustrate the following steps:

[0076] S210. In response to a data reporting request of the application under test at the current moment, obtain the compiled code of the source code of the application under test in the compiled data set; the data reporting request includes the test coverage data generated by the source code test of the application under test at the current moment; the compiled data set includes the compiled code of the source code of multiple different application programs pre-stored.

[0077] The process of testing the source code of the application under test is the software testing process. Specifically, the application under test is run manually or automatically, and the source code of the application under test is gradually executed / covered during the test. Code coverage is a measure of the code executed during the entire test process, which is used to reflect which statements in the source code of the application under test are executed during the test and which statements are not executed.

[0078] The executed / covered part of the source code of the application under test is called test coverage data. As the test progresses, the application under test will continuously generate new test coverage data. Each time a set of test coverage data is generated, the terminal generates a data reporting request including the test coverage data in real time and sends the data reporting request to the server.

[0079] The server receives the data reporting request sent by the terminal, and in response to the data reporting request, obtains the compiled code of the source code of the corresponding application under test in the compiled data set. The compiled data set can be obtained based on the basic information of a variety of different application programs that are pre-entered. The basic information can be the source code of each application program, or can be used to obtain indicative information of the source code, such as the address for obtaining the source code.

[0080] In an optional embodiment, the server may predetermine the entry order of each application in the compiled data set, and use the entry order as the test order. After receiving the data reporting request, the server may obtain the test sequence number carried in the test request, and use the test sequence number as the entry sequence number to obtain the compiled code of the source code of the application corresponding to the entry sequence number in the compiled data set. Among them, the test sequence number represents the test sequence, and the entry sequence number represents the entry sequence. For example, when the test sequence number is sequence number 1 representing the first test, the server obtains the compiled code of the source code of the application corresponding to the entry sequence number 1 in the compiled data set.

[0081] S220: Generate code coverage of the application under test according to the test coverage data and the compiled code.

[0082] The compiled code corresponding to the application under test may be used to determine all data required to be covered by source code testing of the application under test.

[0083] The server can determine all data that need to be covered based on the compiled code of the application under test, and compare the test coverage data with all data that need to be covered to determine the execution degree of the source code of the application under test to generate the code coverage of the application under test.

[0084] In an embodiment of the present application, by responding to a data reporting request of the application under test at the current moment, the compiled code of the source code of the application under test is obtained in the compiled data set, so as to generate the code coverage of the application under test based on the test coverage data and the compiled code. Among them, the data reporting request includes the test coverage data generated by the source code test of the application under test at the current moment; the compiled data set includes the compiled code of the source code of multiple different applications pre-stored. In the above method, the compiled code of multiple different applications is pre-stored in the compiled data set. After receiving the data reporting request of the application under test at the current moment, there is no need to compile the source code of the application under test. The compiled code of the application under test can be directly obtained in the compiled data set, and the code coverage can be generated in combination with the reported test coverage data, so that the probability of compilation anomalies is greatly reduced, thereby improving the success rate and stability of generating code coverage.

[0085] In actual applications, the data reporting request also includes the identity information of the application being tested. Based on this, in one embodiment, Figure 3 As shown, the compiled code of the source code of the application under test is obtained in the compiled data set in S210, including:

[0086] S310: Determine the identity of the application under test according to the identity information of the application under test.

[0087] The identity information of the tested application is used to represent the identity of the tested application. The identity identifier corresponds to the application program, and the same identity identifier is used to represent the same application program. The identity identifier can be represented by at least one character, such as at least one of letters, numbers, words, and symbols.

[0088] In an optional embodiment, when the identity information of the tested application includes the application name of the tested application, the server may parse the received data reporting request to obtain the identity information of the tested application included in the data reporting request, and obtain the application name of the tested application therefrom, so as to determine the identity information corresponding to the application name of the tested application in the pre-stored correspondence between the application name and the identity identifier. The correspondence between the application name and the identity identifier may be stored in a list form, and the server may determine the identity information corresponding to the application name of the tested application by looking up a table.

[0089] S320: Obtain, from the compiled data set, compiled code that matches the identity identifier of the application under test as the compiled code of the application under test.

[0090] Each application in the compiled data set corresponds to its own identity.

[0091] After obtaining the identity of the application under test, the server can determine the identity of each application in the compiled data set accordingly, and compare the identity of the application under test with the identity of each application in the compiled data set, determine the compiled code of the application whose identity is the same as the identity of the application under test in the compiled data set, determine it as the compiled code that matches the identity of the application under test, and use it as the compiled code of the application under test.

[0092] In an embodiment of the present application, the data reporting request also includes the identity information of the application under test, so as to determine the identity of the application under test based on the identity information of the application under test, and obtain the compiled code matching the identity of the application under test in the compiled data set as the compiled code of the application under test. In the above method, the data reporting request includes the identity information of the application under test, and the identity information of the application under test can determine the identity of the application under test, and obtain the compiled code matching the identity of the application under test in the compiled data set as the compiled code of the application under test. Obtaining the compiled code based on the identity is not only convenient and fast, but also improves the acquisition efficiency. In addition, the identity can uniquely represent the application program, which correspondingly increases the matching between the obtained compiled code and the application under test, thereby improving the accuracy of the obtained compiled code of the application under test.

[0093] In actual applications, the development of applications is constantly iteratively updated, so the identity information that characterizes the identity of the application includes not only the application name, but also the application version of the application. Based on this, in one embodiment, the above S310, determining the identity of the application under test according to the identity information of the application under test, includes:

[0094] Generate an identity of the application under test based on the application name and application version of the application under test.

[0095] The identity information of the tested application includes the application name and application version of the tested application, and the identity of the tested application can be represented by the application name and application version of the tested application.

[0096] In an optional embodiment, the server may directly concatenate the application name and application version of the application under test to generate the identity of the application under test. For example, if the application name of the application under test is AAA and the application version is V1, the server concatenates the application name and application version of the application under test to obtain the string "AAAV1" as the identity of the application under test.

[0097] In another optional embodiment, the server can determine the name code corresponding to the application name of the tested application based on the correspondence between the application name and the name code, determine the name code corresponding to the application version of the tested application based on the correspondence between the application version and the version code, and concatenate the name code and version code of the tested application to generate the identity of the tested application. For example, the application name of the tested application is AAA, corresponding to the name code 001; the application version of the tested application is V2, corresponding to the version code 01; the server concatenates the name code and version code of the tested application to obtain the string "00101" as the identity of the tested application.

[0098] In an embodiment of the present application, the identity information of the application under test includes the application name and application version of the application under test, so as to generate an identity identifier of the application under test based on the application name and application version of the application under test. In the above method, the application name and application version of the application under test are used to comprehensively generate the identity identifier of the application under test, which is adapted to the iterative update of the application program. When determining the identity identifier of the application under test, the application name and application version of the application under test are taken into consideration, thereby improving the strong correlation between the generated identity identifier and the application under test, and also strengthening the uniqueness of the identity identifier of the application under test. The test coverage data includes data of at least one data name type, and the generated code coverage rate correspondingly includes the code coverage rate corresponding to the data of the data name type. Therefore, in one of the embodiments, Figure 4 As shown, the above S220, generating the code coverage of the application under test according to the test coverage data and the compiled code, includes:

[0099] S410: Obtain, based on the test coverage data and the historical test coverage data of the application under test, a coverage amount of at least one data type that needs to be generated for the application under test at the current moment.

[0100] The data type includes a file, a class, a method or a line number. The covered amount may be the actual amount of data of the corresponding data type, or the amount of data of the corresponding data type.

[0101] Test coverage data is sent in real time along with data reporting requests as source code testing proceeds. Historical test coverage data is the test coverage data sent by the same application under test in this source code test before the current time. For example, the source code test of the application under test starts at time T0, and at the current time, the Tn terminal reports a set of test coverage data to the server. The test coverage data reported between T0 and Tn is the historical test coverage data of the application under test.

[0102] After obtaining the test coverage data at the current moment, the server obtains the historical test coverage data before the current time in the source code test of the tested application, and summarizes and integrates the test coverage data at the current moment and the historical test coverage data to obtain all the test coverage data at the current moment.

[0103] Among them, all the test covered data include data of at least one data type, and different data types have different data representation forms. For example, file data is represented in the form of file name, method data is represented in the form of method name, and line number data is represented in the form of digital number. The server determines the data type of the data according to the data representation form of the data included in all the test covered data.

[0104] In an optional embodiment, at least one data type that needs to be generated by the tested application at the current moment can be a pre-configured target data type. The server obtains data of each target data type from all test covered data at the current moment, and determines the coverage amount of the corresponding target data type for the data of each target data type. For example, if the target data type is a file type, the server obtains data of the file type from all test covered data at the current moment, and determines the coverage amount of the file type based on the data of the file type, such as obtaining the total actual data amount of the file type as the coverage amount of the file type.

[0105] In another optional embodiment, at least one data type that needs to be generated by the application under test at the current moment may be a template data type extracted from a report template of a coverage report in response to a user refreshing operation of the coverage report displayed on a display unit of the server. The server obtains data of each template data type from all test coverage data at the current moment, and determines the coverage amount of the corresponding template data type for the data of each template data type. Among them, at least one data type that needs to be generated by the application under test at the current moment may also be a mobile data type input by the user to the server in real time.

[0106] S420. Determine the total amount of each data type to be covered according to the compiled code.

[0107] The compiled code of the application under test can be used to indicate all data that needs to be covered for source code testing of the application under test. The sum of the total amount of each data type to be covered is all the data that needs to be covered.

[0108] The server can determine all the data that needs to be covered based on the compiled code of the application under test, analyze and determine the data type of each data in all the data that needs to be covered, and determine the total amount of the corresponding data type to be covered for each data type. For example, all the data that needs to be covered include data a1, a2, b1, b3, b4, c3, d1 and d2, data a1 and a2 are file-type data, data b1, b3, b4 are class data, data c3 is method-type data, data d1 and d2 are line number data, and the server can determine the total amount A of file-type data to be covered based on data a1 and a2, determine the total amount B of class data to be covered based on data b1, b3, b4, determine the total amount C of method-type data to be covered based on data c3, and determine the total amount D of line number data to be covered based on data d1 and d2.

[0109] In an optional embodiment, the total amount of each data type to be covered can be the actual amount of data of each data type. In another optional embodiment, the total amount of each data type to be covered can also be the number of data of each data type. For example, continuing the above example, the total amount A of file data to be covered can be the actual amount of data m of data a1 and a2, or the number 2 of data a1 and a2; the total amount B of class data to be covered can be the actual amount of data n of data b1, b3, and b4, or the number 3 of data b1, b3, and b4; the total amount C of method data to be covered can be the actual amount of data p of data c3, or the number 1 of data c3; the total amount D of line number data to be covered can be the actual amount of data q of data d1 and d2, or the number 2 of data d1 and d2.

[0110] S430: Determine the code coverage rate of each data type according to each covered amount and each total amount to be covered.

[0111] After obtaining the amount of coverage and the total amount to be covered of each data type of the tested application, the server can determine the ratio between the amount of coverage of the data type and the total amount to be covered of the corresponding data type as the code coverage of the corresponding data type for any data type, and thus obtain the code coverage of each data type. For example, the amount of coverage of the corresponding files, classes, methods and line numbers of the tested application at the current moment are a, b, c and d respectively, and the total amount to be covered of the corresponding files, classes, methods and line numbers of the tested application are A, B, C and D respectively. The server can calculate the code coverage of the corresponding file type as a / A, the code coverage of the corresponding class as b / B, the code coverage of the corresponding method class as c / C, and the code coverage of the corresponding line number as d / D.

[0112] In an embodiment of the present application, based on the test coverage data and the historical test coverage data of the tested application, the coverage amount of at least one data type that needs to be generated by the tested application at the current moment is obtained, and based on the compiled code, the total amount to be covered of each data type is determined, so as to determine the code coverage of each data type based on each covered amount and each total amount to be covered. In the above method, the code coverage of the corresponding data type is determined based on the covered amount and the total amount to be covered of at least one data type, so as to generate the code coverage of the corresponding data type in a targeted manner, so that the code coverage can be generated on demand, and at the same time, the types of the generated code coverage are enriched, thereby improving the diversity.

[0113] There is duplicate data between the test coverage data of the tested application at the current moment and the historical test coverage data before the current moment. In order to improve the accuracy of the coverage amount of each data type, in one embodiment, Figure 5As shown, the above S410, according to the test coverage data and the historical test coverage data of the tested application, obtains the coverage amount of at least one data type that needs to be generated by the tested application at the current moment, including:

[0114] S510: De-duplicate and merge the test coverage data and the historical test coverage data to obtain a de-duplicated data set.

[0115] The deduplicated data set includes all data that has been executed / covered during the source code test of the application under test as of the current moment.

[0116] After obtaining the test coverage data at the current moment and the historical test coverage data before the current moment, the server can remove duplicates and merge the test coverage data with the historical test coverage data to form a deduplicated data set. For example, the test coverage data at the current moment includes file 3, class I, method B, and line number 050, and the historical test coverage data before the current moment includes file 1, file 2, class I, class II, method A, and line numbers 010 to 050. The server removes duplicates and merges these two sets of test coverage data and the historical test coverage data to obtain a deduplicated data set {file 1, file 2, file 3, class I, class II, method A, method B, line numbers 010 to 050}.

[0117] S520. The number of data corresponding to each data type in the deduplicated data set is used as the coverage amount of each data type.

[0118] The server may first divide the data in the deduplication data set into data types to determine the data corresponding to each data type, and for each data type, count the number of data of the data type as the coverage amount of the corresponding data type. For example, continuing the above example, the deduplication data set {file 1, file 2, file 3, class I, class II, method A, method B, line number 010-050}, the server may divide the data in the deduplication data set into data types according to the data name characteristics, and obtain that file 1, file 2, file 3 belong to the file type data, class I, class II belong to the class data, method A, method B belong to the method type data, and line number 010-050 belongs to the line number type data. The server further counts the number of data of each data type, the number of data of the file type is 3, the number of data of the class is 2, the number of data of the method type is 2, and the number of data of the line number type is 50, which is the coverage amount of each data type.

[0119] In the embodiment of the present application, the test coverage data and the historical test coverage data are merged and deduplicated to obtain a deduplicated data set, and then the number of data corresponding to each data type in the deduplicated data set is used as the coverage amount of each data type. In the above method, the merging and deduplication process improves the uniqueness of the data in the deduplicated data set, providing an accurate data basis for the subsequent determination of the coverage amount, and the number of data can accurately measure the test progress of the source code test, thereby improving the accuracy of the coverage amount of each data type obtained.

[0120] The above code coverage generation method also includes a process of compiling a data set. In one embodiment, Figure 6 As shown in the figure, the construction process of the compiled dataset includes:

[0121] S610: Obtain source code indication information of multiple application programs; the source code indication information is used to represent the storage path of the application program source code.

[0122] The source code indication information includes at least one of a code address, a code branch, and a branch submission ID. Different application programs correspond to different source code indication information.

[0123] The server is configured with an input interface for testers / developers to input source code indication information of multiple application programs into the server, and the server obtains the source code indication information of the multiple application programs accordingly.

[0124] S620: Generate a compilation data set according to source code indication information of multiple application programs.

[0125] After obtaining source code indication information of multiple applications, the server determines the storage path of the corresponding application according to each source code indication information, obtains the source code of each application according to the storage path, and generates a compilation data set according to the source code of each application.

[0126] In an embodiment of the present application, source code indication information of multiple applications is obtained, and a compilation data set is generated based on the source code indication information of the multiple applications. The source code indication information is used to characterize the storage path of the source code of the application. In the above method, a compilation data set including the compiled codes of the multiple applications is generated based on the obtained source code indication information of the multiple applications, thereby improving the data richness of the compilation data set to cover more applications, and correspondingly improving the scope of application of the code coverage generation method.

[0127] The compiled data set includes the compiled code of the source code. Based on this, in one embodiment, Figure 7 As shown, the above S620, generating a compilation data set according to source code indication information of multiple application programs, includes:

[0128] S710: Determine the storage location of the source code of each application program according to the storage path of the source code of each application program.

[0129] The storage location of the source code is the storage location of the source code in the source code database.

[0130] After obtaining the source code indication information of each application, the server may determine the storage path based on the source code indication information to determine the storage location of the source code of each application corresponding to each storage path.

[0131] S720: Acquire the source code of each application from the storage location of the source code of each application.

[0132] After obtaining the storage location of the source code of each application, the server can obtain the source code of each application at the corresponding storage location in the source code database.

[0133] S730 . Compile the source code of each application program, and generate a compilation data set according to the compiled code of each application program.

[0134] After obtaining the source code of each application, the server may compile the source code of each application to obtain the compiled code of each application, and then aggregate the compiled code of each application to generate a compiled data set.

[0135] In the embodiment of the present application, the storage location of the source code of each application is determined according to the storage path of the source code of each application, the source code of each application is obtained from the storage location of the source code of each application, and the source code of each application is compiled to generate a compilation data set according to the compiled code of each application. In the above method, the storage path can locate the storage location, and the source code is directly obtained from the storage location, which is not only convenient and efficient with a low error probability, but also has high reliability of the obtained source code. In addition, the source code of each application is compiled in advance and stored in the compilation data set, which greatly reduces the number of subsequent compilations, reduces the compilation time, and correspondingly reduces the probability of compilation exceptions. While improving the generation efficiency, it also improves the success rate and stability of the generated code coverage.

[0136] To improve the relevance between the compiled code in the compiled data set and the corresponding application, in one embodiment, Figure 8 As shown, the above method also includes:

[0137] S810. Obtain identity information of each application.

[0138] The server is configured with an input interface for testers / developers to input identity information of multiple applications into the server, and the server obtains the identity information of each application accordingly.

[0139] In an optional embodiment, the server can simultaneously receive source code indication information of multiple applications and identity information of corresponding applications inputted to the server by the tester / developer based on the same input interface. In another optional embodiment, the server can also receive source code indication information of multiple applications and identity information of corresponding applications inputted to the server by the tester / developer based on different input interfaces.

[0140] S820: Generate an identity tag for each application program according to the identity information of each application program.

[0141] The identity information of the application includes the application name and application version of the application, and the identity of the application can be represented by the application name and application version of the application.

[0142] In an optional embodiment, the server may directly concatenate the application name and the application version of the application to generate the identity of the application. In another optional embodiment, the server may determine the name code corresponding to the application name of the application according to the correspondence between the application name and the name code, determine the name code corresponding to the application version of the application according to the correspondence between the application version and the version code, and concatenate the name code and the version code of the application to generate the identity of the application.

[0143] It should be noted that the above process of generating the identity of the application according to the identity information of the application is the same as the process of determining the identity of the application under test according to the identity information of the application under test in the aforementioned embodiment. For example, if the identity of the application is generated by combining the application name and the application version of the application, then the identity of the application under test is also determined by combining the application name and the application version of the application under test.

[0144] S830: Associating the identity of each application with the compiled code of the corresponding application to obtain an association relationship.

[0145] After obtaining the identity of each application and the compiled code of each application, the server can associate the identity of each application with the corresponding compiled code to obtain the association relationship between the identity information of all applications and the compiled code.

[0146] S840: Store the association relationship in the compiled data set.

[0147] The server may store the aforementioned association relationship between the identity information of all application programs and the compiled codes in a compiled data set.

[0148] In the embodiment of the present application, the identity information of each application is obtained, and the identity identifier of each application is generated according to the identity information of each application, and the identity identifier of each application is associated with the compiled code of the corresponding application to obtain an association relationship, so as to store the association relationship in the compiled data set. In the above method, the identity identifier of the application is generated according to the identity information of the application, and the uniqueness of the identity identifier is improved by means of the uniqueness of the identity information, and the accuracy and convenience of the subsequent positioning of the tested application is improved, and the compiled code of the application is associated with the identity identifier, which improves the correlation between the compiled code and the corresponding application, and improves the accuracy and convenience of the subsequent positioning of the compiled code of the tested application.

[0149] After the code coverage is generated, the code coverage can also be displayed using a coverage report. Based on this, in one embodiment, if Fig. 9 As shown, the above method also includes:

[0150] S910: Generate a coverage report including the code coverage at the current moment.

[0151] Among them, the coverage report allows testers / developers to check the current code coverage in real time.

[0152] When the code coverage of the tested application at the current moment is generated, the server may fill the generated code coverage into the corresponding position in the coverage report, and generate a coverage report including the code coverage at the current moment.

[0153] In an optional embodiment, when a coverage report is generated for the first time in the source code test of the application under test at the current moment, the server can calculate and generate the code coverage of the template data type at the current moment through the report template of the coverage report, and fill the generated code coverage into the corresponding position in the blank coverage report to obtain a coverage report including the code coverage at the current moment.

[0154] In another optional embodiment, when the coverage report is not generated for the first time in the source code test of the application under test at the current moment, the server can calculate and generate the code coverage of the template data type at the current moment through the report template of the coverage report, and use the generated code coverage to update the data at the corresponding position in the coverage report, to obtain a coverage report including the code coverage at the current moment.

[0155] S920. Display the coverage report through a network page.

[0156] The server is configured with a display unit to display the generated coverage report through a web page.

[0157] In an optional embodiment, the server can actively update the code coverage in the coverage report according to the real-time updated code coverage at the current moment, so as to automatically refresh the coverage report. In another optional embodiment, the server is also configured with an input unit for the tester / developer to perform a refresh operation to manually refresh the coverage report and synchronously update the code coverage of the tested application at the current moment in the coverage report.

[0158] In the embodiment of the present application, a coverage report including the code coverage at the current moment is generated, and the coverage report is displayed through a network page. In the above method, the coverage report including the code coverage of the tested application at the current moment is displayed in real time through a network page, which improves the timeliness of the code coverage display, so that the tester / developer can timely understand the test status of the tested application, and can also make test adjustments in time when necessary.

[0159] It should be noted that the code coverage generation method provided in the embodiment of the present application also includes the necessary processes for generating code coverage in the related art, such as code instrumentation, which will not be repeated here.

[0160] In one embodiment, in order to facilitate the understanding of those skilled in the art, the code coverage generation method provided by the present application is described in detail below. Fig.10 As shown, the method may include:

[0161] S1001, obtaining source code indication information and identity information of multiple applications; the source code indication information is used to represent the storage path of the application source code;

[0162] S1002, determining the storage location of the source code of each application according to the storage path of the source code of each application;

[0163] S1003, obtaining the source code of each application from the storage location of the source code of each application;

[0164] S1004, compile the source code of each application program, and generate a compiled data set according to the compiled code of each application program;

[0165] S1005, generating an identity identifier for each application program according to the identity information of each application program;

[0166] S1006, associating the identity of each application with the compiled code of the corresponding application to obtain an association relationship;

[0167] S1007, storing the association relationship in the compiled data set;

[0168] S1008, in response to a data reporting request of the application under test at the current moment, determining an identity identifier of the application under test according to the identity information of the application under test;

[0169] S1009, obtaining the compiled code matching the identity of the application under test in the compiled data set as the compiled code of the application under test;

[0170] S1010, merging and deduplicating the test coverage data and the historical test coverage data to obtain a deduplicated data set;

[0171] S1011, taking the number of data corresponding to each data type in the deduplicated data set as the coverage amount of each data type;

[0172] S1012. Determine the total amount of each data type to be covered according to the compiled code;

[0173] S1013, determining the code coverage rate of each data type according to each covered amount and each total amount to be covered;

[0174] S1014, generating a coverage report including the code coverage at the current moment;

[0175] S1015. Display the coverage report via a web page.

[0176] Among them, S1001-S1007 is the process of building a compilation data set, which can be used as a preparatory step for generating code coverage; S1008-S1013 is the process of generating code coverage, which can be used as a core step for generating code coverage; S1014-S1015 is the process of generating and displaying a coverage report, which can be used as a supplementary step for generating code coverage.

[0177] The code coverage generation method provided in this application is implemented based on the C / S architecture constructed by the terminal (ie, the client) and the server. In order to understand the generation process of the code coverage as a whole, Fig.11 As shown, the process of generating code coverage can be roughly divided into seven steps ①-⑦, the specific contents of the steps are as follows:

[0178] ① The tester / developer enters the basic information of multiple applications into the coverage collection device in the server. The basic information includes the application name and application version of each application, as well as the code address, code branch and branch submission ID.

[0179] ② The coverage collection device obtains the source code of the corresponding application according to the basic information of the multiple application programs entered, and compiles the source code to obtain the compiled code of each application program.

[0180] ③ Testers / developers test the application under test through automated / manual operations, and accordingly generate test coverage data (also referred to as "coverage data") for obtaining code coverage.

[0181] ④ The application under test reports the generated test data to the coverage collection device in real time through the application agent. The test data includes test coverage data, as well as the application name and application version of the application under test.

[0182] ⑤ The coverage collection device merges and removes duplicates from all reported test coverage data, and determines the identity according to the application name and application version of the tested application to obtain the compiled code of the corresponding identity.

[0183] ⑥ The coverage collection device determines the code coverage by combining the compiled code of the corresponding identity with the combined and deduplicated test coverage data, and refreshes the coverage report in real time.

[0184] ⑦ The coverage collection device displays the updated coverage report in real time through a web page for real-time viewing by testers / developers.

[0185] It should be noted that for the descriptions in the above S1001-S1015 and ①-⑦, reference can be made to the relevant descriptions in the above embodiments, and the effects are similar, so this embodiment will not be repeated here.

[0186] For example, Fig.12 The modular schematic diagram of the coverage collection device in the server. The process of generating generation coverage is as follows:

[0187] The application agent 101 sends the reported test data to the gateway 201 in the coverage collection device, which is sent to the message push module 203 through the first transmission module 202. The distributed message push module 203 pushes the real-time test data to the processing module 204, which stores the test data. Usually, the test coverage data of the application under test is stored in the first database 205, and the application name and application version of the application under test are stored in the second database 206. The report 209 obtains the test coverage data from the first database 205 through the template gateway 201 via the second transmission module 207, and obtains the application name and application version of the application under test from the second database 206, so as to obtain the compiled code of the application under test from the storage module 208 storing the compiled code of multiple application programs, and generates code coverage based on the test coverage data and compiled code of the application under test, and generates a coverage report including the code coverage at the current moment, and displays the coverage report through a network page for real-time viewing by testers / developers.

[0188] Exemplarily, the first transmission module 202 and the second transmission module 207 may include an application program interface (API). The message push module 203 may be a distributed publish-subscribe message system kafka. The first database 205 and the second database 206 are relational databases, the first database 205 may be a mysql database, and the second database 206 may be a clickhouseh database. The storage module 208 may be a Hadoop Distributed File System (HDFS).

[0189] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0190] Based on the same inventive concept, the embodiment of the present application also provides a code coverage generation device for implementing the code coverage generation method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more code coverage generation device embodiments provided below can refer to the limitations of the code coverage generation method above, and will not be repeated here.

[0191] In one embodiment, Fig.13 As shown, a code coverage generation device is provided, including: a response module 1301 and a generation module 1302, wherein:

[0192] The response module 1301 is used to respond to the data reporting request of the tested application at the current moment, and obtain the compiled code of the source code of the tested application in the compiled data set; the data reporting request includes the test coverage data generated by the source code test of the tested application at the current moment; the compiled data set includes the compiled code of the source code of multiple different application programs pre-stored;

[0193] The generation module 1302 is used to generate the code coverage of the application under test according to the test coverage data and the compiled code.

[0194] In one embodiment, the data reporting request also includes the identity information of the application under test; the response module 1301 includes:

[0195] The identification submodule is used to determine the identity of the application under test according to the identity information of the application under test;

[0196] The matching submodule is used to obtain the compiled code that matches the identity identifier of the application under test in the compiled data set as the compiled code of the application under test.

[0197] In one embodiment, the identity information of the tested application includes the application name and application version of the tested application; the identification submodule is specifically used for:

[0198] Generate an identity of the application under test based on the application name and application version of the application under test.

[0199] In one embodiment, the generating module 1302 includes:

[0200] The covered submodule is used to obtain the coverage amount of at least one data type that needs to be generated by the application under test at the current moment according to the test coverage data and the historical test coverage data of the application under test;

[0201] The submodule to be covered is used to determine the total amount of each data type to be covered according to the compiled code;

[0202] The coverage submodule is used to determine the code coverage of each data type based on each covered amount and each total amount to be covered.

[0203] In one embodiment, the covered submodules include:

[0204] A processing unit, used for merging and removing duplicates from the test coverage data and the historical test coverage data to obtain a deduplicated data set;

[0205] The statistical unit is used to use the number of data corresponding to each data type in the deduplicated data set as the coverage amount of each data type.

[0206] In one embodiment, the above device further comprises:

[0207] An information module, used to obtain source code indication information of multiple applications; the source code indication information is used to represent the storage path of the application source code;

[0208] The compiling module is used to generate a compilation data set according to source code indication information of a plurality of application programs.

[0209] In one embodiment, the compilation module includes:

[0210] A positioning submodule, used to determine the storage location of the source code of each application program according to the storage path of the source code of each application program;

[0211] An acquisition submodule, used to acquire the source code of each application from the storage location of the source code of each application;

[0212] The compilation submodule is used to compile the source code of each application and generate a compilation data set according to the compiled code of each application.

[0213] In one embodiment, the above device further comprises:

[0214] An acquisition module is used to obtain the identity information of each application;

[0215] An identification module, used to generate an identity identification of each application according to the identity information of each application;

[0216] An association module, used to associate the identity of each application with the compiled code of the corresponding application to obtain an association relationship;

[0217] The storage module is used to store the association relationship in the compiled data set.

[0218] In one embodiment, the above device further comprises:

[0219] A report generation module, used to generate a coverage report including the code coverage at the current moment;

[0220] The report display module is used to display the coverage report through a web page.

[0221] Each module in the above-mentioned code coverage generating device can be implemented in whole or in part by software, hardware and their combination. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0222] In one embodiment, a server is provided, whose internal structure diagram can be as follows: Fig.14As shown. The server includes a processor, a memory, a communication interface, a display unit and an input device connected through a system bus. Among them, the processor of the server is used to provide computing and control capabilities. The memory of the server includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the server is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a code coverage generation method is implemented. The display unit of the server can be a liquid crystal display or an electronic ink display, and the input device of the server can be a touch layer covered on the display, or a button, a trackball or a touchpad set on the server shell, or an external keyboard, touchpad or mouse, etc.

[0223] Those skilled in the art will understand that Fig.14 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0224] In one embodiment, a server is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:

[0225] In response to a data reporting request of the application under test at the current moment, the compiled code of the source code of the application under test is obtained in the compiled data set; the data reporting request includes test coverage data generated by the source code test of the application under test at the current moment; the compiled data set includes the compiled code of the source code of multiple different application programs pre-stored; and the code coverage rate of the application under test is generated based on the test coverage data and the compiled code.

[0226] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0227] The identity of the application under test is determined according to the identity information of the application under test; and the compiled code matching the identity of the application under test is obtained from the compiled data set as the compiled code of the application under test.

[0228] In one embodiment, the identity information of the tested application includes the application name and application version of the tested application; when the processor executes the computer program, the following steps are also implemented:

[0229] Generate an identity of the application under test based on the application name and application version of the application under test.

[0230] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0231] According to the test coverage data and the historical test coverage data of the application under test, obtain the coverage amount of at least one data type that needs to be generated by the application under test at the current moment; according to the compiled code, determine the total amount to be covered of each data type; according to each covered amount and each total amount to be covered, determine the code coverage rate of each data type.

[0232] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0233] The test coverage data and the historical test coverage data are combined and deduplicated to obtain a deduplicated data set; the number of data corresponding to each data type in the deduplicated data set is used as the coverage amount of each data type.

[0234] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0235] The source code indication information of multiple application programs is obtained; the source code indication information is used to represent the storage path of the application program source code; and a compilation data set is generated according to the source code indication information of the multiple application programs.

[0236] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0237] Determine the storage location of the source code of each application according to the storage path of the source code of each application; obtain the source code of each application from the storage location of the source code of each application; compile the source code of each application, and generate a compiled data set according to the compiled code of each application.

[0238] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0239] Obtain the identity information of each application; generate an identity identifier of each application according to the identity information of each application; associate the identity identifier of each application with the compiled code of the corresponding application to obtain an association relationship; and store the association relationship in a compiled data set.

[0240] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0241] Generate a coverage report including the code coverage at the current moment; display the coverage report through a web page.

[0242] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:

[0243] In response to a data reporting request of the application under test at the current moment, the compiled code of the source code of the application under test is obtained in the compiled data set; the data reporting request includes test coverage data generated by the source code test of the application under test at the current moment; the compiled data set includes the compiled code of the source code of multiple different application programs pre-stored; and the code coverage rate of the application under test is generated based on the test coverage data and the compiled code.

[0244] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0245] The identity of the application under test is determined according to the identity information of the application under test; and the compiled code matching the identity of the application under test is obtained from the compiled data set as the compiled code of the application under test.

[0246] In one embodiment, the identity information of the tested application includes the application name and application version of the tested application; when the computer program is executed by the processor, the following steps are also implemented:

[0247] Generate an identity of the application under test based on the application name and application version of the application under test.

[0248] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0249] According to the test coverage data and the historical test coverage data of the application under test, obtain the coverage amount of at least one data type that needs to be generated by the application under test at the current moment; according to the compiled code, determine the total amount to be covered of each data type; according to each covered amount and each total amount to be covered, determine the code coverage rate of each data type.

[0250] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0251] The test coverage data and the historical test coverage data are combined and deduplicated to obtain a deduplicated data set; the number of data corresponding to each data type in the deduplicated data set is used as the coverage amount of each data type.

[0252] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0253] The source code indication information of multiple application programs is obtained; the source code indication information is used to represent the storage path of the application program source code; and a compilation data set is generated according to the source code indication information of the multiple application programs.

[0254] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0255] Determine the storage location of the source code of each application according to the storage path of the source code of each application; obtain the source code of each application from the storage location of the source code of each application; compile the source code of each application, and generate a compiled data set according to the compiled code of each application.

[0256] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0257] Obtain the identity information of each application; generate an identity identifier of each application according to the identity information of each application; associate the identity identifier of each application with the compiled code of the corresponding application to obtain an association relationship; and store the association relationship in a compiled data set.

[0258] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0259] Generate a coverage report including the code coverage at the current moment; display the coverage report through a web page.

[0260] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:

[0261] In response to a data reporting request of the application under test at the current moment, the compiled code of the source code of the application under test is obtained in the compiled data set; the data reporting request includes test coverage data generated by the source code test of the application under test at the current moment; the compiled data set includes the compiled code of the source code of multiple different application programs pre-stored; and the code coverage rate of the application under test is generated according to the test coverage data and the compiled code.

[0262] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0263] The identity of the application under test is determined according to the identity information of the application under test; and the compiled code matching the identity of the application under test is obtained from the compiled data set as the compiled code of the application under test.

[0264] In one embodiment, the identity information of the tested application includes the application name and application version of the tested application; when the computer program is executed by the processor, the following steps are also implemented:

[0265] Generate an identity of the application under test based on the application name and application version of the application under test.

[0266] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0267] According to the test coverage data and the historical test coverage data of the application under test, obtain the coverage amount of at least one data type that needs to be generated by the application under test at the current moment; according to the compiled code, determine the total amount to be covered of each data type; according to each covered amount and each total amount to be covered, determine the code coverage rate of each data type.

[0268] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0269] The test coverage data and the historical test coverage data are combined and deduplicated to obtain a deduplicated data set; the number of data corresponding to each data type in the deduplicated data set is used as the coverage amount of each data type.

[0270] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0271] The source code indication information of multiple application programs is obtained; the source code indication information is used to represent the storage path of the application program source code; and a compilation data set is generated according to the source code indication information of the multiple application programs.

[0272] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0273] Determine the storage location of the source code of each application according to the storage path of the source code of each application; obtain the source code of each application from the storage location of the source code of each application; compile the source code of each application, and generate a compiled data set according to the compiled code of each application.

[0274] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0275] Obtain the identity information of each application; generate an identity identifier of each application according to the identity information of each application; associate the identity identifier of each application with the compiled code of the corresponding application to obtain an association relationship; and store the association relationship in a compiled data set.

[0276] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0277] Generate a coverage report including the code coverage at the current moment; display the coverage report through a web page.

[0278] It should be noted that the information (including but not limited to the identity information of the application) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.

[0279] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0280] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0281] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A code coverage generation method, characterized in that: The method comprises: In response to a data reporting request of the application under test at the current moment, obtaining the compiled code of the source code of the application under test in the compiled data set; the data reporting request includes the test coverage data generated by the source code test of the application under test at the current moment; the compiled data set includes the compiled code of the source code of multiple different application programs pre-stored; The code coverage of the application under test is generated according to the test coverage data and the compiled code.

2. The method according to claim 1, characterized in that The data reporting request also includes the identity information of the application under test; and obtaining the compiled code of the source code of the application under test in the compiled data set includes: Determine the identity of the application under test according to the identity information of the application under test; Obtaining compiled code that matches the identity of the application under test from the compiled data set as the compiled code of the application under test.

3. The method according to claim 2, characterized in that The identity information of the application under test includes the application name and application version of the application under test; and determining the identity identifier of the application under test according to the identity information of the application under test includes: An identity identifier of the application under test is generated according to the application name and application version of the application under test.

4. The method according to any one of claims 1 to 3, characterized in that The step of generating the code coverage of the application under test according to the test coverage data and the compiled code includes: Obtaining, according to the test coverage data and the historical test coverage data of the application under test, a coverage amount of at least one data type that needs to be generated by the application under test at a current moment; Determine the total amount of each data type to be covered according to the compiled code; The code coverage rate of each of the data types is determined according to each of the covered amounts and each of the total amounts to be covered.

5. The method according to claim 4, characterized in that The obtaining, according to the test coverage data and the historical test coverage data of the tested application, a coverage amount of at least one data type required to be generated by the tested application at a current moment, comprises: Merging and removing duplicates from the test coverage data and the historical test coverage data to obtain a deduplicated data set; The number of data corresponding to each of the data types in the deduplicated data set is used as the coverage amount of each of the data types.

6. The method according to any one of claims 1 to 3, characterized in that The process of constructing the compiled dataset includes: Acquire source code indication information of multiple applications; the source code indication information is used to represent the storage path of the application source code; The compiled data set is generated according to the source code indication information of the plurality of application programs.

7. The method according to claim 6, characterized in that The step of generating the compiled data set according to the source code indication information of the plurality of application programs comprises: Determining a storage location of the source code of each application program according to a storage path of the source code of each application program; Acquire the source code of each of the application programs from the storage location of the source code of each of the application programs; The source code of each of the application programs is compiled, and the compiled data set is generated according to the compiled code of each of the application programs.

8. The method according to claim 7, characterized in that The method further comprises: Obtaining identity information of each of the applications; Generating an identity tag of each application according to the identity information of each application; Associating the identity of each application with the compiled code of the corresponding application to obtain an association relationship; The association relationship is stored in the compiled data set.

9. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: Generate a coverage report including the code coverage at the current moment; The coverage report is displayed via a web page.

10. A code coverage generating device, characterized in that: The device comprises: A response module, configured to respond to a data reporting request of the application under test at the current moment, and obtain the compiled code of the source code of the application under test in the compiled data set; the data reporting request includes the test coverage data generated by the source code test of the application under test at the current moment; the compiled data set includes the compiled code of the source code of multiple different application programs pre-stored; A generation module is used to generate the code coverage of the application under test according to the test coverage data and the compiled code.

11. A server, comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 9 are implemented.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.

13. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.