Test coverage rate calculation method and device, equipment, medium and program product

Through a test coverage calculation method, the test coverage is calculated using mapping relationships and historical business data screening interfaces, which solves the problems of redundant code and high maintenance costs in financial institutions' systems, and improves interface coverage and testing efficiency.

CN119621584APending Publication Date: 2025-03-14INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411848597.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-16
Publication Date
2025-03-14

AI Technical Summary

Technical Problem

In software program testing, with the rapid development of business, the system architecture of banks and other financial institutions continues to expand, resulting in huge test assets and high maintenance and error analysis costs. At the same time, there is a large amount of redundant code, which reduces the coverage of interface methods and increases the workload of testers.

Method used

Provide a test coverage calculation method. By obtaining the mapping relationship between applications, interfaces and program methods when running test case scripts, as well as these mapping relationships used in historical business execution, the interface data that meets the target conditions is filtered based on preset rules and calculate the test coverage.

Benefits of technology

By filtering interface methods or branches without call volume on production, the coverage of effective interface program methods can be improved, and the cost of manually covering inefficient interface methods and branches can be reduced, so as to help testers concentrate their time and energy on effective coverage testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119621584A_ABST
    Figure CN119621584A_ABST
Patent Text Reader

Abstract

The invention provides a test coverage rate calculation method which can be applied to the technical field of big data. The test coverage rate calculation method comprises the steps that first data is obtained, and the first data at least represents the mapping relation among called applications, interfaces and program methods when a test case script is operated; obtaining second data, wherein the second data at least represents a mapping relation among an application, an interface and a program method used in execution of the historical business; screening the second data based on a preset rule to obtain third data, the third data representing the second data of which the interface meets a target condition; and calculating the test coverage rate based on the third data, the mapping relation and the first data. The invention further provides a test coverage rate calculation device and equipment, a storage medium and a program product.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of big data technology, specifically to the field of software program testing in big data technology, and more specifically to a test coverage calculation method, device, equipment, medium and program product. Background Art

[0002] With the changes in the market and the rapid development of business, banks and other financial institutions usually develop services in new areas based on the existing system architecture. Although this development method can quickly adapt to the expansion of business, it also leads to the continuous addition of new interfaces, methods and branches to the original architecture. As a result, the test assets are becoming increasingly large, resulting in higher maintenance costs and error analysis costs. In a fast-paced project environment, the iteration speed of the program is accelerated. Testers not only need to test new functions and programs, but also need to perform regression tests on existing functions and programs. At present, it is a common practice to ensure the test coverage of the interface by counting the coverage of the interface program method.

[0003] However, there may be a large amount of redundant code in the system, which may come from abandoned business logic or new business line systems modified from old business line systems. Due to limited human resources, it is often difficult to clean up these redundant codes, which brings troubles to the testing and monitoring of interface coverage. When there are many redundant methods or branches in the application interface, it is easy to reduce the interface method coverage. It takes a lot of time to analyze the reasons for non-coverage, which is time-consuming and labor-intensive. In addition, testers need to spend more time to write automated test cases to cover the uncovered interface methods and branches. Summary of the invention

[0004] In view of the above problems, the present disclosure provides a test coverage calculation method, apparatus, device, medium and program product.

[0005] According to a first aspect of the present disclosure, a test coverage calculation method is provided, including: obtaining first data, the first data at least representing a mapping relationship between applications, interfaces, and program methods called when running a test case script; obtaining second data, the second data at least representing a mapping relationship between applications, interfaces, and program methods used in the execution of historical businesses; filtering the second data based on preset rules to obtain third data, the third data representing second data that an interface meets a target condition; and calculating the test coverage based on the third data, the mapping relationship, and the first data.

[0006] According to an embodiment of the present disclosure, the second data is generated based on the execution process of the historical service, and the generation process of the second data includes: responding to the occurrence of the service, monitoring the execution process of the service, and generating the second data corresponding to the service.

[0007] According to an embodiment of the present disclosure, the process of generating the second data further includes: generating interface index data corresponding to the interface based on the interface information in the second data.

[0008] According to an embodiment of the present disclosure, the second data is screened based on preset rules to obtain third data, including: based on preset indicators, matching the interface index data corresponding to the interface to obtain target index information; based on the target index information, obtaining the second data corresponding to the target index information to form the third data.

[0009] According to an embodiment of the present disclosure, the target index information includes at least the number of times the interface in the second data is called during the execution of the service.

[0010] According to an embodiment of the present disclosure, based on the third data, the mapping relationship and the first data, the target interface test coverage is counted, including: filtering the first data based on the third data to obtain fourth data, the fourth data representing the first data that meets the target condition; and calculating the test coverage based on the interface corresponding to the fourth data and the interface corresponding to the first data.

[0011] According to an embodiment of the present disclosure, obtaining the fourth data includes: matching the first data with the third data to obtain the fifth data, the fifth data representing the data in the first data that matches the interface represented by the third data; matching the fifth data with each program method corresponding to the interface in the fifth data to obtain a target program method collection; matching the target program method collection with the first data to obtain the sixth data, the sixth data representing the first data corresponding to the interface in the first data that matches the target program method; matching the sixth data with the target program method collection to obtain the fourth data.

