Test coverage statistics methods, devices, equipment, media and products
By updating the configuration information of the host application and collecting test coverage metadata, the problem of low statistical accuracy of SDK test coverage is solved, and accurate measurement and comprehensive evaluation of SDK test coverage is achieved.
Patent Information
- Application Number
- CN202411609763.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-12
- Publication Date
- 2025-04-01
AI Technical Summary
It is difficult for the prior art to accurately count the test coverage of SDKs that cannot be deployed independently, resulting in low statistical accuracy.
By obtaining the configuration information of the software development toolkit, update the configuration information of the host application, including the instrumentation range, collecting and merging test coverage metadata, and generating the test coverage report of the SDK.
It realizes accurate measurement of SDK test coverage, supports summary statistics of SDK test coverage data that depend on different deployment methods and multiple applications, and improves the comprehensive evaluation of test results.
Smart Images

Figure CN119739624A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of software testing technology, and in particular to test coverage statistics methods, devices, equipment, media and products. Background Art
[0002] Testing is the last step before software enters the production environment. Counting the test coverage of applications during runtime is a mainstream way to verify whether the test is sufficient and complete. Currently, mainstream applications are divided into SDKs (Software Development Kits) that cannot be deployed independently and applications that can be deployed independently, where the SDK is deployed together with the host application. Most of the mainstream test coverage collection solutions in the industry are only for applications that can be deployed independently, and there is a serious lack of support for SDKs that cannot be deployed independently, resulting in low accuracy in SDK test coverage statistics. Summary of the invention
[0003] The main purpose of this application is to provide a test coverage statistics method, device, equipment, medium and product, aiming to improve the accuracy of SDK test coverage statistics.
[0004] To achieve the above objectives, this application proposes a test coverage statistics method, including:
[0005] Obtain preset software development kit configuration information, and update host application configuration information according to the software development kit configuration information, wherein the host application is an application program installed with the software development kit, the host application configuration information includes a host application instrumentation range, the host application instrumentation range includes a software development kit instrumentation range, and the software development kit configuration information includes the latest software development kit instrumentation range;
[0006] Collecting application test coverage metadata of the host application according to the updated host application configuration information, and generating an application test coverage metadata file according to the application test coverage metadata, wherein the application test coverage metadata includes the test coverage metadata of the host application and the test coverage metadata of the software development kit;
[0007] All application test coverage metadata files are merged into a total test coverage metadata file, and a software development kit test coverage report is generated according to the total test coverage metadata file.
[0008] In one embodiment, the step of collecting application test coverage metadata of the host application according to the updated host application configuration information, and generating an application test coverage metadata file according to the application test coverage metadata further includes:
[0009] Run the preset test coverage tool, and use the running test coverage tool to instrument the running host application and obtain instrumentation data according to the updated host application instrumentation range;
[0010] The instrumentation data is used as application test coverage metadata, and the application test coverage metadata is converted into a format to generate a test coverage metadata file.
[0011] In one embodiment, before the step of running a preset test coverage tool, the following steps are included:
[0012] Determine the deployment method of the host application. If the deployment method is to use a virtual machine to deploy the host application, download the test coverage tool from the preset tool library.
[0013] In one embodiment, after the step of determining the deployment mode of the host application, the following steps are included:
[0014] If the deployment method is to use a container environment to deploy the host application, an instruction for injecting the test coverage tool is inserted into the preset container configuration file.
[0015] In one embodiment, the step of merging all application test coverage metadata files into a total test coverage metadata file includes:
[0016] Upload the application test coverage metadata file to the preset file management service;
[0017] The step of merging all application test coverage metadata files into a total test coverage metadata file also includes:
[0018] All application test coverage metadata files are downloaded from the file management service, and the application test coverage metadata files are merged into a total test coverage metadata file through a preset metadata merging task processor.
[0019] In one embodiment, the step of generating a software development kit test coverage report according to the total test coverage metadata file includes:
[0020] Read the coverage data in the total test coverage metadata file, establish a code coverage mapping between the coverage data and the source code of the software development kit, and generate a test coverage report based on the code coverage mapping;
[0021] Filter the test coverage report according to the software development kit configuration information to obtain the software development kit test coverage report, wherein the software development kit test coverage report includes the software development kit interface coverage report, the software development kit incremental code coverage report, and the software development kit full code coverage report;
[0022] The steps for generating a SDK test coverage report based on the total test coverage metadata file also include:
[0023] The software development kit test coverage report is uploaded to a preset coverage collection service through the metadata merging task processor, and the coverage collection service stores the software development kit test coverage report in a preset database.
[0024] In addition, to achieve the above purpose, the present application also proposes a test coverage statistics device, the test coverage statistics device comprising:
[0025] A synchronous update module obtains preset software development kit configuration information, and updates the host application configuration information according to the software development kit configuration information, wherein the host application is an application program installed with the software development kit, the host application configuration information includes the host application instrumentation range, the host application instrumentation range includes the software development kit instrumentation range, and the software development kit configuration information includes the latest software development kit instrumentation range;
[0026] A data collection module collects application test coverage metadata of the host application according to the updated host application configuration information, and generates an application test coverage metadata file according to the application test coverage metadata, wherein the application test coverage metadata includes the test coverage metadata of the host application and the test coverage metadata of the software development kit;
[0027] Generate a file module, merge all application test coverage metadata files into a total test coverage metadata file, and generate a software development kit test coverage report based on the total test coverage metadata file.
[0028] In addition, to achieve the above-mentioned purpose, the present application also proposes a test coverage statistics device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, and the computer program is configured to implement the steps of the test coverage statistics method as described above.
[0029] In addition, to achieve the above-mentioned purpose, the present application also proposes a medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the test coverage statistics method as described above are implemented.
[0030] In addition, to achieve the above-mentioned purpose, the present application also provides a product, which is a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the steps of the test coverage statistics method as described above are implemented.
[0031] One or more technical solutions proposed in this application have at least the following technical effects:
[0032] This application obtains preset software development kit configuration information and updates the host application configuration information according to the software development kit configuration information, wherein the host application is an application program installed with the software development kit, the host application configuration information includes the host application instrumentation range, the host application instrumentation range includes the software development kit instrumentation range, the software development kit configuration information includes the latest software development kit instrumentation range, and by updating the host application configuration information, the test coverage data of the host application and the SDK can be collected at the same time. The application test coverage metadata of the host application is collected according to the updated host application configuration information, and an application test coverage metadata file is generated according to the application test coverage metadata, wherein the application test coverage metadata includes the test coverage metadata of the host application and the test coverage metadata of the software development kit, thereby realizing the dynamic collection and flexible configuration of the test coverage metadata of the SDK in the host application of different deployment modes, and supporting the summary statistics of the test coverage data of the SDK dependent on multiple applications; all the application test coverage metadata files are merged into a total test coverage metadata file, and a software development kit test coverage report is generated according to the total test coverage metadata file. This process realizes the accurate measurement of the SDK test coverage, which is helpful to comprehensively evaluate the testing effect of the SDK. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0034] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0035] Figure 1 This is a flow chart of the first embodiment of the test coverage statistics method of the present application;
[0036] Figure 2 A schematic diagram of the process of testing coverage statistics method for this application;
[0037] Figure 3 This is another process diagram of the test coverage statistics method of this application;
[0038] Figure 4 This is another process diagram of the test coverage statistics method of this application;
[0039] Figure 5 This is a system architecture diagram of the test coverage statistics method for this application;
[0040] Figure 6 This is a schematic diagram of the module structure of the test coverage statistics device according to the embodiment of the present application;
[0041] Figure 7 This is a schematic diagram of the device structure of the hardware operating environment involved in the test coverage statistics method in the embodiment of the present application.
[0042] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0043] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0044] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0045] The shortcomings of traditional test coverage for SDKs that cannot be deployed independently include the following aspects:
[0046] 1) Lack of support for collecting SDK runtime test coverage metadata for applications attached to different deployment methods (virtual machines, containers, etc.).
[0047] 2) There is a lack of statistical aggregation function for SDK runtime test coverage data that depends on multiple applications.
[0048] 3) There is a lack of test coverage measurement data reports for the SDK's full code and incremental code.
[0049] Based on the existing application runtime test coverage system, this application implements SDK code instrumentation by adjusting the host application's instrumentation range, thereby realizing the collection and statistics of SDK test coverage. A method for obtaining application runtime test coverage data using the open source tool JaCoCo and bytecode injection technology. At the same time, a configuration file is provided to dynamically adjust the bytecode injection range. By adding the SDK's code instrumentation range to the host application's code instrumentation range, the SDK can perform test coverage data statistics together with the host application. Specifically, it includes the following features:
[0050] 1) Supports SDK to collect test coverage metadata for host applications in different deployment modes (virtual machines, container environments).
[0051] 2) You can flexibly select host applications and automatically aggregate the test coverage data of the SDK in these host applications.
[0052] 3) Leverage the capabilities of the existing application runtime test coverage system to generate coverage reports.
[0053] With the help of the above features, dynamic collection and statistics of SDK runtime test coverage are realized. When triggering collection, users can flexibly select which SDKs in the application need to be counted in the test coverage, thereby achieving highly customized configuration. In addition, this process has no impact on the ongoing test coverage behavior of the host application itself, ensuring that the two can be carried out at the same time.
[0054] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, a terminal system, etc. The following takes the test coverage statistics system (hereinafter referred to as the system) as an example to illustrate this embodiment and the following embodiments.
[0055] Based on this, this embodiment provides a test coverage statistics method, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the test coverage statistics method of the present application. The test coverage statistics method includes steps S10 to S30:
[0056] Step S10, obtaining preset software development kit configuration information, and updating the host application configuration information according to the software development kit configuration information, wherein the host application is an application program installed with the software development kit, the host application configuration information includes a host application instrumentation range, the host application instrumentation range includes a software development kit instrumentation range, and the software development kit configuration information includes the latest software development kit instrumentation range;
[0057] It should be noted that a software development kit (SDK) is a toolkit or library used by software developers to build a specific set of functions for an application or software. In this context, the software development kit is the target that requires test coverage measurement. The host application refers to the application that has the software development kit installed. The software development kit is deployed with the host application and provides it with additional functions or services. The instrumentation range refers to the code range used to collect test coverage data when executing the code. For the software development kit, the software development kit instrumentation range includes all the code parts that need to be tested. The software development kit configuration information includes the configuration of information such as the software development kit instrumentation range, which is used to guide how to instrument the software development kit to collect test coverage data. The host application configuration information includes the configuration of information such as the host application instrumentation range, wherein the host application instrumentation range includes the software development kit instrumentation range to ensure that the test coverage data of the software development kit can be collected.
[0058] First, obtain the configuration information of the SDK from a preset source (such as a configuration file, a database, etc.), which includes the scope of the SDK plug-in. Then, according to the configuration information of the SDK, update the configuration information of the host application to ensure that when the SDK configuration information is updated, the scope of the host application plug-in can be updated synchronously. In this embodiment, the software development kit is released through the pipeline CI (Continuous Integration) platform, which is also responsible for the synchronous update of the SDK and the host application plug-in scope, and it will detect any update operation on the SDK configuration information. The pipeline CI platform runs continuously, and it constantly checks whether the SDK configuration information has changed. The update of the SDK configuration information may be due to the developer's adjustment of the SDK plug-in scope, or because the SDK itself has been updated. When an update is detected, the pipeline CI platform will obtain the latest SDK configuration information. This information may come from a version control system, a configuration server, or other systems that store configuration information. After obtaining the updated SDK configuration information, the pipeline CI platform will update the configuration information of the host application according to this new information. Specifically, the host app's instrumentation scope will be updated to include the SDK's new instrumentation scope.
[0059] After updating the host application configuration information, the host application will apply these new configurations the next time it runs. This means that if there are any new code areas that need to be monitored, or if there are any code areas that no longer need to be monitored (including host application and SDK areas), these changes will be reflected when the host application runs.
[0060] For example, refer to Figure 2 The pipeline CI platform in the system will release the software development kit so that the application can install the software development kit. After the software development kit is released, multiple applications install the software development kit, becoming host application A, host application B, and host application C. Configure test coverage for each host application, configure test coverage for the software development kit and synchronize it to each host application. Similarly, the system must automatically identify or the user manually configures the instrumentation range of the software development kit, and synchronize the instrumentation range of all host applications with the instrumentation range of the software development kit.
[0061] This embodiment ensures that the test coverage data collection of the host application is always synchronized with the latest configuration of the SDK, thereby improving the accuracy and reliability of the test coverage data. This automated configuration update mechanism reduces errors and omissions in manual configuration updates and improves development efficiency.
[0062] Step S20, collecting application test coverage metadata of the host application according to the updated host application configuration information, and generating an application test coverage metadata file according to the application test coverage metadata, wherein the application test coverage metadata includes the test coverage metadata of the host application and the test coverage metadata of the software development kit;
[0063] It should be noted that the application test coverage metadata is data collected during the testing process about the test coverage of the application (including SDK), such as which code lines, branches, methods, etc. were tested.
[0064] According to the updated host application configuration information, use the existing test coverage collection tool (such as JaCoCo) to test the host application and collect test coverage metadata. These metadata include the test coverage data of the SDK, because the SDK's instrumentation range has been included in the host application's instrumentation range. Then, save these metadata as an application test coverage metadata file. The test coverage collection tool collects test coverage data by inserting "stubs" (that is, additional code used to record test coverage) into the code and recording which stubs are triggered during the test process.
[0065] Step S30: All application test coverage metadata files are merged into a total test coverage metadata file, and a software development kit test coverage report is generated according to the total test coverage metadata file.
[0066] It should be noted that the total test coverage metadata file is a file obtained by merging the application test coverage metadata files of all host applications, and contains the test coverage data of the SDK in all host applications. The software development kit test coverage report is a report generated based on the total test coverage metadata file, which is used to display the test coverage of the SDK, including the coverage of the full code and incremental code.
[0067] The application test coverage metadata files of all host applications are merged into a total test coverage metadata file. Then, a test coverage report generation tool (which may be based on an existing test coverage system) is used to generate a test coverage report for the SDK based on the total test coverage metadata file.
[0068] This application obtains preset software development kit configuration information, and updates the host application configuration information according to the software development kit configuration information, wherein the host application is an application program installed with the software development kit, the software development kit configuration information includes the software development kit plug-in range, the host application configuration information includes the host application plug-in range, and the host application plug-in range includes the software development kit plug-in range. By updating the configuration information of the host application, the test coverage data of the host application and the SDK can be collected at the same time. The application test coverage metadata of the host application is collected according to the updated host application configuration information, and an application test coverage metadata file is generated according to the application test coverage metadata, wherein the application test coverage metadata includes the test coverage metadata of the software development kit, which realizes the dynamic collection and flexible configuration of the test coverage metadata of the SDK in the host application of different deployment methods, and supports the summary statistics of the SDK test coverage data dependent on multiple applications; all application test coverage metadata files are merged into a total test coverage metadata file, and a software development kit test coverage report is generated according to the total test coverage metadata file. This process realizes the accurate measurement of the SDK test coverage, which is helpful to comprehensively evaluate the test effect of the SDK.
[0069] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the first embodiment can be referred to the above introduction, and will not be repeated hereafter. On this basis, the steps of step S10 also include steps A10 to A20:
[0070] Step A10, running a preset test coverage tool, and according to the updated host application instrumentation range, using the running test coverage tool to instrument the running host application and obtain instrumentation data;
[0071] It should be noted that the test coverage tool is a software tool used to monitor and record code coverage during application execution to evaluate the integrity of the test. Instrumentation is the insertion of additional code into the source code or bytecode of an application to collect coverage data at runtime. The host application instrumentation scope is used to specify which parts of the host application code need to be instrumented to collect test coverage data. Based on the configuration information of the host application, the test coverage tool is started. This tool will instrument the running host application according to the updated host application instrumentation scope. Instrumentation is achieved by injecting additional code into the host application code, which records coverage data when the host application is executed.
[0072] According to the configuration information of the host application, the test coverage tool is started. This tool will insert the running host application according to the updated host application insertion range. Insertion is achieved by injecting additional code into the code of the host application, which records coverage data when the host application is executed. This embodiment supports running the test coverage tool in host applications deployed in a variety of different ways.
[0073] Step A20: Use the instrumentation data as application test coverage metadata, convert the format of the application test coverage metadata, and generate a test coverage metadata file.
[0074] It should be noted that the instrumentation data is the data collected during the instrumentation process, which records the code execution and is used to generate the test coverage report. The test coverage metadata file is a file that stores the instrumentation data and contains the coverage information when the application is executed. The file management service is a service for storing and managing files, allowing files to be uploaded, downloaded, and organized.
[0075] After instrumentation is completed, the test coverage tool will collect instrumentation data. This data records in detail which code is executed and which is not executed during the execution of the host application. The collected instrumentation data is used as application test coverage metadata, and the application test coverage metadata is converted into a format to generate a test coverage metadata file. These files are standardized and can be read and processed by other tools and systems.
[0076] This embodiment runs a test coverage tool to instrument the host application, collect instrumentation data, and transfer the instrumentation data, thereby ensuring that the test coverage data of the host application can be accurately collected, and providing a basis for subsequent code quality analysis and test optimization.
[0077] In a feasible implementation manner, step A10 further includes step B10:
[0078] Step B10, determining the deployment mode of the host application. If the deployment mode is to use a virtual machine to deploy the host application, downloading a test coverage tool from a preset tool library.
[0079] It should be noted that virtual machine deployment is to deploy the host application on the virtual machine. The virtual machine simulates the complete hardware system and allows the application to run in an isolated environment.
[0080] When the host application is deployed on a virtual machine, the test coverage tool needs to be downloaded inside the virtual machine. The download process may involve obtaining the installation package of the tool from the official website or tool repository and executing the installation script or program on the virtual machine.
[0081] In a feasible implementation manner, step B10 further includes step B20:
[0082] Step B20: If the deployment method is to use a container environment to deploy the host application, an instruction for injecting a test coverage tool is inserted into a preset container configuration file.
[0083] It should be noted that container environment deployment is to deploy the host application in the container. The container provides a lightweight isolated environment and shares the host operating system kernel. The container configuration file refers to the configuration file that defines the container behavior and environment, such as Dockerfile, which is used to build and configure the container image. The injection command is a command added to the container configuration file to automatically perform specific operations when the container starts, such as installing or starting the test coverage tool.
[0084] When the host application is deployed in a container environment, the command to inject the test coverage tool needs to be inserted into the container's configuration file. This is usually achieved in the Dockerfile by adding instructions such as RUN, which is executed when the container image is built to install the test coverage tool or include it as a dependency. After adding the injection command in the container configuration file, the test coverage tool will be automatically installed and configured when the container image is built and run. This approach tightly integrates the configuration of the test coverage tool with the deployment process of the host application, ensuring consistency and repeatability in the containerized environment.
[0085] For example, for host applications with different deployment methods, the difference in the application test coverage metadata collection process is only the different ways of starting the test coverage tool. For virtual machines, it depends on downloading and starting the agent program before deployment. For container environments, the command to inject the agent program is inserted into the Dockerfile, and the environment variable JAVA_TOOL_OPTIONS is added to the deployment yaml file to achieve the purpose of starting the javaagent to start the test coverage tool.
[0086] In this embodiment, by adopting different configuration methods according to different deployment environments (virtual machines or containers), this embodiment provides a flexible and adaptable test coverage tool configuration strategy. This strategy ensures that test coverage data can be effectively collected regardless of the environment in which the host application is deployed.
[0087] In a feasible implementation manner, step S30 further includes step C10:
[0088] Step C10, uploading the application test coverage metadata file to a preset file management service;
[0089] For host applications with different deployment methods (virtual machines, container environments), after using the test coverage tool to collect test coverage metadata and generate test coverage metadata files, the test coverage tools in each host application will upload their respective test coverage metadata files to the preset file management service.
[0090] For example, refer to Figure 3 After the host application has configured the test coverage tool (agent and configuration file), the agent is started through javaagent to perform runtime instrumentation on the host application to achieve source code level non-intrusion. The instrumentation range can be configured through the configuration file, and the range will cover the relevant code of the SDK. The instrumentation data is transferred to exec format metadata by executing the JaCoCo dump instruction (dump), and the metadata is uploaded to the file management service.
[0091] In a feasible implementation manner, step S30 further includes step C20 :
[0092] Step C20, downloading all application test coverage metadata files from the file management service, and merging the application test coverage metadata files into a total test coverage metadata file through a preset metadata merging task processor.
[0093] First, the system needs to download all relevant application test coverage metadata files from the file management service. These files contain the coverage data collected by each host application during the test process. The download process may involve using the API or command line tools provided by the file management service to specify the list of files to download.
[0094] After the download is complete, the system will use the metadata merge task processor, which may be a specific tool or script, to merge all the downloaded application test coverage metadata files into a total test coverage metadata file. The merging process involves integrating the coverage data scattered in multiple files into a unified file for overall analysis. The metadata merge task processor needs to be able to identify and process the coverage data formats in different files to ensure that the merged file can accurately reflect the test coverage of all host applications. After the merger is completed, the generated total test coverage metadata file contains the test coverage data of all host applications. This file can be further used to generate detailed test coverage reports to help developers and testers understand the test coverage of the entire system. The total test coverage metadata file is the basis for generating test coverage reports. The report can include various statistics and visualization charts, such as coverage percentage, uncovered code areas, etc. These reports are essential for evaluating the effectiveness of testing and guiding future testing efforts.
[0095] Through this process, this embodiment ensures that test coverage data can be collected and integrated from distributed host applications, providing support for comprehensive evaluation and improvement of software quality.
[0096] Based on the first or second embodiment of the present application, in the third embodiment of the present application, the same or similar contents as those in the first or second embodiment can be referred to the above introduction, and will not be described in detail later. Figure 2 , Figure 2 This is a flow chart of the third implementation of the test coverage statistics method of the present application. Step S30 also includes steps D10 to D20:
[0097] Step D10, reading the coverage data in the total test coverage metadata file, and establishing a code coverage mapping between the coverage data and the source code of the software development kit, and generating a test coverage report according to the code coverage mapping;
[0098] It should be noted that coverage data refers to data collected during the software testing process, which reflects which parts of the code have been executed. Code coverage mapping is a mapping relationship that associates coverage data with the source code of the SDK to facilitate understanding of which code is covered by the test. Test coverage report is a document that summarizes the results of code coverage mapping and provides detailed information about the SDK test coverage.
[0099] Extract coverage data from the total test coverage metadata file. This data is collected when the host application runs tests and records the execution of the SDK code. Using the coverage data, build a map that associates each code execution event with the SDK source code line. This map is the basis for understanding code coverage. Based on the code coverage map, generate a comprehensive test coverage report. The report details which code is executed and which is not, providing an overview of code coverage.
[0100] Step D20, filter the test coverage report according to the software development kit configuration information to obtain the software development kit test coverage report, wherein the software development kit test coverage report includes the software development kit interface coverage report, the software development kit incremental code coverage report, and the software development kit full code coverage report.
[0101] It should be noted that the SDK interface coverage report is part of the test coverage report, focusing on the test coverage of the SDK interfaces. The SDK incremental code coverage report is part of the test coverage report, focusing on the test coverage of the new code added to the SDK since the last release. The SDK full code coverage report is part of the test coverage report, providing the test coverage of all SDK codes.
[0102] Use the SDK configuration information to filter the test coverage report and extract the parts related to the SDK. This step ensures that the report focuses on the test coverage of the SDK. From the filtered reports, generate different types of SDK test coverage reports, including interface coverage reports, incremental code coverage reports, and full code coverage reports. The interface coverage report focuses on the testing of the interfaces defined in the SDK. The incremental code coverage report focuses on the newly added code parts, which is useful for evaluating the testing of new features. The full code coverage report provides a comprehensive view of the test coverage of all SDK codes.
[0103] Exemplary, reference Figure 4 , download the coverage metadata files of host application A, host application B, and host application C, use the first script, such as the merge command provided by JaCoCo, to merge the metadata files of multiple host applications into one file, use the second script, such as the report command of JaCoCo, combine the merged metadata file with the SDK build product, and save it as an XML report. Use the capabilities of existing services to save it into coverage reports in different formats, such as generating SDK API coverage, incremental code coverage, full code coverage, and other coverage reports.
[0104] The step S30 further includes a step D30:
[0105] Step D20 , uploading the software development kit test coverage report to a preset coverage collection service through the metadata merging task processor, and the coverage collection service stores the software development kit test coverage report in a preset database.
[0106] It should be noted that the coverage collection service is a service or system used to receive, process and store test coverage reports for subsequent analysis and evaluation.
[0107] The metadata merge task processor uploads the merged SDK test coverage report to the coverage collection service. This service is a system designed specifically to receive and process test coverage reports. It receives the report from the processor and performs further processing on it, such as verifying the integrity of the report, parsing the report content, etc. The coverage collection service then stores the processed SDK test coverage report in a preset database. This database is pre-configured for storing and managing test coverage data. Storing the report in the database facilitates subsequent analysis and evaluation work, such as generating test coverage statistics charts, identifying uncovered code areas, etc.
[0108] Exemplary, reference Figure 5 , Figure 5 The overall system architecture of this application is shown. The pipeline CI platform in the system is responsible for saving the coverage SDK toolkit configuration information to the MySQL database, and synchronously updating the host application plug-in scope, as well as publishing the application dependency SDK toolkit, and injecting the coverage agent (test coverage tool). The application cluster contains multiple host applications (host application A, host application B, host application C), and the host application uploads the coverage metadata to the file management service. The metadata merge task processing cluster downloads the coverage metadata file from the file management service. The coverage collection service uploads the coverage results in the form of an XML file. The coverage collection service stores the test coverage results in the MongoDB database.
[0109] This embodiment can provide developers with a detailed and organized view of SDK test coverage, helping them identify untested code areas, thereby improving software quality and testing efficiency.
[0110] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the test coverage statistics method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0111] This application also provides a test coverage statistics device, please refer to Figure 6 , the test coverage statistics device includes:
[0112] The synchronous update module 10 obtains preset software development kit configuration information, and updates the host application configuration information according to the software development kit configuration information, wherein the host application is an application program installed with the software development kit, the host application configuration information includes the host application instrumentation range, the host application instrumentation range includes the software development kit instrumentation range, and the software development kit configuration information includes the latest software development kit instrumentation range;
[0113] A data collection module 20 collects application test coverage metadata of the host application according to the updated host application configuration information, and generates an application test coverage metadata file according to the application test coverage metadata, wherein the application test coverage metadata includes the test coverage metadata of the host application and the test coverage metadata of the software development kit;
[0114] The file generating module 30 merges all application test coverage metadata files into a total test coverage metadata file, and generates a software development kit test coverage report according to the total test coverage metadata file.
[0115] The test coverage statistics device provided by the present application adopts the test coverage statistics method in the above embodiment, which can improve the accuracy of SDK test coverage statistics. Compared with the prior art, the beneficial effects of the test coverage statistics device provided by the present application are the same as the beneficial effects of the test coverage statistics method provided by the above embodiment, and other technical features in the test coverage statistics device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0116] The present application provides a test coverage statistics device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the test coverage statistics method in the above-mentioned embodiment one.
[0117] Reference below Figure 7 , which shows a schematic diagram of the structure of a test coverage statistics device suitable for implementing the embodiment of the present application. The test coverage statistics device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The test coverage statistics device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0118] like Figure 7As shown, the test coverage statistics device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the test coverage statistics device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the test coverage statistics device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows a test coverage statistics device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or provided instead.
[0119] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0120] The test coverage statistics device provided by the present application adopts the test coverage statistics method in the above embodiment to improve the accuracy of SDK test coverage statistics. Compared with the prior art, the beneficial effects of the test coverage statistics device provided by the present application are the same as the beneficial effects of the test coverage statistics method provided by the above embodiment, and the other technical features in the test coverage statistics device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0121] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0122] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0123] The present application provides a medium, which is a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the test coverage statistics method in the above-mentioned embodiment.
[0124] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM: Random Access Memory), a read-only memory (ROM: Read Only Memory), an erasable programmable read-only memory (EPROM: Erasable Programmable Read Only Memory or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM: CD-Read Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency: Radio Frequency), etc., or any suitable combination of the above.
[0125] The computer-readable storage medium may be included in the test coverage statistics device; or may exist independently without being assembled into the test coverage statistics device.
[0126] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by the test coverage statistics device, the test coverage statistics device:
[0127] Obtain preset software development kit configuration information, and update host application configuration information according to the software development kit configuration information, wherein the host application is an application program installed with the software development kit, the host application configuration information includes a host application instrumentation range, the host application instrumentation range includes a software development kit instrumentation range, and the software development kit configuration information includes the latest software development kit instrumentation range;
[0128] Collecting application test coverage metadata of the host application according to the updated host application configuration information, and generating an application test coverage metadata file according to the application test coverage metadata, wherein the application test coverage metadata includes the test coverage metadata of the host application and the test coverage metadata of the software development kit;
[0129] All application test coverage metadata files are merged into a total test coverage metadata file, and a software development kit test coverage report is generated according to the total test coverage metadata file.
[0130] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0131] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0132] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0133] The readable storage medium provided in this application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned test coverage statistics method, and can improve the accuracy of SDK test coverage statistics. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as the beneficial effects of the test coverage statistics method provided in the above-mentioned embodiment, and will not be repeated here.
[0134] The present application also provides a product, which is a computer program product, including a computer program, and when the computer program is executed by a processor, the steps of the test coverage statistics method as described above are implemented.
[0135] The computer program product provided by this application can improve the accuracy of SDK test coverage statistics. Compared with the prior art, the beneficial effects of the computer program product provided by this application are the same as the beneficial effects of the test coverage statistics method provided by the above embodiment, which will not be repeated here.
[0136] The above are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect application in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A test coverage statistics method, characterized in that: The test coverage statistical method comprises: Obtaining preset software development kit configuration information, and updating host application configuration information according to the software development kit configuration information, wherein the host application is an application program installed with a software development kit, the host application configuration information includes a host application instrumentation range, the host application instrumentation range includes a software development kit instrumentation range, and the software development kit configuration information includes the latest software development kit instrumentation range; Collecting application test coverage metadata of the host application according to the updated host application configuration information, and generating an application test coverage metadata file according to the application test coverage metadata, wherein the application test coverage metadata includes test coverage metadata of the host application and test coverage metadata of the software development kit; All of the application test coverage metadata files are merged into a total test coverage metadata file, and a software development kit test coverage report is generated according to the total test coverage metadata file.
2. The test coverage statistics method according to claim 1, characterized in that: The step of collecting the application test coverage metadata of the host application according to the updated host application configuration information, and generating an application test coverage metadata file according to the application test coverage metadata also includes: Running a preset test coverage tool, and according to the updated host application instrumentation range, using the running test coverage tool to instrument the running host application and obtain instrumentation data; The instrumentation data is used as the application test coverage metadata, and the application test coverage metadata is format-converted to generate a test coverage metadata file.
3. The test coverage statistics method according to claim 2, characterized in that: Before the step of running the preset test coverage tool, the method includes: Determine the deployment mode of the host application. If the deployment mode is to deploy the host application using a virtual machine, download a test coverage tool from a preset tool library.
4. The test coverage statistics method according to claim 3, characterized in that: After the step of determining the deployment mode of the host application, the following steps are included: If the deployment method is to use a container environment to deploy the host application, an instruction for injecting the test coverage tool is inserted into a preset container configuration file.
5. The test coverage statistics method according to claim 1, characterized in that: The step of merging all the application test coverage metadata files into a total test coverage metadata file includes: Uploading the application test coverage metadata file to a preset file management service; The step of merging all the application test coverage metadata files into a total test coverage metadata file also includes: All the application test coverage metadata files are downloaded from the file management service, and the application test coverage metadata files are merged into a total test coverage metadata file through a preset metadata merging task processor.
6. The test coverage statistics method according to claim 5, characterized in that: The step of generating a software development kit test coverage report according to the total test coverage metadata file comprises: Reading coverage data in the total test coverage metadata file, and establishing a code coverage mapping between the coverage data and a software development kit source code, and generating a test coverage report according to the code coverage mapping; Screening the test coverage report according to the software development kit configuration information to obtain a software development kit test coverage report, wherein the software development kit test coverage report includes a software development kit interface coverage report, a software development kit incremental code coverage report, and a software development kit full code coverage report; The step of generating a software development kit test coverage report according to the total test coverage metadata file also includes: The software development kit test coverage report is uploaded to a preset coverage collection service through the metadata merging task processor, and the coverage collection service stores the software development kit test coverage report in a preset database.
7. A test coverage statistics device, characterized in that: The test coverage statistics device comprises: A synchronous update module, which obtains preset software development kit configuration information, and updates the host application configuration information according to the software development kit configuration information, wherein the host application is an application program installed with the software development kit, the host application configuration information includes a host application instrumentation range, the host application instrumentation range includes a software development kit instrumentation range, and the software development kit configuration information includes the latest software development kit instrumentation range; A data collection module collects application test coverage metadata of the host application according to the updated host application configuration information, and generates an application test coverage metadata file according to the application test coverage metadata, wherein the application test coverage metadata includes the test coverage metadata of the host application and the test coverage metadata of the software development kit; A file generation module is provided to merge all the application test coverage metadata files into a total test coverage metadata file, and to generate a software development kit test coverage report according to the total test coverage metadata file.
8. A test coverage statistics device, characterized in that: The test coverage statistics device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the test coverage statistics method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the test coverage statistics method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements the steps of the test coverage statistics method according to any one of claims 1 to 6.