A code coverage testing method, computer device and storage medium
By receiving and processing test requests from multiple test callers and obtaining and calculating the code coverage of each request, the problem of difficulty in accurately identifying the code coverage of each test caller in the prior art is solved, and the effect of accurately identifying and avoiding the risk of missed testing is achieved.
Patent Information
- Application Number
- CN202210685658.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-16
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2042-06-16
AI Technical Summary
In large and medium-sized projects, when multiple test calls are conducting end-to-end joint debugging tests at the same time, it is difficult for the existing technology to accurately identify the code coverage of each test caller, resulting in the risk of missing tests.
By receiving test requests from multiple test callers, the code data to be tested and its unique data identification in each request are obtained, and the code execution and coverage calculation are performed separately to obtain the specific code coverage of each test caller.
Accurate identification of the code coverage of each test caller is achieved, the risk of missed testing is avoided, and the effectiveness and integrity of the test is improved.
Smart Images

Figure CN115185816B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of application testing technology, and in particular to a code coverage testing method, computer equipment and storage medium. Background Art
[0002] In the modern software development system, test measurement activities are an indispensable part of the software development process. Through measurement, the effectiveness and completeness of the test, as well as the quality of the work product, are judged, and quantitative guidance is provided for the improvement of the development process. The measurement scope includes time schedule, cost input, scale, test quality, product quality, etc. Among them, the measurement of test quality is the most important dimension, which has a direct reference value for evaluating the final release quality of the work product. Test quality measurement includes a variety of methods, such as requirement coverage, use case pass rate, code coverage, etc. Among them, the measurement of code coverage is the most accurate and intuitive measurement method that reflects the test effect.
[0003] Existing code coverage measurement tools can obtain the code coverage of a single application test conveniently, efficiently, and dynamically. However, in the actual R&D activities of large and medium-sized projects / demands, there may be situations where several test callers call the same test service provider or test service provider link. In this case, multiple test callers simultaneously perform a large number of end-to-end joint debugging tests, and often only the final end-to-end joint debugging test code coverage of all test callers can be obtained, that is, only an overall code coverage corresponding to the code data to be tested of all test callers can be obtained, but the specific code coverage corresponding to the code data to be tested of each test caller cannot be obtained, resulting in the inability to accurately identify whether the end-to-end joint debugging test of any test caller is insufficiently covered, which ultimately brings the risk of missed tests. Summary of the invention
[0004] In view of the deficiencies in the prior art, the present invention provides a code coverage testing method, a computer device and a storage medium.
[0005] In a first aspect, in one embodiment, the present invention provides a code coverage testing method, comprising:
[0006] Receiving first test requests to be processed respectively sent by multiple test callers;
[0007] Respectively obtain the code data to be tested and the first data identifier of the code data to be tested in each first test request; the first data identifier is used to represent the identity information of the test caller, and each test caller has a unique first data identifier;
[0008] Perform code execution on each code data to be tested respectively to obtain first code coverage data corresponding to each first data identifier;
[0009] The code coverage rate of each first code coverage data is determined respectively to obtain the first code coverage rate corresponding to each first data identifier.
[0010] In a second aspect, in one embodiment, the present invention provides a computer device including a memory and a processor; the memory stores a computer program, and the processor is used to run the computer program in the memory to execute the steps in the code coverage testing method in any of the above embodiments.
[0011] In a third aspect, in one embodiment, the present invention provides a storage medium storing a computer program, and the computer program is loaded by a processor to execute the steps in the code coverage testing method in any of the above embodiments.
[0012] Through the above-mentioned code coverage testing method, computer equipment and storage medium, after receiving multiple test requests from multiple test callers, the code coverage test of each code data to be tested is completed based on the corresponding data identifier by obtaining the data identifier in the test request, so that the code coverage rate of the code data to be tested corresponding to each test caller can be obtained respectively, and it is possible to accurately identify whether the end-to-end joint debugging test of any test caller is insufficiently covered, thereby avoiding the risk of missed tests. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0014] Figure 1 A schematic diagram of an application scenario of a code coverage testing method in an embodiment of the present invention;
[0015] Figure 2 A schematic diagram of a code coverage testing method according to an embodiment of the present invention;
[0016] Figure 3 A schematic diagram of a process of sending code data to be tested to a next-level testing service provider in one embodiment of the present invention;
[0017] Figure 4 A schematic diagram of a specific process of obtaining a first data identifier in one embodiment of the present invention;
[0018] Figure 5 A schematic diagram of a specific process of determining a first code coverage rate in one embodiment of the present invention;
[0019] Figure 6A schematic diagram of a flow chart for obtaining all code data to be tested in one embodiment of the present invention;
[0020] Figure 7 A schematic diagram of the structure of a code coverage test device in one embodiment of the present invention;
[0021] Figure 8 The figure is a schematic diagram of the internal structure of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION
[0022] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0023] In the description of the present invention, it should be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the drawings, which are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first" and "second" are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the present application, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined. In the present application, the word "exemplary" is used to mean "used as an example, illustration or description". Any embodiment described as "exemplary" in the present application is not necessarily interpreted as being more preferred or more advantageous than other embodiments. In order to enable any person skilled in the art to implement and use the present invention, the following description is given. In the following description, details are listed for the purpose of explanation. It should be understood that those of ordinary skill in the art will recognize that the present invention can be implemented without using these specific details. In other examples, well-known structures and processes will not be elaborated in detail to avoid unnecessary details that make the description of the present invention obscure. Therefore, the present invention is not intended to be limited to the embodiments shown, but is consistent with the widest range of principles and features disclosed in this application.
[0024] The code coverage testing method in the embodiment of the present invention is applied to a code coverage testing device, and the code coverage testing device is arranged on a computer device; the computer device can be a terminal, such as a mobile phone or a tablet computer, and the computer device can also be a server, or a service cluster composed of multiple servers.
[0025] like Figure 1 As shown, Figure 1 This is a schematic diagram of an application scenario of the code coverage testing method in an embodiment of the present invention. The application scenario of the code coverage testing method in the embodiment of the present invention includes a computer device 100 (a code coverage testing apparatus is integrated in the computer device 100), and a computer-readable storage medium corresponding to the code coverage testing method is run in the computer device 100 to execute the steps of the code coverage testing method.
[0026] Understandably, Figure 1 The computer device in the application scenario of the code coverage testing method shown, or the devices included in the computer device, does not constitute a limitation on the embodiments of the present invention, that is, the number of devices and types of devices included in the application scenario of the code coverage testing method, or the number of devices and types of devices included in each device, do not affect the overall implementation of the technical solution in the embodiments of the present invention, and can all be regarded as equivalent replacements or derivatives of the technical solution claimed to be protected in the embodiments of the present invention.
[0027] The computer device 100 in the embodiment of the present invention may be an independent device, or a device network or device cluster composed of devices. For example, the computer device 100 described in the embodiment of the present invention includes but is not limited to a computer, a network host, a single network device, a plurality of network devices, or a cloud device composed of a plurality of devices. The cloud device is composed of a large number of computers or network devices based on cloud computing.
[0028] Those skilled in the art will understand that Figure 1 The application scenario shown in the figure is only an application scenario corresponding to the technical solution of the present invention, and does not constitute a limitation on the application scenario of the technical solution of the present invention. Other application scenarios may also include Figure 1 More or fewer computer devices shown in, or computer device network connection relationships, such as Figure 1 Only one computer device is shown. It can be understood that the scenario of the code coverage testing method can also include one or more other computer devices, which are not limited here. The computer device 100 can also include a memory for storing information related to the code coverage testing method.
[0029] In addition, in the application scenario of the code coverage test method in the embodiment of the present invention, the computer device 100 may be provided with a display device, or the computer device 100 may not be provided with a display device and may be in communication connection with an external display device 200, and the display device 200 is used to output the result of the execution of the code coverage test method in the computer device. The computer device 100 may access a backend database 300 (the backend database 300 may be a local memory of the computer device 100, or the backend database 300 may also be provided in the cloud), and the backend database 300 stores information related to the code coverage test method.
[0030] It should be noted that Figure 1 The application scenario of the code coverage testing method shown is only an example. The application scenario of the code coverage testing method described in the embodiment of the present invention is to more clearly illustrate the technical solution of the embodiment of the present invention, and does not constitute a limitation on the technical solution provided by the embodiment of the present invention.
[0031] Based on the application scenario of the above code coverage testing method, an embodiment of the code coverage testing method is proposed.
[0032] First, as Figure 2 As shown, in one embodiment, the present invention provides a code coverage testing method, comprising:
[0033] Step 201, receiving first test requests to be processed respectively sent by multiple test callers;
[0034] Among them, the first test request includes the code data to be tested that needs to be subjected to code coverage testing and the first data identifier of the code data to be tested, and the first data identifier is used to distinguish the code data to be tested from other code data to be tested, so as to facilitate the subsequent corresponding code coverage testing for each code data to be tested; for example, the first data identifier of each code data to be tested may be appid-a, appid-b, appid-c..., of course, in other embodiments, other forms of data identifiers may also be used;
[0035] Among them, when the project requirements involve the transformation of the open API interface and the simultaneous transformation of multiple test callers, it is necessary to organize all test callers to conduct testing. That is, in these cases, the first test requests to be processed will be received from multiple test callers respectively;
[0036] The test caller refers to a terminal device that needs to send a first test request to call a test service provider to perform code coverage testing on a corresponding software application, and the multiple test callers in this embodiment may be the same terminal device, that is, multiple first test requests are sent based on one terminal device, or may be different terminal devices, that is, a first test request is sent based on different terminal devices respectively;
[0037] Among them, like the test caller, the execution subject of the code coverage test method in this embodiment is the test service party, which refers to a terminal device that performs code coverage testing in response to the first test request of the test caller; usually, the test caller and the test service method send the first test request and respond to the first test request respectively based on different terminal devices, wherein the test caller and the test service party can send the first test request through the HTTP protocol (HyperText Transfer Protocol HyperText Transfer Protocol, which is an application layer transmission protocol based on the TCP protocol, in simple terms, it is a rule for the client and the server to perform data transmission), that is, the first test request is an http request (the http request includes an http request line, an http request header and an http request body), in which the first data identifier can be stored in the http request header, and the code data to be tested is stored in the http request body;
[0038] Step 202, respectively obtaining the code data to be tested and the first data identifier of the code data to be tested in each first test request;
[0039] The first data identifier is used to represent the identity information of the test caller, and each test caller has a unique first data identifier;
[0040] As mentioned above, the first test request includes the code data to be tested that needs to be tested for code coverage testing and the first data identifier of the code data to be tested. Therefore, it can be obtained by simply parsing the corresponding data. For example, if the first test request is an http request, when the http request is received, the HTTP protocol-related parsing method is used to parse the http data.
[0041] Step 203, executing code on each code data to be tested respectively, to obtain first code coverage data corresponding to each first data identifier;
[0042] Wherein, when the first data identifier exists, each code data to be tested can be distinguished, so that the obtained code coverage data corresponding to each code data to be tested can be distinguished, that is, the first code coverage data corresponding to each first data identifier can be obtained;
[0043] The first code coverage data refers to the code data obtained after the code data to be tested is executed by the test service party, which contains the mark of the executed code data, and the marked executed code data can be used for the subsequent calculation of the code coverage rate;
[0044] Step 204, respectively determine the code coverage of each first code coverage data to obtain the first code coverage corresponding to each first data identifier;
[0045] After obtaining the differentiated first code coverage data, the corresponding code coverage rate can be determined for each first code coverage data, and the obtained code coverage rates can be differentiated, that is, the first code coverage rate corresponding to each first data identifier can be obtained;
[0046] Among them, for each first code coverage data, different coverage analysis strategies can be used to obtain the corresponding first code coverage rate; for example, a decision coverage analysis strategy can be adopted (pointing out the correct or incorrect execution of each Boolean expression in the source code. The goal of decision coverage is to cover and verify all accessible source codes by checking and ensuring that each branch of each decision point is executed at least once), a branch coverage analysis strategy (testing each result from a code module (statement or loop). The purpose of branch coverage is to ensure that each decision condition from each branch is executed at least once. It helps to measure the percentage of independent code segments and find out the parts without branches; for example, if the result is a Boolean type, it is necessary to test both True and False results) or a condition coverage analysis strategy (used to test and evaluate variables or sub-expressions in conditional statements. The goal of condition coverage is to check a single result of each logical condition. Compared with decision coverage, condition coverage is more sensitive to control flow).
[0047] Through the above-mentioned code coverage testing method, after receiving multiple test requests from multiple test caller applications, the code coverage test of each code data to be tested is completed based on the corresponding data identifier by obtaining the data identifier in the test request, so that the code coverage rate of the code data to be tested corresponding to each test caller can be obtained respectively, and it can be accurately identified whether the end-to-end joint debugging test of any test caller is insufficiently covered, thereby avoiding the risk of missed tests.
[0048] like Figure 3 As shown, in one embodiment, after the step of respectively obtaining the code data to be tested and the first data identifier of the code data to be tested in each test request, the code coverage test method further includes:
[0049] Step 301, obtaining the identity of the current testing service provider;
[0050] Among them, the identity information of the current test service provider (usually software applications have corresponding serial numbers, and the serial number is an identification code given by the software developer to the software, which is similar to a person's ID number. Its main function is to prevent the software from being stolen by users. In this embodiment, the identity information mentioned refers to the corresponding serial number) can be directly determined as the identity of the current test service provider. However, since the serial number of the software application generally has more digits, usually more than ten digits, if it is directly determined as the identity and used to identify related data in the subsequent process, it will result in a large amount of transmitted data and waste transmission resources; therefore, a simplified identity can also be generated based on the identity information of the current test service provider, such as appid-A;
[0051] Step 302, obtaining a second data identifier of each code data to be tested according to the identity identifier and the first data identifier of each code data to be tested;
[0052] The identity identifier and the first data identifier of each code data to be tested may be respectively fused to extract the data features of the two, thereby obtaining a second data identifier containing the data features of the two. For example, if the identity identifier of the current test service provider is appid-A, and the first data identifier of a code data to be tested is appid-a, then a and A are the data features of the first data identifier and the identity identifier, respectively. In one fusion method, the fused second data identifier is appid-a~A. Undoubtedly, based on the second data identifier, it can be determined that the code data to be tested corresponding to the second data identifier is the code data to be tested of the test caller a sent from the test service provider A.
[0053] Step 303, generating a second test request corresponding to each second data identifier according to each code data to be tested and the second data identifier of each code data to be tested;
[0054] Among them, the second test request is used to send to the next level test service provider. Different test service providers have different corresponding coverage test strategies and different code coverage rates. Therefore, multi-level code coverage testing can be implemented through different test service providers, which can more comprehensively cover the code data to be tested and improve the comprehensive test effect. As mentioned above, the upper level test service provider and the test caller of the corresponding code data to be tested can be determined based on the second data identifier, so that the entire test service system can reliably and coordinately perform comprehensive testing.
[0055] Step 304, sending each second test request to a next-level test service provider, so that the next-level test service provider performs code coverage testing on the code data to be tested in each second test request;
[0056] The test service providers at different levels may be the same terminal device or different terminal devices. When the test service providers at different levels are different terminal devices, the current test service provider and the next-level test service provider may send the first test request through the HTTP protocol, that is, the second test request is an http request. In the http request, the second data identifier may be stored in the http request header, and the code data to be tested may be stored in the http request body.
[0057] In this embodiment, a corresponding second test request is generated for each code data to be tested, so that the independence between each code data to be tested can be maintained; however, in other embodiments, a third test request can be generated based on all the code data to be tested, and the third test request includes all the code data to be tested and the second data identifier corresponding to the code data to be tested, so as to reduce the number of transmissions and the corresponding number of responses between the current test service provider and the next-level test service provider, thereby saving transmission resources;
[0058] By updating the identifier and initiating a request to the next level of testing service, automated multi-level testing is achieved.
[0059] In one embodiment, obtaining the second data identification of each code data to be tested according to the identity identification and the first data identification of each code data to be tested includes:
[0060] The identity identifier is respectively concatenated with the first data identifier of each code data to be tested to obtain the second data identifier of each code data to be tested;
[0061] For example, if the identity identifier is appid-A, and the first data identifier of a code data to be tested is appid-a, then the second data identifier obtained after splicing is appid-a~appid-A. The splicing method is used to obtain each second data identifier, which makes the operation simpler and can improve processing efficiency.
[0062] In one embodiment, after the step of receiving first test requests to be processed respectively sent by multiple test callers, the code coverage test method further includes:
[0063] Respectively determining each first test request as a corresponding second test request;
[0064] Sending each second test request to a next-level test service provider, so that the next-level test service provider performs code coverage testing on the code data to be tested in each second test request;
[0065] In this embodiment, there is no need to obtain the second data identifier additionally, and the first test request is directly determined as the second test request for forwarding, which can improve processing efficiency and save computing resources.
[0066] like Figure 4 As shown, in one embodiment, before the step of receiving first test requests to be processed respectively sent by multiple test callers, the code coverage test method further includes:
[0067] Step 401, obtaining the identity information of each test caller;
[0068] If each test caller generates the corresponding first data identifier by itself, the formats of the first data identifiers corresponding to different test callers may be inconsistent, and the first data identifiers corresponding to different test callers may be exactly the same. These situations will increase the difficulty of the test service provider in identifying the first data identifier. Therefore, the test service provider may generate the first data identifier uniformly to avoid the problem of inconsistent or exactly the same first data identifier formats and reduce the difficulty of identification.
[0069] Step 402, generating a first data identifier corresponding to each piece of identity information according to each piece of identity information;
[0070] Among them, the identity information of the test caller is consistent with the identity information of the test service provider mentioned above, that is, the corresponding serial number. After the test service provider establishes a connection with the test caller, it can obtain the serial number of each test caller, thereby generating a first data identifier corresponding to each test caller in the same format but with different data content according to the serial number of each test caller; of course, in other embodiments, it is also possible to directly generate the corresponding first data identifier without the need to be based on the serial number of the test caller, but the stability of the first data identifier obtained in this way is poor. When the number of test callers is large and they are called in batches, the first data identifier will not have a reliable identification function;
[0071] Step 403, sending each first data identifier to the test caller corresponding to each identity information, so that each test caller adds the first data identifier to the first test request before sending the first test request;
[0072] Among them, after each test caller obtains the first data identifier assigned by the test service provider, when performing the coverage test later, the first data identifier can be added to the first test request, and then the first test request can be sent to the test service provider.
[0073] like Figure 5As shown, in one embodiment, respectively determining the code coverage of each first code coverage data to obtain the first code coverage corresponding to each first data identifier includes:
[0074] Step 501, respectively determining the executed code data and the total code data in each first code coverage data;
[0075] As mentioned above, in the first code coverage data, the executed code data is marked, so the executed code data can be obtained based on the mark, and the total code data is the original code data to be tested;
[0076] Step 502, determining a first code coverage rate corresponding to each first data identifier according to a ratio of each executed code data to the corresponding total code data;
[0077] Among them, determining the corresponding code coverage rate according to the quantity ratio is an efficient coverage analysis strategy, namely, the statement coverage analysis strategy (all executable statements in the source code are executed at least once, which is used to calculate the number of statements executed in the source code. The main purpose of statement coverage is to cover all possible paths, lines and statements in the source code);
[0078] Among them, if the executed code data includes 800 statements and the total code data includes 1000 statements, the corresponding quantity ratio is 800 / 1000, which is converted into a percentage to obtain the corresponding first code coverage: 80%.
[0079] The structure of the statement coverage analysis strategy is simple and can easily handle the test code data with a large amount of code.
[0080] In one embodiment, after the step of obtaining the first code coverage rate corresponding to each first data identifier, the code coverage testing method further includes:
[0081] Evaluate and analyze each first code coverage rate respectively to obtain a first coverage rate analysis report corresponding to each first code coverage rate;
[0082] Among them, the first code coverage rate obtained is only a percentage, and the relevant personnel cannot conduct in-depth analysis based on the percentage. In the testing service provider, due to the existence of various intermediate data, such as the first code coverage data, the specific composition of the first code coverage rate can be further analyzed, such as which part of the code has a lower coverage rate and which part of the code has a higher coverage rate, thereby obtaining a comprehensive first coverage rate analysis report. When the relevant personnel view the first coverage rate analysis report, they can very intuitively judge the quality of the code data to be tested.
[0083] like Figure 6As shown, in one embodiment, after the step of obtaining the first code coverage data corresponding to each first data identifier, the code coverage test method further includes:
[0084] Step 601, merging all first code coverage data to obtain second code coverage data;
[0085] Among them, this method is mainly used to implement a separate code coverage test for each code data to be tested in multiple code data to be tested, but the method is not limited to this, and can also perform an overall code coverage test on all code data to be tested; it can be aggregated to obtain an overall second code coverage rate. Specifically, the first data identifier can be ignored, and all the first code coverage data can be merged to obtain an overall second code coverage data;
[0086] Step 602, determining the code coverage rate of the second code coverage data, and obtaining a second code coverage rate corresponding to the second code coverage data;
[0087] Among them, since the second code coverage data is obtained by merging all the first code coverage data, the second code coverage rate obtained based on the second code coverage data is the overall code coverage rate corresponding to all the code data to be tested.
[0088] By performing individual tests and overall tests on the code data to be tested, multiple individual first code coverage rates and an overall second code coverage rate are obtained, so that relevant personnel can perform evaluation based on the first code coverage rate and the second code coverage rate at the same time, thereby improving evaluation efficiency.
[0089] In one embodiment, after the step of obtaining the second code coverage rate corresponding to the second code coverage data, the code coverage testing method further includes:
[0090] Evaluate and analyze the second code coverage to obtain a second coverage analysis report corresponding to the second code coverage;
[0091] The specific process of obtaining the second coverage analysis report may refer to the first coverage analysis report, which will not be repeated here.
[0092] Second, as Figure 7 As shown, in one embodiment, the present invention provides a code coverage testing device, comprising:
[0093] The request receiving module 701 is used to receive first test requests to be processed respectively sent by multiple test callers;
[0094] The data acquisition module 702 is used to respectively acquire the code data to be tested and the first data identifier of the code data to be tested in each first test request; the first data identifier is used to represent the identity information of the test caller, and each test caller has a unique first data identifier;
[0095] A code execution module 703 is used to execute code on each code data to be tested, and obtain first code coverage data corresponding to each first data identifier;
[0096] The first coverage module 704 is used to determine the code coverage of each first code coverage data respectively, and obtain the first code coverage corresponding to each first data identifier.
[0097] Through the above-mentioned code coverage testing device, after receiving multiple test requests from multiple test caller applications, the code coverage test of each code data to be tested is completed based on the corresponding data identifier by obtaining the data identifier in the test request, so that the code coverage rate of the code data to be tested corresponding to each test caller can be obtained respectively, and it can be accurately identified whether the end-to-end joint debugging test of any test caller is insufficiently covered, avoiding the risk of missed tests.
[0098] like Figure 7 As shown, in one embodiment, the above-mentioned code coverage testing device also includes:
[0099] The identification updating module 705 is used to obtain the identity of the current test service provider after the steps of respectively obtaining the code data to be tested and the first data identification of the code data to be tested in each test request, and obtain the second data identification of each code data to be tested according to the identity and the first data identification of each code data to be tested;
[0100] The request generating module 706 is used to generate a second test request corresponding to each second data identifier according to each code data to be tested and the second data identifier of each code data to be tested;
[0101] The request sending module 707 is used to send each second test request to the next-level test service provider, so that the next-level test service provider performs code coverage testing on the code data to be tested in each second test request.
[0102] In one embodiment, the identification updating module is specifically used to concatenate the identity identification with the first data identification of each code data to be tested, so as to obtain the second data identification of each code data to be tested.
[0103] like Figure 7 As shown, in one embodiment, the above-mentioned code coverage testing device also includes:
[0104] The identification generation module 708 is used to obtain the identity information of each test caller, and generate a first data identification corresponding to each identity information according to each identity information;
[0105] The identification sending module 709 is used to send each first data identification to the test caller corresponding to each identity information, so that each test caller adds the first data identification to the first test request before sending the first test request.
[0106] In one embodiment, the coverage module is specifically used to respectively determine the executed code data and the total code data in each first code coverage data; based on the ratio of the quantity of each executed code data to the corresponding total code data, the first code coverage corresponding to each first data identifier is determined.
[0107] In one embodiment, the code coverage testing device further includes:
[0108] The first analysis module is used to evaluate and analyze each first code coverage rate after obtaining the first code coverage rate corresponding to each first data identifier, so as to obtain a first coverage rate analysis report corresponding to each first code coverage rate.
[0109] like Figure 7 As shown, in one embodiment, the above-mentioned code coverage testing device also includes:
[0110] The second coverage module 710 is used to merge all the first code coverage data after the step of obtaining the first code coverage data corresponding to each first data identifier to obtain the second code coverage data; determine the code coverage of the second code coverage data to obtain the second code coverage corresponding to the second code coverage data.
[0111] In one embodiment, the code coverage testing device further includes:
[0112] The second analysis module is used to evaluate and analyze the second code coverage after the step of obtaining the second code coverage corresponding to the second code coverage data, and obtain a second coverage analysis report corresponding to the second code coverage.
[0113] In a third aspect, in one embodiment, the present invention provides a computer device, such as Figure 8 As shown, it shows the structure of the computer device involved in the present invention, specifically:
[0114] The computer device may include one or more processing core processors 801, one or more computer-readable storage media memories 802, a power supply 803, an input unit 804 and other components. Those skilled in the art will appreciate that Figure 8 The structure of the computer device shown in the figure does not constitute a limitation on the computer device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. Among them:
[0115] The processor 801 is the control center of the computer device. It uses various interfaces and lines to connect various parts of the entire computer device. By running or executing software programs and / or modules stored in the memory 802 and calling data stored in the memory 802, it executes various functions of the computer device and processes data, thereby monitoring the computer device as a whole. Optionally, the processor 801 may include one or more processing cores; preferably, the processor 801 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, computer program, etc., and the modem processor mainly processes wireless communication. It is understandable that the above-mentioned modem processor may not be integrated into the processor 801.
[0116] The memory 802 can be used to store software programs and modules. The processor 801 executes various functional applications and data processing by running the software programs and modules stored in the memory 802. The memory 802 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, a computer program required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the server, etc. In addition, the memory 802 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 802 may also include a memory controller to provide the processor 801 with access to the memory 802.
[0117] The computer device also includes a power supply 803 for supplying power to each component. Preferably, the power supply 803 can be logically connected to the processor 801 through a power management system, so that the power management system can manage charging, discharging, power consumption and other functions. The power supply 803 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators and other arbitrary components.
[0118] The computer device may further include an input unit 804, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0119] Although not shown, the computer device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 801 in the computer device will load the executable files corresponding to the processes of one or more computer programs into the memory 802 according to the following instructions, and the processor 801 will run the computer program stored in the memory 802 to perform the following steps:
[0120] Receiving first test requests to be processed respectively sent by multiple test callers;
[0121] Respectively obtain the code data to be tested and the first data identifier of the code data to be tested in each first test request; the first data identifier is used to represent the identity information of the test caller, and each test caller has a unique first data identifier;
[0122] Perform code execution on each code data to be tested respectively to obtain first code coverage data corresponding to each first data identifier;
[0123] The code coverage rate of each first code coverage data is determined respectively to obtain the first code coverage rate corresponding to each first data identifier.
[0124] Through the above-mentioned computer device, after receiving multiple test requests from multiple test caller applications, the code coverage test of each code data to be tested is completed based on the corresponding data identifier by obtaining the data identifier in the test request, so that the code coverage rate of the code data to be tested corresponding to each test caller can be obtained respectively, and it is possible to accurately identify whether the end-to-end joint debugging test of any test caller is insufficiently covered, thereby avoiding the risk of missed tests.
[0125] A person of ordinary skill in the art will appreciate that all or part of the steps in any of the methods of the above embodiments may be completed by a computer program, or by controlling related hardware through a computer program. The computer program may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0126] In a fourth aspect, in one embodiment, the present invention provides a storage medium storing a plurality of computer programs, wherein the computer programs can be loaded by a processor to perform the following steps:
[0127] Receiving first test requests to be processed respectively sent by multiple test callers;
[0128] Respectively obtain the code data to be tested and the first data identifier of the code data to be tested in each first test request; the first data identifier is used to represent the identity information of the test caller, and each test caller has a unique first data identifier;
[0129] Perform code execution on each code data to be tested respectively to obtain first code coverage data corresponding to each first data identifier;
[0130] The code coverage rate of each first code coverage data is determined respectively to obtain the first code coverage rate corresponding to each first data identifier.
[0131] Through the above-mentioned storage medium, after receiving multiple test requests from multiple test caller applications, the code coverage test of each code data to be tested is completed based on the corresponding data identifier by obtaining the data identifier in the test request, so that the code coverage rate of the code data to be tested corresponding to each test caller can be obtained respectively, and it is possible to accurately identify whether the end-to-end joint debugging test of any test caller is insufficiently covered, thereby avoiding the risk of missed tests.
[0132] It will be appreciated by those skilled in the art that any reference to memory, storage, database or other medium used in the embodiments provided by the present invention may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0133] Since the computer program stored in the storage medium can execute the steps in the code coverage testing method in any embodiment provided in the present invention, the beneficial effects that can be achieved by the code coverage testing method in any embodiment provided in the present invention can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0134] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0135] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the detailed description of other embodiments above, and will not be repeated here.
[0136] The above is a detailed introduction to a code coverage testing method, device, computer equipment and storage medium provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for technical personnel in this field, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
[0137] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
Claims
1. A code coverage testing method, characterized in that: include; Receiving first test requests to be processed respectively sent by multiple test callers; Respectively obtain the code data to be tested and the first data identifier of the code data to be tested in each of the first test requests; The first data identifier is used to represent the identity information of the test caller, and each of the test callers has a unique first data identifier; Perform code execution on each of the code data to be tested respectively to obtain first code coverage data corresponding to each of the first data identifiers; Determine the code coverage rate of each of the first code coverage data respectively, and obtain the first code coverage rate corresponding to each of the first data identifiers; After the step of respectively obtaining the code data to be tested and the first data identifier of the code data to be tested in each of the first test requests, the method further includes: Get the identity of the current testing service provider; Obtaining a second data identifier of each of the code data to be tested according to the identity identifier and the first data identifier of each of the code data to be tested; According to each of the code data to be tested and the second data identifier of each of the code data to be tested, generating a second test request corresponding to each of the second data identifiers; Sending each of the second test requests to a next-level test service provider, so that the next-level test service provider performs code coverage testing on the code data to be tested in each of the second test requests; Before the step of receiving first test requests to be processed respectively sent by a plurality of test callers, the method further includes: Obtaining identity information of each of the test callers; According to each piece of identity information, generate a first data identifier corresponding to each piece of identity information; Each of the first data identifiers is sent to a test caller corresponding to each of the identity information, so that each of the test callers adds the first data identifier to the first test request before sending the first test request.
2. The code coverage testing method according to claim 1, characterized in that: The step of obtaining the second data identifier of each of the code data to be tested according to the identity identifier and the first data identifier of each of the code data to be tested comprises: The identity identifier is respectively concatenated with the first data identifier of each of the code data to be tested to obtain the second data identifier of each of the code data to be tested.
3. The code coverage testing method according to claim 1, characterized in that: The respectively determining the code coverage rate of each of the first code coverage data to obtain the first code coverage rate corresponding to each of the first data identifiers includes: respectively determining the executed code data and the total code data in each of the first code coverage data; According to the ratio of each executed code data to the corresponding total code data, a first code coverage rate corresponding to each first data identifier is determined.
4. The code coverage testing method according to any one of claims 1 to 3, characterized in that: After the step of obtaining the first code coverage rate corresponding to each of the first data identifiers, the method further includes: Each of the first code coverage rates is evaluated and analyzed respectively to obtain a first coverage rate analysis report corresponding to each of the first code coverage rates.
5. The code coverage testing method according to any one of claims 1 to 3, characterized in that: After the step of obtaining the first code coverage data corresponding to each of the first data identifiers, the method further includes: Merging all the first code coverage data to obtain second code coverage data; Determine the code coverage rate of the second code coverage data, and obtain a second code coverage rate corresponding to the second code coverage data.
6. The code coverage testing method according to claim 5, characterized in that: After the step of obtaining the second code coverage rate corresponding to the second code coverage data, the method further includes: The second code coverage is evaluated and analyzed to obtain a second coverage analysis report corresponding to the second code coverage.
7. A computer device, characterized in that: It comprises a memory and a processor; the memory stores a computer program, and the processor is used to run the computer program in the memory to execute the steps in the code coverage testing method according to any one of claims 1 to 6.
8. A storage medium, characterized in that: The storage medium stores a computer program, and the computer program is loaded by a processor to execute the steps in the code coverage testing method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Request message processing method and apparatus, storage medium, processor and terminal
CN107707644A
Method, system and equipment for calling open interface service
CN110008691A