[0012] According to an embodiment of the present disclosure, the test coverage is calculated based on the interface corresponding to the fourth data and the interface corresponding to the first data, including: calculating a first quantity based on the fourth data, the first quantity representing the number of non-repeated interfaces in the fourth data; calculating a second quantity based on the first data, the second quantity representing the number of non-repeated interfaces in the first data; calculating the test coverage based on the first data quantity and the second quantity.

[0013] According to an embodiment of the present disclosure, the target condition represents that the number of calls of the interface within a preset time range is greater than or equal to a preset number threshold, and the preset indicator is the number of calls of the interface.

[0014] A second aspect of the present disclosure provides a test coverage calculation device, which includes: a first acquisition module, used to acquire first data, the first data at least representing the mapping relationship between the applications, interfaces and program methods called when running the test case script; a second acquisition module, used to acquire second data, the second data at least representing the mapping relationship between the applications, interfaces and program methods used in the execution of historical businesses; a screening module, used to screen the second data based on preset rules to obtain third data, the third data representing the second data of the interface meeting the target condition; and a calculation module, used to calculate the test coverage based on the third data, the mapping relationship and the first data.

[0015] A third aspect of the present disclosure provides an electronic device, comprising: one or more processors; and a memory for storing one or more computer programs, wherein the one or more processors execute the one or more computer programs to implement the steps of the test coverage calculation method.

[0016] The fourth aspect of the present disclosure further provides a computer-readable storage medium having a computer program or instructions stored thereon, which implements the steps of the test coverage calculation method when the computer program or instructions are executed by a processor.

[0017] The fifth aspect of the present disclosure also provides a computer program product, including a computer program or instructions, which implement the steps of the test coverage calculation method when the computer program or instructions are executed by a processor.

[0018] According to the embodiments of the present disclosure, the technical solution provided by the present disclosure has at least one of the following beneficial effects: by filtering out interface methods or branches that have no calls in production, an effective test case set and an effective program method set are formed, thereby improving the coverage rate of effective interface program methods, while also reducing the cost of manually covering inefficient interface methods and branches, allowing testers to focus their time and energy on coverage testing of effective program methods and branches, timely discovering effective and uncovered program methods and scenario branches and completing coverage of missing branches before the program goes into production. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The above contents and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:

[0020] Figure 1 A scenario diagram schematically shows an application of the test coverage calculation method according to an embodiment of the present disclosure;

[0021] Figure 2 A flowchart of a test coverage calculation method according to an embodiment of the present disclosure is schematically shown;

[0022] Figure 3 A flowchart of generating second data according to an embodiment of the present disclosure is schematically shown;

[0023] Figure 4 Another flowchart schematically shows a process of generating second data according to an embodiment of the present disclosure;

[0024] Figure 5 Schematically shows a flow chart of screening second data according to an embodiment of the present disclosure;

[0025] Figure 6 A flowchart of calculating target interface test coverage in a test coverage calculation method according to an embodiment of the present disclosure is schematically shown;

[0026] Figure 7 A flowchart of calculating test coverage in a test coverage calculation method according to an embodiment of the present disclosure is schematically shown;

[0027] Figure 8 A flowchart of calculating coverage based on first data and fourth data in a test coverage calculation method according to an embodiment of the present disclosure is schematically shown;

[0028] Fig. 9 A structural block diagram of a test coverage calculation device according to an embodiment of the present disclosure is schematically shown; and

[0029] Fig.10 A block diagram of an electronic device suitable for implementing a test coverage calculation method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION

[0030] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.

[0031] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.

[0032] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.

[0033] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).

[0034] An embodiment of the present disclosure provides a test coverage calculation method, which obtains first data, the first data at least representing the mapping relationship between the applications, interfaces and program methods called when running the test case script; obtains second data, the second data at least representing the mapping relationship between the applications, interfaces and program methods used in the execution of historical businesses; filters the second data based on preset rules to obtain third data, the third data representing the second data that the interface meets the target condition; and calculates the test coverage based on the third data, the mapping relationship and the first data.

[0035] Figure 1 A scenario diagram schematically illustrates the application of the test coverage calculation method according to an embodiment of the present disclosure.

[0036] like Figure 1 As shown, the application scenario 100 according to this embodiment may include a data source 110, a case composition device 120, a case operation device 130, a business monitoring device 140, a coverage statistics device 150, and a network 160. The network 160 is used to provide a communication link between the data source 110, the case composition device 120, the case operation device 130, the business monitoring device 140, and the coverage statistics device 150. The network 160 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0037] The data source 110 is used to receive and store at least part of the data used in this scenario. For example, the data source 110 may include an interface call data source and a test case data source. Among them, the interface call chain data source can receive and store an interface call chain, and the interface call chain can include a mapping relationship between a test case name, an interface name, a program name, an application name, and any multiple of the test case name, interface name, program name, and application name. The test case data source includes a data set of input parameters related to the automated test case.

