Interface test coverage calculation method, device, terminal device and storage medium
By obtaining and analyzing the application interface data in the target system, determining the number of tested and target application interfaces, and adjusting the correction coefficient, calculating the interface test coverage, the problem of low calculation accuracy in the existing technology is solved, and a more accurate interface test coverage evaluation is achieved.
Patent Information
- Application Number
- CN202111435613.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-29
- Publication Date
- 2025-06-27
- Estimated Expiration
- 2041-11-29
AI Technical Summary
When calculating interface test coverage, the accuracy of the prior art is low, because only counting whether the interface has been tested in the test case, without considering whether all interface functions have been tested, and whether all interfaces in the system need to participate in the calculation is not distinguished.
By obtaining the application interface, number of test cases and number of calls used by each application in the target system, the number of tests of the tested application interface and the number of target application interfaces are determined based on these data, the preset correction coefficient is adjusted, and the interface test coverage of the target system is calculated.
Improves the calculation accuracy of interface test coverage, ensuring that only interfaces that are actually used and fully tested are calculated, thereby reducing maintenance costs.
Smart Images

Figure CN114090456B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the technical field of R & D management, and particularly relates to a method, device, terminal device and storage medium for calculating interface test coverage rate. Background Art
[0002] Interface testing is a type of testing for each interface between system components, mainly used to test the accuracy, integrity, security and quality of the interfaces between the system and other external systems, as well as the interfaces between each functional module within the system.
[0003] Through the interface test coverage rate, testers can know which interfaces in the system have been replaced and which interfaces still have services being called, facilitating testers to understand the interfaces that have been taken offline and promptly abandoning the automated tests for these interfaces to reduce maintenance costs.
[0004] However, during the process of calculating the interface test coverage rate, when the system counts the number of tested interfaces, it only counts based on whether the interface has been tested by test cases. However, for some interfaces during testing, all functions of the interface have not been fully tested. That is, although the application interface has been tested by test cases, it should not be regarded as a tested interface to participate in the above calculation. At the same time, when calculating the interface test coverage rate, only the ratio of the number of tested interfaces to the total number of interfaces in the system is calculated, without distinguishing whether all interfaces in the system need to participate in the above calculation, resulting in a low accuracy of the finally calculated interface test coverage rate. Summary of the Invention
[0005] The embodiments of this application provide a method, device, terminal device and storage medium for calculating interface test coverage rate, which can solve the problem of low accuracy when calculating the interface test coverage rate of a test system.
[0006] In a first aspect, the embodiments of this application provide a method for calculating interface test coverage rate, and the method includes:
[0007] Obtain the group data included in the target system, where the target system includes multiple applications, and the group data includes at least the application interfaces used by each application, the number of test cases for each application interface, and the call volume;
[0008] Based on the number of test cases, determine the number of tests for the tested application interfaces from multiple application interfaces; and, based on the call volume, determine the target application interfaces and the target quantity of the target application interfaces; the target application interfaces are the interfaces actually used by the target system;
[0009] Adjust the preset correction coefficient according to the ratio of the target quantity to the total quantity of application interfaces to obtain the adjusted target correction coefficient;
[0010] Calculate the ratio of the number of tests to the target number and calculate it with the target correction coefficient to obtain the actual interface test coverage rate of the target system.
[0011] In a second aspect, an embodiment of the present application provides an interface test coverage rate calculation device, which includes:
[0012] An acquisition module, configured to acquire group data included in a target system. The target system includes multiple applications. The group data at least includes application interfaces used corresponding to each application, the number of test cases for each application interface, and the call volume.
[0013] A quantity determination module, configured to determine the number of tests of the tested application interfaces from multiple application interfaces based on the number of test cases; and determine the target application interfaces and the target quantity of the target application interfaces based on the call volume. The target application interfaces are the interfaces actually used by the target system.
[0014] A correction module, configured to adjust a preset correction coefficient according to the ratio of the target quantity to the total quantity of the application interfaces to obtain an adjusted target correction coefficient.
[0015] A calculation module, configured to calculate the ratio of the number of tests to the target quantity and calculate it with the target correction coefficient to obtain the actual interface test coverage rate of the target system.
[0016] In a third aspect, an embodiment of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the method described in the first aspect above is implemented.
[0017] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and is characterized in that when the computer program is executed by a processor, the method described in the first aspect above is implemented.
[0018] In a fifth aspect, an embodiment of the present application provides a computer program product. When the computer program product runs on a terminal device, the terminal device is enabled to execute the method described in the first aspect above.
[0019] The beneficial effects of the embodiments of the present application compared with the prior art are as follows: In this embodiment, after obtaining the application interfaces used by each application in the target system, as well as the number of test cases and the number of calls for each application interface, the terminal device can accurately determine the number of tests for the actually tested application interfaces from multiple application interfaces based on the number of test cases; and further distinguish the application interfaces used by all applications according to the number of calls to accurately obtain the target application interfaces that are actually still in use in the target system. Then, according to the ratio of the target number of the target application interfaces that are actually still in use to the total number, the fixed preset correction coefficient can be fine-tuned, so that the terminal device can accurately calculate the interface test coverage rate in the target system according to the processed number of tests, the target number, and the fine-tuned target correction coefficient. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0021] Figure 1 is a flowchart of the implementation of a method for calculating interface test coverage rate provided by an embodiment of the present application;
[0022] Figure 2 is a schematic diagram of an implementation manner of S102 of a method for calculating interface test coverage rate provided by an embodiment of the present application;
[0023] Figure 3 is a flowchart of the implementation of a method for calculating interface test coverage rate provided by another embodiment of the present application;
[0024] Figure 4 is a flowchart of the implementation of a method for calculating interface test coverage rate provided by still another embodiment of the present application;
[0025] Figure 5 is a schematic diagram of the structure of a device for calculating interface test coverage rate provided by an embodiment of the present application;
[0026] Figure 6 is a schematic diagram of the structure of a terminal device provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0027] In the following description, specific details such as specific system architectures and technologies are presented for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, those skilled in the art should clearly understand that the present application can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid unnecessary details from obscuring the description of the present application.
[0028] It should be understood that when used in the specification and appended claims of the present application, the term "comprising" indicates the presence of the described features, wholes, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components, and / or their combinations.
[0029] In addition, in the description of the specification and appended claims of the present application, terms such as "first", "second", "third", etc. are only used for distinguishing descriptions and cannot be construed as indicating or implying relative importance.
[0030] The interface test coverage calculation method provided by the embodiments of the present application can be applied to terminal devices such as tablet computers, laptop computers, ultra-mobile personal computers (UMPCs), etc. The embodiments of the present application do not impose any restrictions on the specific types of terminal devices. Among them, the terminal device can be installed with the above-mentioned target system or have a data connection with the target system to process the target system.
[0031] Please refer to Figure 1 , Figure 1 , which shows an implementation flowchart of an interface test coverage calculation method provided by the embodiments of the present application. The method includes the following steps:
[0032] S101. The terminal device obtains the group data included in the target system. The target system includes multiple applications. The group data includes at least the application interfaces used by each application, the number of test cases for each application interface, and the call volume.
[0033] In one embodiment, the above-mentioned target system includes, but is not limited to, a system for bank transactions, or a system for logistics information management. The embodiments of the present application do not limit the functions used by the target system. Specifically, the above-mentioned target system can be composed of three subsystems, namely, the Athena subsystem, the Seiya subsystem, and the Cat subsystem. Among them, the Athena subsystem includes multiple applications for executing background programs. Each application usually communicates with other applications or external devices through one or more application programming interfaces (APIs) during operation.
[0034] The above-mentioned Seiya subsystem can be used for data interaction with the Athena subsystem to maintain the interface data of the application interfaces used by each application in the Athena subsystem.
[0035] The above-mentioned Cat subsystem is used to record the call volume of each application interface when each application in the Athena subsystem is running. For example, for the application interface of any application, the Cat subsystem can monitor the number of times the application interface is called by the application within a day as the call volume.
[0036] It can be understood that the Athena subsystem, the Seiya subsystem, and the Cat subsystem can be systems used to record, store, and process the interface data generated by each application interface that needs to be called during the operation of the same type of business.
[0037] In one embodiment, the above-mentioned group data includes, but is not limited to, the traffic type and application identifier corresponding to each application, and may also include all application information of each application in the Athena subsystem. For example, it may also include the application name, each interface included in the application, etc. Among them, the above-mentioned traffic type can be specifically distinguished according to the name of the application. For example, if the application is Weibo, the corresponding traffic type can be considered as the Weibo traffic type, and there is no limitation on this.
[0038] Among them, when the target system includes multiple applications, the terminal device can obtain the group data included in the target system in the following way: The terminal device can log in to the Athena subsystem and use web crawler technology to obtain the grouping relationship between all applications under the Athena subsystem. For example, the terminal device can first obtain multiple sub-groups belonging to group A in the Athena subsystem; then, for any sub-group, loop to obtain the remaining sub-sub-groups under the sub-group; finally, according to the application identifier included in the sub-sub-group, determine the applications under the group and the traffic type corresponding to the applications. After that, the terminal device can query the interface data maintained by the target system according to the application identifier and traffic type; the interface data at least includes the application interfaces used by each application, the number of test cases for each application interface, and the call volume.
[0039] In a specific embodiment, the interface data maintained by the above-mentioned target system can specifically be the automated interface data maintained by the Seiya subsystem, which includes the application interfaces used by each application in the Athena subsystem, the number of test cases used when performing automated testing on each application interface, and the call volume of each application interface in a preset time period.
[0040] It should be noted that when conducting functional tests on the application interfaces of an application, multiple test cases are usually required for testing to fully ensure the security and stability of the application interfaces. Moreover, for any application interface in the Athena subsystem, when testers conduct tests on the application interface, the final interface data (number of test cases, application identifier, application interface) can be stored in the Seiya subsystem. Among them, when obtaining all the maintained application interfaces included in the Athena subsystem, the terminal device can directly query the maintained interface data from the Seiya subsystem according to the application identifier and traffic type.
[0041] It should be added that the above application interfaces are all the interfaces used by the application. That is, for any one application, generally, the application has multiple application interfaces, and each type of application interface is respectively used to transmit a type of business data.
[0042] It should be noted that when the terminal device obtains the group data of the target system, it can specifically use web crawler technology to obtain it. Exemplarily, if the database storing the grouping relationship in the target system is the requests database, the terminal device can use the requests.get() method to obtain data. Specifically, it can be implemented through the code variable = request.get('url'). Among them, variable represents the name of the variable, and the parameter url in the parentheses is the address of the required group data.
[0043] S102. The terminal device determines the test quantity of the tested application interfaces from multiple application interfaces based on the number of test cases; and determines the target application interface and the target quantity of the target application interface based on the call volume; the target application interface is the interface actually used by the target system.
[0044] In one embodiment, the above number of test cases has been described in S101 and will not be explained again here. Among them, determining the tested application interfaces from multiple application interfaces can be: for any one application interface, it has been tested by the test cases corresponding to the application interface. It can also be that although the application interface has been tested by the corresponding test cases, the number of test cases does not meet the requirements. That is, although the application interface has been tested, not all of its functions have been tested. Based on this, the terminal device can consider that this application interface is not a tested application interface.
[0045] In this embodiment, referring to Figure 2 , the terminal device can determine the test quantity of the tested application interfaces and the target quantity of the target application interface from multiple application interfaces through the following steps S1021 - S1022:
[0046] S1021. For the application interface of any application, the terminal device determines whether the number of test cases of the application interface is greater than a preset number of cases; if the number of test cases is greater than the preset number of cases, it is determined that the application interface is a tested application interface; the number of tested application interfaces is counted to obtain the test quantity.
[0047] In an embodiment, the above preset number of cases can be set by the tester according to the actual situation, and there is no limitation on this. Specifically, it can be to obtain the number of test cases of multiple existing tested application interfaces; then, calculate the average value of the multiple numbers of test cases as the preset number of cases.
[0048] It can be understood that for any application interface, if the number of test cases used when testing this application interface is greater than the preset number of cases, and this application interface is still being used by the application, it means that this application interface is a safe and stable interface. That is, it is considered that this application interface belongs to the tested application interface.
[0049] If the number of test cases used when testing this application interface is less than or equal to the preset number of cases, then even if this application interface is still being used by the application, it cannot be directly determined that this application interface is a safe and stable interface. That is, it is considered that this application interface belongs to the untested application interface.
[0050] It should be added that the terminal device can count the test quantities of all tested application interfaces and store them. Specifically, the terminal device can store the test quantity and the tested application interfaces in the oracle database through the cx-oracle technology.
[0051] S1022. The terminal device determines whether the call volume of the application interface is greater than a preset call volume; if the call volume is greater than the preset call volume, it is determined that the application interface is a target application interface; the number of target application interfaces is counted to obtain the target quantity.
[0052] In an embodiment, the above call volume has been described in S101 and will not be explained again here. Among them, the target application interface is the interface actually used by the target system. Exemplarily, to determine the target quantity of the target application interface from multiple application interfaces, it can be: for any one application interface, if it has been called within the target preset time period, it can be considered that this application interface is a target application interface. Then, count the number of all target application interfaces to obtain the target quantity.
[0053] In one embodiment, the above preset call volume can be the preset call volume separately set by the tester for each application interface in advance, or it can also be a uniquely preset call volume set in advance. That is, each application interface corresponds to a common preset call volume. Then, for any application interface, when it is determined that the call volume of the application interface is greater than the preset call volume, the application interface can be determined as the target application interface. Among them, the value of the preset call volume can be specifically set to 100, which is not limited in this regard.
[0054] It can be understood that all the application interfaces of the application can be divided into: tested application interfaces and untested application interfaces. It should be particularly noted that for untested application interfaces, there may be a situation where the number of times they are called daily is small. That is, although the application includes this untested application interface, because this application interface is not frequently used, it does not belong to the target application interface. Therefore, when calculating the interface test coverage rate of multiple applications, untested application interfaces with low call volumes can be excluded to make the calculated test coverage rate more accurate.
[0055] It should be added that when counting the call volume of each application interface, it is to count the call volume of each application interface called within the target time period. Specifically, the target time period can be within one day before the current moment. Specifically, it can be tested by the tester. In addition, for the preset call volume, it can also be set according to the duration of the target time period. For example, the preset call volume for one day can be 100, and the preset call volume for two days can be 200, and so on, which is not limited in this regard. That is to say, the preset call volume is not a fixed value.
[0056] In addition, in a specific embodiment, referring to Figure 3 , after determining the target application interface and the target quantity of the target application interface based on the call volume in S102, the following steps S121 - S122 can also be used to perform a secondary verification on the target application interface to accurately determine the target application interface:
[0057] S121. The terminal device obtains service data from the target application interface, and the service data is the data obtained from the database of the target system when the target application interface is called.
[0058] S122. If the service data includes preset key information, the terminal device deletes the target application interface; where the key information is used to identify that the target application interface corresponding to the service data containing the key information is an application interface to be taken offline.
[0059] In one embodiment, the above service data is the data pre - stored in the database of the target system. Among them, when the application runs, it usually needs to call the corresponding application interface to obtain service data from the database to implement a certain application function of the application.
[0060] Specifically, functions are usually predefined in the application interface. For example, the function can be a query language for accessing a database to achieve data sharing between applications through the database. Therefore, for any application interface, it can obtain corresponding business data from the database for processing.
[0061] Based on this, testers can pre-set one or more key information for each business data in the database. When the business data is obtained by the application interface, the terminal device can determine whether the current application interface is an infrequently used application interface (i.e., a non-target application interface) or an application interface to be taken offline based on the key information.
[0062] It can be understood that for the application interfaces to be taken offline, these interfaces do not need to participate in the testing. Therefore, when counting the target application interfaces, these application interfaces can also not participate in the statistics.
[0063] Based on this, when the terminal device determines that the business data includes the preset key information, it can delete the target application interface called at this time; otherwise, it retains the target application interface. Then, it counts the number of the remaining target application interfaces as the target number.
[0064] S103. The terminal device adjusts the preset correction coefficient according to the ratio of the target number to the total number of application interfaces to obtain an adjusted target correction coefficient.
[0065] S104. The terminal device calculates the ratio of the test number to the target number and calculates it with the target correction coefficient to obtain the actual interface test coverage rate of the target system.
[0066] In an embodiment, after obtaining the test number and the target number, the terminal device can calculate the interface test coverage rate according to a preset calculation formula. Specifically, the calculation formula can be:
[0067] L coverage = M test / N target * K correction
[0068] Wherein, M test is the test number, N target is the target number, and K correction is the preset correction coefficient; the correction coefficient is used to be adjusted according to the ratio of the target number to the total number of application interfaces.
[0069] Wherein, the correction coefficient K correctionSpecific adjustments can be made in the following ways: when the ratio is within the first preset range, the preset correction coefficient is decreased to the first preset value; when the ratio is within the second preset range, the preset correction coefficient is increased to the second preset value. Among them, the first preset range, the first preset value, the second preset range, and the second preset value can all be set by the tester according to the actual situation.
[0070] It should be added that the purpose of adjusting the correction coefficient by the ratio is as follows: when determining the target application interface, the accuracy of the determination method may not be high, so that the terminal device may count the number of target application interfaces too many or too few; or, when counting the application interfaces to be taken offline, although the service data called by the application interface includes the preset key information, however, there may be business adjustments in the target system, resulting in the application interface not actually being taken offline.
[0071] Therefore, in order to prevent the terminal device from determining the target application interface too many or too few, when the ratio is within the first preset range with a higher value, it can be considered that the number of target application interfaces is overcounted, so that the target number of non-target application interfaces is undercounted. As a result, the calculated interface test coverage rate is on the low side. Based on this, in order to further correct the interface test coverage rate, a relatively high value can be set for the corresponding first preset value. That is, the preset correction coefficient is increased to the first preset value. On the contrary, when the ratio is within the second preset range with a lower value, it can be considered that the target number of target application interfaces is undercounted. As a result, the calculated interface test coverage rate is on the high side. Furthermore, a relatively low value can be set for the corresponding second preset value. That is, the preset correction coefficient is decreased to the second preset value. Among them, the first preset value is greater than the second preset value.
[0072] Based on this, in this embodiment, after obtaining the application interfaces used by each application in the target system, as well as the number of test cases and the call volume of each application interface, the terminal device can accurately determine the number of tested application interfaces that have actually been tested from multiple application interfaces based on the number of test cases; and, further distinguish the application interfaces used by all applications according to the call volume to accurately obtain the target application interfaces that are actually still in use in the target system. Then, the fixed preset correction coefficient can also be fine-tuned according to the ratio of the target number of target application interfaces that are actually still in use to the total number, so that the terminal device can accurately calculate the interface test coverage rate of the target system based on the processed number of tests, the target number, and the fine-tuned target correction coefficient.
[0073] In one embodiment, referring to Figure 4, after calculating the ratio of the number of tests to the target number and the target correction coefficient in S104 to obtain the actual interface test coverage rate of the target system, the following steps S141 - S143 are further included:
[0074] S141. If the interface test coverage rate is lower than the preset coverage rate, the terminal device acquires untested application interfaces whose number of test cases is less than or equal to the preset number of cases.
[0075] S142. The terminal device deletes the application interfaces to be taken offline from the untested application interfaces.
[0076] S143. The terminal device tests the remaining untested application interfaces.
[0077] In one embodiment, as already described in S1022 above, when the number of test cases is greater than the preset number of cases, the application interface is determined as a tested application interface; based on this, it can be determined that when the number of test cases is less than or equal to the preset number of cases, the application interface is an untested application interface. Among them, the above - mentioned preset coverage rate can be set by the tester according to the actual situation, and no limitation is imposed on this.
[0078] It can be understood that when the interface test coverage rate is lower than the preset coverage rate, it can be considered that among the application interfaces used by the target system, there are a large number of untested application interfaces that are insecure and unstable. When the untested application interface runs, it may affect the normal operation of the business and cause the target system to run unstably.
[0079] Based on this, in order to improve the stability of the target system operation and improve the test efficiency of the terminal device for untested application interfaces, for multiple untested application interfaces, the application interfaces to be taken offline that do not need to be tested can be deleted from them.
[0080] It can be understood that for the application interfaces to be taken offline, it can be considered that the application interface may not be called when the target system runs subsequently. Therefore, even if the interface test is not performed on this application interface, it does not affect the stability of the target system operation. Based on this, the terminal device can only test the remaining untested application interfaces.
[0081] Among them, in one embodiment, after obtaining the interface test coverage rate of the above - mentioned target system, the terminal device can generate a test report of the interface test coverage rate for the tester to have a detailed understanding of each application interface in the target system. The test report includes but is not limited to tested application interfaces, the number of tests, untested application interfaces, and the number of untested application interfaces, and no limitation is imposed on this.
[0082] Among them, in the test of the remaining untested application interfaces in S143, specifically, it can be: the terminal device classifies the untested application interfaces according to the interface types of the untested application interfaces, and takes the untested application interfaces with the same interface type as a group of untested application interfaces; the terminal device obtains the number of test cases of all test cases in a group of untested application interfaces; if the number of test cases of all test cases is greater than the preset number of cases, the terminal device uses all test cases as the test cases of each untested application interface with the same interface type respectively.
[0083] In the application, the above interface types include but are not limited to the function types of untested application interfaces, the data types called, etc. Among them, taking the interface type as the function type as an example, the function type can be divided into a registration function type, a login function type, a logout function type, etc. Therefore, for multiple untested application interfaces of the same function type, since the number of test cases of each untested application interface is less than the preset number of cases. Therefore, the terminal device can take each untested application building with the same function type as a group of untested application interfaces. At the same time, when the number of test cases of all test cases is greater than the preset number of cases, all the numbers of test cases can be used as the test cases of each untested application interface with the same interface type respectively.
[0084] It can be understood that since the test cases corresponding to untested application interfaces of the same function type are usually the same or similar, therefore, for any untested application interface, it can also use the test cases of other untested application interfaces of the same function type to perform interface testing on it. In this way, the terminal device can, while achieving the test of each untested application interface, also eliminate the need for testers to write new test cases for each untested application interface again, improving the test efficiency of untested application interfaces.
[0085] Please refer to Figure 5 , Figure 5 is the structural block diagram of an interface test coverage rate calculation device provided by an embodiment of the present application. In this embodiment, each module included in the interface test coverage rate calculation device is used to execute Figures 1 to 4 the respective steps in the corresponding embodiment. Specifically, please refer to Figures 1 to 4 and Figures 1 to 4 the relevant descriptions in the corresponding embodiments. For the sake of convenience of description, only the parts related to this embodiment are shown. See Figure 6 , the interface test coverage rate calculation device 500 may include: an acquisition module 510, a quantity determination module 520, a correction module 530, and a calculation module 540, where:
[0086] An acquisition module 510, configured to acquire group data included in a target system, where the target system includes multiple applications, and the group data includes at least application interfaces used by each application, the number of test cases for each application interface, and the call volume.
[0087] A quantity determination module 520, configured to determine the number of tests for the tested application interfaces from multiple application interfaces based on the number of test cases; and determine a target application interface and the target quantity of the target application interface based on the call volume; the target application interface is an interface actually used by the target system.
[0088] A correction module 530, configured to adjust a preset correction coefficient according to the ratio of the target quantity to the total quantity of the application interfaces to obtain an adjusted target correction coefficient.
[0089] A calculation module 540, configured to calculate the ratio of the number of tests to the target quantity and the target correction coefficient to obtain the actual interface test coverage rate of the target system.
[0090] In one embodiment, the test quantity determination module 520 is further configured to:
[0091] For the application interface of any application, determine whether the number of test cases of the application interface is greater than a preset number of cases; if the number of test cases is greater than the preset number of cases, determine that the application interface is a tested application interface; count the number of tested application interfaces to obtain the test quantity; and determine whether the call volume of the application interface is greater than a preset call volume; if the call volume is greater than the preset call volume, determine that the application interface is a target application interface; count the number of target application interfaces to obtain the target quantity.
[0092] In one embodiment, the interface test coverage rate calculation device 500 further includes:
[0093] A service data acquisition module, configured to acquire service data from the target application interface, where the service data is data acquired from the database of the target system when the target application interface is called.
[0094] A target application interface deletion module, configured to delete the target application interface if the service data includes preset key information; where the key information is used to identify that the target application interface corresponding to the service data including the key information is an application interface to be taken offline.
[0095] In one embodiment, the correction module 530 is further configured to:
[0096] When the ratio is within a first preset range, raise the preset correction coefficient to a first preset value; when the ratio is within a second preset range, lower the preset correction coefficient to a second preset value.
[0097] In one embodiment, the interface test coverage rate calculation device 500 further includes:
[0098] An untested application interface acquisition module, configured to acquire untested application interfaces with the number of test cases less than or equal to a preset number of cases if the interface test coverage rate is lower than a preset coverage rate.
[0099] A decommissioned application interface deletion module, configured to delete decommissioned application interfaces from the untested application interfaces.
[0100] A test module, configured to test the remaining untested application interfaces.
[0101] In one embodiment, the test module is further configured to:
[0102] Classify the untested application interfaces according to the interface types of the untested application interfaces, and use the untested application interfaces with the same interface type as a group of untested application interfaces; obtain the number of test cases of all test cases in a group of untested application interfaces; if the number of test cases of all test cases is greater than the preset number of cases, use all test cases as the test cases of each untested application interface with the same interface type respectively.
[0103] In one embodiment, the interface test coverage rate calculation device 500 further includes:
[0104] A generation module, configured to generate a test report on the interface test coverage rate, where the test report includes tested application interfaces, the number of tests, untested application interfaces, and the number of untested application interfaces.
[0105] It should be understood that Figure 5 in the structural block diagram of the interface test coverage rate calculation device shown, each module is used to execute Figures 1 to 4 the respective steps in the corresponding embodiment, and for Figures 1 to 4 the respective steps in the corresponding embodiment have been explained in detail in the above embodiments. For details, please refer to FIG. Figures 1 to 4 and Figures 1 to 4 the relevant descriptions in the corresponding embodiment, which will not be elaborated here.
[0106] Figure 6 is the structural block diagram of a terminal device provided in an embodiment of the present application. As Figure 6 shown, the terminal device 600 in this embodiment includes: a processor 610, a memory 620, and a computer program 630 stored in the memory 620 and executable on the processor 610, such as a program for the interface test coverage rate calculation method. When the processor 610 executes the computer program 630, the steps in each of the above embodiments of the interface test coverage rate calculation method are implemented, such as Figure 1S101 to S104 shown above. Alternatively, when the processor 610 executes the computer program 630, it implements the functions of each module in the corresponding Figure 6 embodiment, for example, Figure 6 the functions of the modules 510 to 540 shown above. For specific details, please refer to Figure 5 the relevant descriptions in the corresponding embodiments.
[0107] Exemplarily, the computer program 630 can be divided into one or more modules. One or more modules are stored in the memory 620 and executed by the processor 610 to implement the interface test coverage calculation method provided by the embodiments of the present application. One or more modules can be a series of computer program instruction segments capable of completing specific functions, and these instruction segments are used to describe the execution process of the computer program 630 in the terminal device 600. For example, the computer program 630 can implement the interface test coverage calculation method provided by the embodiments of the present application.
[0108] The terminal device 600 may include, but is not limited to, a processor 610 and a memory 620. Those skilled in the art can understand that Figure 6 these are merely examples of the terminal device 600 and do not constitute a limitation on the terminal device 600. It may include more or fewer components than shown in the figure, or combine certain components, or different components. For example, the terminal device may also include input / output devices, network access devices, buses, etc.
[0109] The so-called processor 610 may be a central processing unit, or may also be other general-purpose processors, digital signal processors, application-specific integrated circuits, off-the-shelf programmable gate arrays, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor, or the processor may also be any conventional processor, etc.
[0110] The memory 620 may be an internal storage unit of the terminal device 600, such as the hard disk or memory of the terminal device 600. The memory 620 may also be an external storage device of the terminal device 600, such as a plug-in hard disk, a smart memory card, a flash memory card, etc. equipped on the terminal device 600. Further, the memory 620 may also include both the internal storage unit and the external storage device of the terminal device 600.
[0111] The embodiments of the present application provide a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the interface test coverage calculation method in the above-mentioned various embodiments.
[0112] An embodiment of the present application provides a computer-readable storage medium, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the interface test coverage calculation method in each of the above embodiments.
[0113] An embodiment of the present application provides a computer program product. When the computer program product runs on a terminal device, it causes the terminal device to execute the interface test coverage calculation method in each of the above embodiments.
[0114] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features. These modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of each embodiment of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for calculating interface test coverage rate, characterized in that, Including: Obtain group data included in a target system, where the target system includes multiple applications, and the group data includes at least application interfaces respectively used by each application, the number of test cases for each application interface, and the call volume; Based on the number of test cases, determine the number of tests for the tested application interfaces from multiple application interfaces; And, based on the call volume, determine a target application interface and the target number of the target application interface; The target application interface is an interface actually used by the target system; Adjust a preset correction coefficient according to the ratio of the target number to the total number of application interfaces to obtain an adjusted target correction coefficient; Calculate the ratio of the number of tests to the target number and the target correction coefficient to obtain the actual interface test coverage rate of the target system; Among them, the determining the number of tests for the tested application interfaces from multiple application interfaces based on the number of test cases; and, determining a target application interface and the target number of the target application interface based on the call volume includes: For the application interface of any application, determine whether the number of test cases of the application interface is greater than a preset number of cases; if the number of test cases is greater than the preset number of cases, determine that the application interface is the tested application interface; count the number of the tested application interfaces to obtain the number of tests; and, Determine whether the call volume of the application interface is greater than a preset call volume; if the call volume is greater than the preset call volume and the application interface is still used by the application, determine that the application interface is the target application interface; count the number of the target application interfaces to obtain the target number.
2. The interface test coverage rate calculation method according to claim 1, characterized in that After determining the target application interface and the target number of the target application interface based on the call volume, it further includes: Obtain service data from the target application interface, where the service data is data obtained from the database of the target system when the target application interface is called; If the service data includes preset key information, delete the target application interface; where the key information is used to identify that the target application interface corresponding to the service data containing the key information is an application interface to be taken offline.
3. The interface test coverage rate calculation method according to claim 1, wherein The adjusting a preset correction coefficient according to the ratio of the target number to the total number of application interfaces to obtain an adjusted target correction coefficient includes: When the ratio is within a first preset range, raise the preset correction coefficient to a first preset value; When the ratio is within a second preset range, lower the preset correction coefficient to a second preset value.
4. The interface test coverage rate calculation method according to claim 1, wherein After calculating the ratio of the number of tests to the target number and the target correction coefficient to obtain the actual interface test coverage rate of the target system, it further includes: If the interface test coverage rate is lower than a preset coverage rate, obtain untested application interfaces whose number of test cases is less than or equal to the preset number of cases; Delete the application interfaces to be taken offline from the untested application interfaces; Test the remaining untested application interfaces.
5. The interface test coverage rate calculation method according to claim 4, wherein Testing the remaining untested application interfaces includes: Classifying the untested application interfaces according to the interface types of the untested application interfaces, and taking the untested application interfaces with the same interface type as a group of untested application interfaces; Obtaining the number of test cases of all test cases in the group of untested application interfaces; If the number of test cases of all test cases is greater than the preset number of cases, then taking all the test cases as the test cases of each untested application interface with the same interface type.
6. The interface test coverage rate calculation method according to any one of claims 1 or 3-5, characterized in that After calculating the interface test coverage rate of the target system according to the test quantity and the target quantity, it further includes: Generating a test report of the interface test coverage rate, where the test report includes the tested application interfaces, the test quantity, the untested application interfaces, and the number of the untested application interfaces.
7. An interface test coverage calculation device, characterized in that, Including: An acquisition module for acquiring group data included in a target system, where the target system includes multiple applications, and the group data at least includes the application interfaces used corresponding to each application, the number of test cases of each application interface, and the call volume; A quantity determination module for determining the test quantity of the tested application interfaces from multiple application interfaces based on the number of test cases; And determining a target application interface and the target quantity of the target application interface based on the call volume; The target application interface is the interface actually used by the target system; A correction module for adjusting a preset correction coefficient according to the ratio of the target quantity to the total quantity of the application interfaces to obtain an adjusted target correction coefficient; A calculation module for calculating the ratio of the test quantity to the target quantity and the target correction coefficient to obtain the actual interface test coverage rate of the target system; Wherein, the quantity determination module is specifically configured to: for the application interface of any application, determine whether the number of test cases of the application interface is greater than a preset number of cases; if the number of test cases is greater than the preset number of cases, then determine that the application interface is the tested application interface; counting the number of the tested application interfaces to obtain the test quantity; and determining whether the call volume of the application interface is greater than a preset call volume; if the call volume is greater than the preset call volume and the application interface is still being used by the application, then determine that the application interface is the target application interface; counting the number of the target application interfaces to obtain the target quantity.
8. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method according to any one of claims 1 to 6.
9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Automatic test analysis processing method and device, computer device and storage medium
CN109766263A
Test verification method and device, electronic equipment and computer readable storage medium
CN112685283A