[0038] The test case composition device 120 is used to automatically compose a test case script according to the case data source. For example, according to the configured script call type, after calling the corresponding script template from the code library of the case execution platform, the call parameters are configured through the input parameter information and message information maintained in the test case data source in the data source device to generate the corresponding test case.

[0039] The test case composition device 120 may include a case generation device and a case composition device. The case generation device selects a corresponding script template through the input parameters provided by the test case data source in the data source device, and configures its parameters, including message type, request type, request header, access address, dependent script, etc., to form a test class script. The case composition device obtains the test class script generated by the case generation module and the test case data source in the data source device, provides the corresponding case data to the corresponding test class, and further combines them into an executable script.

[0040] The case running device 130 may include a case execution device and a data download device. The case execution device is composed of a common call code library and configuration information. The common call code library is used to support common methods such as group reporting, sending, and return message parsing of various call type scripts. In the test case configuration information, there will also be a corresponding execution environment. You can choose whether to use regression test mode or non-regression test mode in the version environment version. The main purpose of distinguishing regression test and non-regression test mode is to avoid the intersection of the two. In order to distinguish each test mode, when selecting the regression test mode, a regression test flag can be added to the data and transmitted to the coverage statistics device. When selecting the non-regression test mode, a non-regression test flag will be added to the data. The data download device is used to transmit the case log data to the monitoring platform after the case is run. The monitoring platform monitors the interface call chain of the case, and transmits the interface call chain, the call interface, the program method name and other data and the association relationship between the data to the data source device for storage.

[0041] The business monitoring device 140 is used to monitor the traffic of the target application and analyze and process the traffic. For example, by obtaining the production traffic, the calling status of the specific interface program method can be understood and stored as relevant historical data for subsequent analysis and screening.

[0042] The coverage statistics device 150 is used to calculate the coverage of the test case based on the data in the data source device 110, the data transmitted from the case running device 130, and the data transmitted from the business monitoring device 140, so as to help developers and testers to promptly discover uncovered interface program methods and scenario branches and complete the coverage of missed branches before the program goes into production, thereby reducing production problems caused by lack of program branch coverage.

[0043] The following will be based on Figure 1 The scene described by Figure 2~Figure 6 The test coverage calculation method of the disclosed embodiment is described in detail.

[0044] Figure 2 The flowchart of the test coverage calculation method according to the embodiment of the present disclosure is schematically shown.

[0045] like Figure 2 As shown, the test coverage calculation method of this embodiment includes operations S210 to S240, and the test coverage calculation method can be executed in a coverage statistics device.

[0046] In operation S210, first data is obtained, and the first data at least represents the mapping relationship between the called application, interface and program method when running the test case script. For example, the first data can be an interface call chain, and the data format of the interface call chain can be [interface call chain L, (case name, call application A->call interface I->call program method M)]. For example, in the July 2024 version, that is, the version number version is 2407, a new test case A is added. By running the script in the case running device, the transaction log ID number of the test case A is obtained as traceid1. According to traceid1, the interface call chain L1 is obtained. The call chain of case A crosses the program method M1 under the interface I1 of the cross-border clearing application APP1, the program method M2 under the interface I2 of the public settlement product service application APP2, and the program method M3 under the interface I3 of the clearing business management application APP3. Then the corresponding interface call chain data can be: [L1, (A, APP1->I1->M1, APP2->I2->M2, APP3->I3->M3)].

[0047] In operation S220, the second data is obtained, and the second data at least represents the mapping relationship between the application, interface and program method used in the execution of the historical business. The second data can be obtained by collecting the production traffic of the target application and replaying the production traffic to obtain the interface, program method and other data of the target application. The format can be [application name A, interface I, program method M]. For example, during the execution of business 1, program method M1 under interface I1 of cross-border clearing application APP1 is called, then its second data can be saved as: [APP1, I->I1, M->M1].

[0048] In operation S230, the second data is screened based on a preset rule to obtain third data, where the third data represents the second data that meets the target condition. Specifically, the third data is at least part of the second data, and this part of the data meets a certain preset target condition.

[0049] According to an embodiment of the present disclosure, the target condition can characterize that the number of calls of the interface within a preset time range is greater than or equal to a preset number threshold, and the preset indicator is the number of calls of the interface. For example, the target condition is that the number of calls of the interface within a year is greater than or equal to 10 times. For example, in the second data, there are 100 pieces of data related to APP1, and the storage format is the aforementioned [application name A, interface I, program method M], and among them, only the number of times interface I1 appears is greater than or equal to 10 times and is 22 times, then, these 11 pieces of second data are filtered out as the third data.

[0050] Preferably, a first screening identifier can be added to the second data during the screening process. For example, in the data saved in the aforementioned format of [application name A, interface I, program method M], a flag is added and changed to [application name A, interface I, program method M, first screening identifier Y / N], wherein the data that meets the target condition has a first screening identifier Y, and the data that does not meet the target condition has a first screening identifier N. Based on the aforementioned example, the second data corresponding to the 22 I1 interfaces will have a first screening identifier Y added during the screening process. For example, the data may be [APP1, I->I1, M->M1, Y]. Among the 100 second data related to the interface APP1, except for the 22 data related to I1, the remaining data will all be added with the first screening identifier N, for example, [APP1, I->I2, M->M3, N]. In this way, the second data with the first screening identifier Y is the third data, which is equivalent to filtering out the third data from the second data.

[0051] In other embodiments, other target conditions may also be selected. For example, interfaces may be screened based on their importance, so that testers can focus on the test coverage of interfaces with higher importance. Interface change frequency may be used as the target condition. The more interfaces are changed, the greater the probability of problems and defects that may occur. Testers may pay more attention to the test coverage of these higher-risk interfaces. Interfaces may be screened based on test cost and difficulty as target conditions, so that testers may pay more attention to the test coverage of interfaces with complex logic.

[0052] In operation S240, the test coverage is calculated based on the third data, the mapping relationship and the first data. Since the third data that meets the target condition is screened out, based on the interfaces and program methods recorded in the third data and the mapping relationship in the first data, the proportion of the corresponding interfaces and methods in the first data can be known. The first data is the data after the test case is executed, and the test coverage of the interface that meets the target condition can be calculated.

[0053] Figure 3The flowchart of generating the second data according to the embodiment of the present disclosure is schematically shown.

[0054] like Figure 3 As shown, the second data is generated based on the execution process of the historical business. The generation process of the second data in the embodiment of the present disclosure may include: operation S310.

[0055] In operation S310, in response to the occurrence of the service, the execution process of the service is monitored to generate second data corresponding to the service. For example, based on the real-time monitoring platform monitoring the target application, during the execution of the service, the real-time monitoring platform will monitor the status of each target application in real time, for example, monitoring the calling status of the interface in each target application, the calling status of the program method, and other information, and generate corresponding second data based on this information.

[0056] In other embodiments, the second data can be generated by collecting the flow data of each historical business and replaying the flow data according to the flow data of the historical business. For example, by collecting the production flow of the target application and replaying the production flow, the actual use of the interface and program method of the target application can be efficiently obtained. First, the flow data in the production environment is captured in real time by integrating the buried point technology or the flow collection tool in the target application, and the collected data is stored. Then the production flow is resent through the flow replay tool. The specific process includes: parsing the stored flow data, restoring the original call link according to the time series and dependency, and sending the captured requests one by one to the test environment of the target application. During the playback process, the system will record the detailed information of the interface call, including the request path, interface name, program method name, number of calls and parameter type, etc. For example, in the playback of a certain application, it is found that the interface I1 calls the program method M1 150 times, the interface I2 of another application calls the program method M2 80 times, and some program methods do not have any call records in the playback. In this way, the corresponding second data is generated.

[0057] Figure 4 Another flowchart schematically illustrates a process of generating second data according to an embodiment of the present disclosure.

[0058] like Figure 4 As shown, the process of generating the second data may further include operation S410.

[0059] In operation S410, the generation process of the second data also includes: based on the interface information in the second data, generating interface index data corresponding to the interface. The business volume produced is very large, and the daily business volume can reach thousands or even hundreds of millions. If the data is matched one by one in sequence for calculation, the efficiency is very low. Therefore, in the generation process of the second data, the interfaces of the full amount of the target application group and their corresponding program methods can be used as basic indicators to synchronously generate interface index data corresponding to the second data. Every time a business data occurs, the interface index data of this business is stored in the first storage location, and the corresponding business traffic data is stored in the second storage location, and the interface index data serves as the secondary index information of the business traffic data.

[0060] According to an embodiment of the present disclosure, the interface index data is stored in a first storage location, and the first storage location may be a distributed search engine to support fast searching of the service traffic data based on the interface index data.

[0061] Figure 5 The flowchart of screening the second data according to the embodiment of the present disclosure is schematically shown.

[0062] like Figure 5 As shown, operation S230 may include operations S510 to S520.

[0063] In operation S510, based on a preset index, matching is performed with interface index data corresponding to the interface to obtain target index information.

[0064] In operation S520, based on the target index information, second data corresponding to the target index information is acquired to form third data.

[0065] On the basis of the foregoing embodiments, during the generation of the second data, index information corresponding to the second data will also be generated. Based on the preset indicators, the index information is matched to obtain target index information that meets the preset requirements. The preset indicator is at least one of the basic indicators mentioned in the foregoing embodiments, such as the number of interface calls, the time when the interface is called, etc. It should be noted that the preset indicators are associated with the interface index data, but they are not the same data. The preset indicators are predefined goals or standards, and the interface index data is actual data generated based on the actual data at runtime.

[0066] According to an embodiment of the present disclosure, the target index information at least includes the number of times the interface in the second data is called during the execution of the business. Specifically, the target index information is generated by matching the interface index data with preset indicators, and the preset indicators include but are not limited to the number of times the interface is called within a specific time range, the business classification information corresponding to the interface, and the call chain position of the interface in the system. By matching the preset indicators, interfaces that meet the target conditions and their associated program methods can be quickly screened out to form target index information. When the number of times an interface is called during the execution of a business reaches or exceeds the preset number threshold, the interface is considered to have business validity and meet the target conditions. The preset number threshold can be flexibly set according to specific business needs. For example, for the core interface of high-frequency transactions, the threshold can be set to a higher value to reflect its importance; for low-frequency transactions or seasonal businesses, the threshold can be appropriately lowered to ensure that key interfaces are not missed during the screening process.

[0067] According to an embodiment of the present disclosure, the target condition characterizes that the number of calls of the interface within a preset time range is greater than or equal to a preset number threshold, and the preset indicator is the number of calls of the interface. Specifically, the preset time range can be dynamically adjusted according to the business type and system characteristics. For example, the core clearing business in the banking system is usually counted in units of months or quarters, while the real-time transaction interface in the payment system may be monitored in units of days or hours. By counting the number of interface calls within the preset time range and comparing it with the preset number threshold, the interface method that truly has actual call value in the business can be effectively identified. In actual applications, the setting of the preset time range and the number of calls threshold can also be optimized in combination with the trend of historical business data. For example, by analyzing the call status of the interface in the past year, a dynamic threshold can be set, so as to screen out interface methods with efficient coverage significance in different time periods. For some special business scenarios (such as long-term business or low-frequency business), the preset time range can be flexibly extended, for example, the statistical time range can be extended to two years, so as to more comprehensively evaluate the call status of the business.

[0068] Through the above screening mechanism, the target index information can accurately identify the interfaces that meet the target conditions and their corresponding program methods, laying a data foundation for the subsequent formation of third data and calculation of test coverage. This method not only improves the screening efficiency, but also effectively avoids the interference of redundant interfaces on coverage statistics.

[0069] Figure 6 The flowchart of counting target interface test coverage in the test coverage calculation method according to an embodiment of the present disclosure is schematically shown.

[0070] like Figure 6 As shown, operation S240 may include operations S610 to S620.

[0071] In operation S610, the first data is screened based on the third data to obtain fourth data, and the fourth data represents the first data that meets the target condition. For example, the third data can represent the effective applications, interfaces and program methods in the historical business execution process, and the first data can represent the applications, interfaces and program methods called during the execution of the test case script. By matching the first data with the third data, the part of the first data that does not match the third data can be eliminated, so as to obtain the fourth data that only includes the interfaces that meet the target condition and their corresponding program methods. This process can effectively filter out interfaces and program methods that do not meet the target condition, reduce redundant data in the subsequent test coverage calculation, and improve calculation efficiency.

[0072] In operation S620, the test coverage is calculated based on the interface corresponding to the fourth data and the interface corresponding to the first data. By counting the number of interfaces in the fourth data and combining it with the number of interfaces in the first data, the percentage of test coverage can be determined. The number of interfaces in the fourth data represents the number of interfaces that meet the target conditions and have been tested, while the number of interfaces in the first data represents the number of all interfaces involved in the test case operation. By comparing the relationship between the two, the coverage of effective interfaces can be accurately reflected, providing developers and testers with an integrity assessment of interface testing, helping them to promptly discover uncovered effective interfaces and program methods, and optimize test resource allocation.

[0073] Figure 7 The flowchart of calculating the test coverage in the test coverage calculation method according to an embodiment of the present disclosure is schematically shown.

[0074] like Figure 7 As shown, operation S620 may include operations S710 to S740.

[0075] In operation S710, the first data is matched with the third data to obtain fifth data, and the fifth data represents data in the first data that matches the interface represented by the third data. By comparing the first data with the third data, the part of the first data that is consistent with the valid interface represented by the third data can be screened out to form the fifth data, thereby excluding unnecessary invalid interfaces at the data level and improving matching efficiency.

[0076] For example, the third data can be interface matched with the first data, and a second filter identifier can be added to the first data according to the matching result. Specifically, for example, the third data in the format of [application name A, interface I, program method M, first filter identifier Y] can be interface matched with the first data in the format of [interface call chain L, (case name, call application A->call interface I->call program method M)]. If they match, the second filter identifier Y is added to the matched first data. If they do not match, the second filter identifier N is added. Then the first data in the format of [interface call chain L, (case name, call application A->, call interface I->, call program method M->, second filter identifier Y)] is the fifth data.

[0077] In operation S720, the target program method collection is obtained based on matching the fifth data with each program method corresponding to the interface in the fifth data. Each interface usually corresponds to multiple program methods. By analyzing the program methods involved in the interface in the fifth data, the program method set related to these interfaces can be further determined, thereby extracting the target program method collection. The target program method collection is a streamlined method set, and each method in the collection is a method corresponding to a valid interface. For example, when the target condition in the aforementioned embodiment is that the number of calls within one year is greater than 0, then all methods in the collection will meet this target condition. The target program method collection can accurately characterize the key program methods associated with the valid interface and reduce the complexity of subsequent data processing.

[0078] In operation S730, the target program method collection is matched with the first data to obtain sixth data, and the sixth data represents the first data corresponding to the interface matching the target program method in the first data. By matching the target program method collection with the program methods recorded in the first data one by one, the part of the first data that meets the target program method collection can be further refined and screened out to form the sixth data. The sixth data not only includes the program methods that meet the conditions, but also retains the interface information corresponding to these program methods, that is, this step is to screen out all interfaces corresponding to all valid methods.

[0079] Specifically, the first data may be matched with the target program method set in a loop. If they match, the first data is marked with a first matching mark T. If they do not match, the program method in the next first data is matched until all the data are matched. Then, all the first data with the first matching mark T are the sixth data.

[0080] In operation S740, the sixth data is matched with the target program method collection to obtain the fourth data. The final fourth data can be formed by further screening the sixth data for the part that matches the interface in the target program method collection. This step is to screen out the valid interfaces among all interfaces corresponding to all valid methods. So far, the fourth data is the data that has executed the test case and the interface and program method are covered.

[0081] Specifically, the sixth data can be matched with the target program method in a loop. If they match, the sixth data will be marked with the second matching mark TT. If they do not match, the next sixth data will be matched until all the data are matched. Then all the first data with the second matching mark TT are the fourth data.

[0082] According to the aforementioned embodiment, by filtering out interface methods or branches that have no calls in production, an effective test case set and an effective program method set are formed, thereby improving the coverage rate of effective interface program methods, while also reducing the cost of manually covering inefficient interface methods and branches, allowing testers to focus their time and energy on coverage testing of effective program methods and branches, timely discovering effective and uncovered program methods and scenario branches, and completing coverage of missing branches before the program goes into production.

[0083] Figure 8 The flowchart of calculating coverage based on first data and fourth data in the test coverage calculation method according to an embodiment of the present disclosure is schematically shown.

[0084] like Figure 8 As shown, operation S620 may include operations S810 to S830.

[0085] In operation S810, based on the fourth data, a first quantity is calculated, and the first quantity represents the number of non-repeated interfaces in the fourth data. The fourth data is a collection of valid interfaces and program methods obtained by screening through the preceding operation, representing interfaces and related data that meet the target conditions and have been tested. By deduplicating the interface information in the fourth data, the number of independent and non-repeated interfaces in the fourth data can be counted to form a first quantity. The first quantity reflects the number of valid interfaces that have been covered during the test.

[0086] In operation S820, based on the first data, a second quantity is calculated, where the second quantity represents the number of non-repeated interfaces in the first data. The first data represents a set of all interfaces and program methods actually called during the execution of the test case script, which may include interfaces that are repeatedly called. By deduplicating the interface information in the first data, the number of all independent interfaces actually called can be counted to form the second quantity.

[0087] In operation S830, the test coverage is calculated according to the first data amount and the second amount. For example, the test coverage is calculated by dividing the first amount by the second amount and multiplying by 100%. Based on the above embodiment, the coverage can be calculated by counting the proportion of the first data with the second matching mark TT.

[0088] According to the embodiment of the present disclosure, after calculating the coverage rate, a time point can also be set in the configuration of the coverage rate statistics device. If this time point is exceeded, the device will automatically send an email to notify the developers and testers corresponding to the uncovered program methods, so as to facilitate the developers and testers to understand the coverage of the interface in a timely manner.

[0089] Based on the above test coverage calculation method, the present disclosure also provides a test coverage calculation device. Fig. 9 The device is described in detail.

[0090] Fig. 9 The structure block diagram of the test coverage calculation device according to the embodiment of the present disclosure is schematically shown.

[0091] like Fig. 9 As shown, the test coverage calculation device 900 of this embodiment includes a first acquisition module 910 , a second acquisition module 920 , a screening module 930 and a calculation module 940 .

[0092] The first acquisition module 910 is used to acquire first data, and the first data at least represents the mapping relationship between the applications, interfaces and program methods called when running the test case script; in one embodiment, the first acquisition module 910 can be used to execute the operation S210 described above, which will not be repeated here.

[0093] The second acquisition module 920 is used to acquire second data, and the second data at least represents the mapping relationship between applications, interfaces and program methods used in the execution of historical business; in one embodiment, the second acquisition module 920 can be used to execute the operation S220 described above, which will not be repeated here.

[0094] The screening module 930 is used to screen the second data based on preset rules to obtain third data, where the third data represents the second data whose interface meets the target condition; in one embodiment, the screening module 930 can be used to perform the operation S230 described above, which will not be repeated here.

[0095] The calculation module 940 is used to calculate the test coverage based on the third data, the mapping relationship and the first data. In one embodiment, the calculation module 940 can be used to perform the operation S240 described above, which will not be described in detail here.

[0096] According to an embodiment of the present disclosure, the second data is generated based on the execution process of the historical business, and the test coverage calculation device 900 may include a first generation module.

[0097] The first generating module is used to monitor the execution process of the service in response to the occurrence of the service and generate the second data corresponding to the service. In one embodiment, the first generating module can be used to perform the operation S310 described above, which will not be described in detail here.

[0098] The test coverage calculation apparatus 900 may include a second generating module.

[0099] The second generating module is used to generate interface index data corresponding to the interface based on the interface information in the second data. In one embodiment, the second generating module can be used to perform the operation S410 described above, which will not be described in detail here.

[0100] According to an embodiment of the present disclosure, the second acquisition module 920 may include a first matching module and a third acquisition module.

[0101] The first matching module is used to match the interface index data corresponding to the interface based on a preset index to obtain target index information. In one embodiment, the first matching module can be used to perform the operation S510 described above, which will not be described in detail here.

[0102] The third acquisition module is used to acquire the second data corresponding to the target index information based on the target index information to form the third data. In one embodiment, the third acquisition module can be used to perform the operation S520 described above, which will not be described in detail here.

[0103] According to an embodiment of the present disclosure, the calculation module 940 may include a fourth obtaining module and a first calculation module.

[0104] The fourth obtaining module is used to filter the first data based on the third data to obtain fourth data, where the fourth data represents the first data that meets the target condition. In one embodiment, the fourth obtaining module can be used to perform the operation S610 described above, which will not be repeated here.

[0105] The first calculation module is used to calculate the test coverage based on the interface corresponding to the fourth data and the interface corresponding to the first data. In one embodiment, the first calculation module can be used to perform the operation S620 described above, which will not be repeated here.

[0106] According to an embodiment of the present disclosure, the fourth obtaining module may include a second matching module, a third matching module, a fourth matching module and a fifth matching module.

[0107] The second matching module is used to match the first data with the third data to obtain fifth data, where the fifth data represents data in the first data that matches the interface represented by the third data. In one embodiment, the second matching module can be used to execute the operation S710 described above, which will not be repeated here.

[0108] The third matching module is used to match the fifth data with each program method corresponding to the interface in the fifth data to obtain a target program method collection; in one embodiment, the third matching module can be used to execute the operation S720 described above, which will not be repeated here.

[0109] The fourth matching module is used to match the target program method collection with the first data to obtain sixth data, and the sixth data represents the first data corresponding to the interface in the first data that matches the target program method; in one embodiment, the fourth matching module can be used to execute the operation S730 described above, which will not be repeated here.

[0110] The fifth matching module is used to match the sixth data with the target program method set to obtain the fourth data. In one embodiment, the fifth matching module can be used to perform the operation S740 described above, which will not be described in detail here.

[0111] According to an embodiment of the present disclosure, the first computing module may include a first computing submodule, a second computing submodule and a third computing submodule.

[0112] The first calculation submodule is used to calculate a first quantity based on the fourth data, where the first quantity represents the number of non-repeated interfaces in the fourth data. In one embodiment, the first calculation submodule can be used to execute the operation S810 described above, which will not be repeated here.

[0113] The second calculation submodule is used to calculate a second quantity based on the first data, where the second quantity represents the number of non-repeated interfaces in the first data. In one embodiment, the second calculation submodule can be used to perform the operation S820 described above, which will not be repeated here.

[0114] The third calculation submodule is used to calculate the test coverage rate according to the first data volume and the second quantity. In one embodiment, the third calculation submodule can be used to perform the operation S830 described above, which will not be described in detail here.

[0115] According to an embodiment of the present disclosure, any multiple modules of the first acquisition module 910, the second acquisition module 920, the screening module 930 and the calculation module 940 can be combined into one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the first acquisition module 910, the second acquisition module 920, the screening module 930 and the calculation module 940 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware and firmware or in a suitable combination of any of them. Alternatively, at least one of the first acquisition module 910 , the second acquisition module 920 , the screening module 930 , and the calculation module 940 may be at least partially implemented as a computer program module, and when the computer program module is executed, a corresponding function may be executed.

[0116] Fig.10 A block diagram of an electronic device suitable for implementing a test coverage calculation method according to an embodiment of the present disclosure is schematically shown.

[0117] like Fig.10 As shown, the electronic device 1000 according to an embodiment of the present disclosure includes a processor 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage part 1008 to a random access memory (RAM) 1003. The processor 1001 may include, for example, a general-purpose microprocessor (such as a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (for example, an application-specific integrated circuit (ASIC)), etc. The processor 1001 may also include an onboard memory for caching purposes. The processor 1001 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.

[0118] In RAM 1003, various programs and data required for the operation of electronic device 1000 are stored. Processor 1001, ROM 1002 and RAM 1003 are connected to each other via bus 1004. Processor 1001 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 1002 and / or RAM 1003. It should be noted that the program can also be stored in one or more memories other than ROM 1002 and RAM 1003. Processor 1001 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.

[0119] According to an embodiment of the present disclosure, the electronic device 1000 may further include an input / output (I / O) interface 1005, which is also connected to the bus 1004. The electronic device 1000 may further include one or more of the following components connected to the input / output (I / O) interface 1005: an input portion 1006 including a keyboard, a mouse, etc.; an output portion 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 1008 including a hard disk, etc.; and a communication portion 1009 including a network interface card such as a LAN card, a modem, etc. The communication portion 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the input / output (I / O) interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed, so that a computer program read therefrom is installed into the storage portion 1008 as needed.

[0120] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.

[0121] According to an embodiment of the present disclosure, a computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device. For example, according to an embodiment of the present disclosure, a computer-readable storage medium may include the ROM 1002 and / or RAM 1003 described above and / or one or more memories other than ROM 1002 and RAM 1003.

[0122] The embodiment of the present disclosure also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the test coverage calculation method provided by the embodiment of the present disclosure.

[0123] The above functions defined in the system / device of the embodiment of the present disclosure are performed when the computer program is executed by the processor 1001. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.

[0124] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 1009, and / or installed from the removable medium 1011. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0125] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1009, and / or installed from the removable medium 1011. When the computer program is executed by the processor 1001, the above functions defined in the system of the embodiment of the present disclosure are performed. According to the embodiment of the present disclosure, the system, device, means, module, unit, etc. described above can be implemented by a computer program module.

[0126] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages ​​include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect through the Internet).

[0127] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0128] It will be appreciated by those skilled in the art that the features described in the various embodiments of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations or combinations are not explicitly described in the present disclosure. In particular, without departing from the spirit and teachings of the present disclosure, the features described in the various embodiments of the present disclosure may be combined and / or combined in a variety of ways. All of these combinations and / or combinations fall within the scope of the present disclosure.

[0129] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.

Claims

1. A test coverage calculation method, characterized in that: The method comprises: Acquire first data, wherein the first data at least represents a mapping relationship between applications, interfaces, and program methods called when running a test case script; Acquire second data, where the second data at least represents a mapping relationship between applications, interfaces, and program methods used in the execution of the historical business; Filter the second data based on a preset rule to obtain third data, where the third data represents the second data whose interface meets a target condition; The test coverage is calculated based on the third data, the mapping relationship and the first data.

2. The method according to claim 1, characterized in that The second data is generated based on the execution process of the historical business, and the generation process of the second data includes: In response to the occurrence of the service, the execution process of the service is monitored, and second data corresponding to the service is generated.

3. The method according to claim 2, characterized in that The generation process of the second data further includes: Based on the interface information in the second data, interface index data corresponding to the interface is generated.

4. The method according to claim 3, characterized in that The step of screening the second data based on a preset rule to obtain the third data includes: Based on the preset index, matching is performed with the interface index data corresponding to the interface to obtain target index information; Based on the target index information, second data corresponding to the target index information is acquired to form third data.

5. The method according to claim 4, characterized in that The target index information includes at least the number of times the interface in the second data is called during the execution of the service.

6. The method according to any one of claims 1 to 5, characterized in that The calculating the target interface test coverage based on the third data, the mapping relationship and the first data includes: Filtering the first data based on the third data to obtain fourth data, where the fourth data represents the first data that meets the target condition; The test coverage is calculated based on the interface corresponding to the fourth data and the interface corresponding to the first data.

7. The method according to claim 6, characterized in that The obtaining of the fourth data comprises: Matching the first data with the third data to obtain fifth data, where the fifth data represents data in the first data that matches the interface represented by the third data; Matching the fifth data with each program method corresponding to the interface in the fifth data to obtain a target program method collection; Matching the target method collection with the first data to obtain sixth data, wherein the sixth data represents the first data corresponding to the interface matching the target program method in the first data; The sixth data is matched with the target method collection to obtain the fourth data.

8. The method according to claim 7, wherein the step of calculating the test coverage based on the interface corresponding to the fourth data and the interface corresponding to the first data comprises: Calculate a first quantity based on the fourth data, where the first quantity represents the number of non-repeated interfaces in the fourth data; Based on the first data, calculating a second quantity, where the second quantity represents the number of non-repeated interfaces in the first data; The test coverage is calculated according to the first data amount and the second amount.

9. The method according to any one of claims 1 to 5, characterized in that The target condition represents that the number of calls of the interface within a preset time range is greater than or equal to a preset number threshold, and the preset indicator is the number of calls of the interface.

10. A test coverage calculation device, characterized in that: The device comprises: A first acquisition module, configured to acquire first data, wherein the first data at least represents a mapping relationship between applications, interfaces, and program methods called when running a test case script; A second acquisition module, used to acquire second data, wherein the second data at least represents a mapping relationship between applications, interfaces and program methods used in the execution of historical services; a screening module, configured to screen the second data based on a preset rule to obtain third data, wherein the third data represents the second data whose interface meets a target condition; and A calculation module is used to calculate the test coverage based on the third data, the mapping relationship and the first data.

11. An electronic device, comprising: one or more processors; a memory for storing one or more computer programs, It is characterized in that the one or more processors execute the one or more computer programs to implement the steps of the method according to any one of claims 1 to 9.

12. A computer-readable storage medium having a computer program or instruction stored thereon, characterized in that: When the computer program or instruction 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 or instructions, characterized in that When the computer program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.