Code coverage rate testing method and device, storage medium and electronic equipment
By storing multiple dump records in the database and activating target records, the problem of interruption in the code coverage test process after application restart is solved, and the continuity statistics of test case coverage is achieved.
Patent Information
- Application Number
- CN202411832497.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-12
- Publication Date
- 2025-04-15
AI Technical Summary
In the prior art, after the application is restarted, the probe of the code coverage tool will be interrupted, and the continuity statistics of the coverage of test cases cannot be guaranteed.
By storing multiple dump records in the database, the target dump records are activated when the application version is updated to ensure the traceability of the code test file and the continuity of coverage tests.
It ensures the continuity of the code coverage test process after the application version is updated, and avoids interruption of test case coverage.
Smart Images

Figure CN119829432A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software testing, and in particular to a code coverage testing method, device, storage medium and electronic device. Background Art
[0002] In the field of software testing, whether it is automated testing or manual testing, it is impossible to effectively and intuitively monitor whether the test cases cover the corresponding development code. Especially for complex logic with many judgment branches and many exception handling situations, it is difficult to monitor the degree of code coverage by test cases, resulting in online failures that affect the interests of users and companies; the code coverage tool in the related technology can solve this problem, and will output a report on whether the test case covers each line of code, which can most intuitively see the uncovered / covered code. However, the method in the related technology needs to restart the service after the application code is put back on the service. At this time, the code coverage tool probe will be interrupted. After the service is started again, the probe will be reset, and the continuity of the test case coverage statistics cannot be guaranteed.
[0003] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0004] The embodiments of the present invention provide a code coverage testing method, device, storage medium and electronic device to at least solve the technical problem in the related art that when determining code coverage, the code coverage determination process is restarted due to the restart of the application, the code coverage evaluation process is interrupted, and the continuity of the code coverage testing process cannot be guaranteed.
[0005] According to one aspect of an embodiment of the present invention, a code coverage testing method is provided, comprising: in a process of performing code coverage testing on an application, when it is detected that the application is undergoing a version update, determining an activated target dump record from a plurality of dump records stored in a database, wherein the plurality of dump records are respectively used to store a version number of a corresponding version of the application, and storage information of a code test file of the corresponding version of the application; based on the target dump record, determining a target code test file from a plurality of code test files, wherein the plurality of code test files are obtained by executing the code coverage test; and based on the target code test file, obtaining a code coverage test result of the application.
[0006] Optionally, before determining the target dump record in an activated state from the multiple dump records stored in the database, the method also includes: in the process of performing the code coverage test on the application, if it is detected that the application has been updated, determining the version of the application before the version update as the target version; switching the dump record corresponding to the target version among the multiple dump records stored in the database from an inactivated state to an activated state.
[0007] Optionally, during the code coverage test of the application, if it is detected that the application is updated, the method further includes: switching the dump record corresponding to the previous version of the target version among the multiple dump records stored in the database from an activated state to an inactivated state.
[0008] Optionally, the method also includes: in the process of performing code coverage testing on the application, generating a current code test file based on a preset scheduled task; uploading the current code test file to an object storage server; based on the application name, application version information, server identifier, and storage information of the current code test file in the object storage server, constructing a dump record of the current code test file, wherein the server identifier is a server that performs code coverage testing on the application; and storing the dump record of the current code test file in the database.
[0009] Optionally, uploading the current code test file to the object storage server includes: sending the current code test file to a message queue; and uploading the current code test file to the object storage server through the message queue.
[0010] Optionally, sending the current code test file to the message queue includes: detecting whether the current code test file is consistent with a previous code test file; if the current code test file is inconsistent with the previous code test file, sending the current code test file to the message queue.
[0011] Optionally, when there are multiple target code test files, and the multiple target code test files are obtained by performing code coverage testing on the application on multiple servers, obtaining the code coverage test result of the application based on the target code test files includes: merging the multiple target code test files to obtain a merged test file, wherein the multiple target code test files correspond one-to-one to the multiple servers; and obtaining the code coverage test result based on the merged test file.
[0012] According to another aspect of an embodiment of the present invention, a code coverage testing device is also provided, including: a dump record determination module, which is used to determine an activated target dump record from multiple dump records stored in a database when it is detected that the application has been updated during a code coverage test on the application, wherein the multiple dump records are respectively used to store the version number of the corresponding version application and the storage information of the code test file of the corresponding version application; a test file determination module, which is used to determine a target code test file from multiple code test files based on the target dump record, wherein the multiple code test files are obtained by executing the code coverage test; and a code coverage testing module, which is used to obtain a code coverage test result of the application based on the target code test file.
[0013] According to another aspect of an embodiment of the present invention, a non-volatile storage medium is provided, wherein the non-volatile storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded by a processor and executing any one of the code coverage testing methods.
[0014] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, comprising one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement any one of the code coverage testing methods described.
[0015] In an embodiment of the present invention, when a version update of an application is detected during a code coverage test of the application, a target dump record in an activated state is determined from a plurality of dump records stored in a database, wherein the plurality of dump records are respectively used to store a version number of a corresponding version of the application and storage information of a code test file of the corresponding version of the application; based on the target dump record, a target code test file is determined from a plurality of code test files, wherein the plurality of code test files are obtained by executing the code coverage test; based on the target code test file, a code coverage test result of the application is obtained, so that when the code coverage test process is reset due to a version update of the application, the code test file can be traced by setting the activation state, so that even when the code coverage test process is reset, the continuity of the code coverage test process can be guaranteed, thereby achieving the technical effect of ensuring the continuity of the code coverage test process, and further solving the technical problem in the related art that when the code coverage determination process is restarted due to the restart of the application, the code coverage evaluation process is interrupted, and the continuity of the code coverage test process cannot be guaranteed. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0017] Figure 1 is a flow chart of a code coverage testing method according to an embodiment of the present invention;
[0018] Figure 2 is a flowchart of an optional code coverage testing method according to an embodiment of the present invention;
[0019] Figure 3 is a flowchart of an optional code coverage testing method according to an embodiment of the present invention;
[0020] Figure 4 is a schematic diagram of a code coverage testing device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0021] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings 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 ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0022] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0023] First, to facilitate understanding of the embodiments of the present invention, some terms or nouns involved in the present invention are explained below:
[0024] Java Code Coverage (Jacoco) tool: is an open source Java code coverage tool that helps developers evaluate their test coverage and code quality. Code coverage statistics are performed by modifying the bytecode of the classified class files. That is, probe bytecodes are inserted at specified locations in the original class bytecode to form a new bytecode instruction stream.
[0025] Mini Object Storage Minio Server is an open source distributed object storage server that allows users to build high-performance object storage services in a private cloud environment. Minio Server provides a simple and powerful application programming interface that allows users to manage and store data through a standard object storage interface.
[0026] Object is the basic storage unit in Minio object storage. It can be any type of data, such as text files, images, videos, etc. Objects are stored in buckets, and each object has a unique key that uniquely identifies the object. The object key usually includes the name and storage path of the object.
[0027] Bucket is a container used to store objects in Minio object storage. Similar to folders in a file system, buckets are used to organize and manage objects. Bucket is a top-level namespace used to store related objects. Each bucket has a unique name, and the bucket name must be unique in the same Minio instance. Buckets can be used to classify and manage objects, making it easier for users to access, share, and manage objects as needed.
[0028] According to an embodiment of the present invention, a method embodiment of code coverage testing is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0029] Figure 1 is a flowchart of a code coverage testing method according to an embodiment of the present invention. Figure 1 As shown, the method comprises the following steps:
[0030] Step S102, during the process of performing code coverage test on the application program, when it is detected that the application program is undergoing version update, determining a target dump record in an activated state from a plurality of dump records stored in a database;
[0031] Optionally, multiple dump records (i.e., dump records) are respectively used to store the version number of the corresponding version of the application, and the storage information of the code test file of the corresponding version of the application, wherein the code test file is a code coverage report file (exec file), and the code test file is obtained by performing a code coverage test on the application code, and the storage information may include but is not limited to the storage location information of the code test file in the object storage server. Multiple dump records correspond to different versions of the application, and each code test file corresponds to a dump record. By setting the activation status of the dump record, the code test file can be traced, so that even if the code coverage test process is reset due to reasons such as code version update, the test results can be obtained to ensure the continuity of the code coverage test process.
[0032] Optionally, a code coverage tool may be used, but is not limited to, to perform code coverage testing on the application. The code coverage tool may be, but is not limited to, the Java code coverage tool Jacoco. The code coverage tool can be used to evaluate the unit test coverage of the application, and to understand which codes are covered by the test and which codes are not covered by the test. The coverage report (i.e., code test file) generated by the code coverage tool can better understand their code quality and test coverage, so as to improve and optimize the test cases in a targeted manner.
[0033] In an optional embodiment, before determining an activated target dump record from multiple dump records stored in a database, the method also includes: during code coverage testing of an application, if it is detected that an application has been updated, determining the version of the application before the update as the target version; and switching the dump record corresponding to the target version from an inactivated state to an activated state among the multiple dump records stored in the database.
[0034] Optionally, since the code coverage test of the current updated version of the application is in progress, the relevant data (such as dump records) are being collected. The data collection is one step behind. After the collection is completed, it is ready to be stored in the database. Therefore, it is necessary to switch the dump record of the application version before the version update, that is, the previous version, from the inactive state to the active state. The above method can ensure that even if the currently collected data is lost, the historical data can be traced through the activated state, thereby ensuring the continuity of the code coverage test process.
[0035] In an optional embodiment, during code coverage testing of an application, if it is detected that an application version update is performed, the method further includes: switching a dump record corresponding to a previous version of the target version among multiple dump records stored in a database from an activated state to an inactivated state.
[0036] Optionally, by switching the dump record of the previous version (i.e., the target version) to an activated state and simultaneously switching the dump record of the previous version (i.e., the previous version of the target version) from an activated state to an inactivated state, it is possible to ensure that the records in the database are updated in a timely manner to reflect the code coverage of the latest version; in addition, by switching the status of the dump record in a timely manner, confusion and errors can be avoided, thereby ensuring the accuracy of the data stored in the database.
[0037] In an optional embodiment, the method also includes: in the process of performing code coverage testing on the application, generating a current code test file based on a preset scheduled task; uploading the current code test file to an object storage server; based on the application name, application version information, server identifier, and storage information of the current code test file in the object storage server, constructing a dump record of the current code test file, wherein the server identifier is a server that performs code coverage testing on the application; and storing the dump record of the current code test file in a database.
[0038] Optionally, during the code coverage test of the application, the code test file can be generated based on a pre-set scheduled task to obtain the current code test file generated at the current moment, and the current code test file can be stored in an object storage server (such as a mini object storage minio server) for storage, so as to facilitate subsequent calls and avoid the loss of related files when the code coverage test process is reset due to code version updates and other reasons, thereby causing the interruption of the code coverage test process. Further, based on the application name, application version information, server identifier, and storage information of the current code test file in the object storage server, a dump record of the current code test file is constructed to facilitate the subsequent call and query of the code test file based on the rollout record and the corresponding activation status. Among them, the application version information can be recorded in the form of a code submission identifier commitId; the server identifier can be a server IP, that is, the IP address of the server that performs code coverage testing on the application; the storage information of the current code test file in the object storage server can include but is not limited to the bucket, object Object, and other information of the current code test file in the object storage service.
[0039] In an optional embodiment, uploading the current code test file to the object storage server includes: sending the current code test file to a message queue; and uploading the current code test file to the object storage server through the message queue.
[0040] Optionally, asynchronous processing can be achieved by sending the test file to the message queue MQ. Even if the test file upload time is long or other operations are required, the sending operation can be completed immediately, and subsequent upload operations can be queued in the message queue waiting for processing. At the same time, the test file upload operation is decoupled from the user request, thereby reducing the dependency between systems and improving the flexibility and maintainability of the system. In addition, the use of message queues can ensure the reliability of test file transmission. Even in the event of network failure or server downtime, files can be safely transmitted and stored.
[0041] In an optional embodiment, sending the current code test file to the message queue includes: detecting whether the current code test file is consistent with the previous code test file; if the current code test file is inconsistent with the previous code test file, sending the current code test file to the message queue.
[0042] Optionally, it is possible but not limited to determine whether the current code test file is consistent with the previous code test file by comparing the checksum of the previous code test file with the checksum value of the current code test file, that is, whether the content of the current code test file has changed relative to the previous code test file. It should be noted that checksum is a checksum algorithm that calculates the file content to obtain a value of a fixed length, which can be used to represent the content of the code test file. When the content of the code test file changes, its checksum value will also change accordingly. Therefore, by comparing the checksum values of the last and current code test files, it can be determined whether the file content has changed.
[0043] In the above method, by comparing the current code test file with the previous code test file, it is possible to verify whether the file content has been modified, thereby ensuring the integrity and accuracy of the file; at the same time, subsequent operations are performed only when the file content has changed, avoiding unnecessary processing of unchanged files, saving resources and time.
[0044] Step S104, determining a target code test file from a plurality of code test files based on the target dump record, wherein the plurality of code test files are obtained by executing a code coverage test;
[0045] It can be understood that different code test files correspond to different dump records. When the target dump record in the activated state is determined, the code test file is traced by setting the activation state of the dump record, and the code test file corresponding to the activated dump record, that is, the target code test file, is determined for subsequent code coverage test result generation. This ensures that even if the code coverage test process is reset due to reasons such as code version update, the test results can be obtained, thereby ensuring the continuity of the code coverage test process.
[0046] Step S106, obtaining a code coverage test result of the application based on the target code test file.
[0047] Optionally, the code coverage test results of the application can be obtained by analyzing the target code test file. The code coverage test results obtained in the above manner are obtained by taking into account the reset of the code coverage test process caused by code version updates and other reasons, and have higher timeliness, thereby ensuring the continuity of the code coverage test process.
[0048] In an optional embodiment, when there are multiple target code test files, and the multiple target code test files are obtained by performing code coverage testing on an application on multiple servers, a code coverage test result of the application is obtained based on the target code test files, including: merging the multiple target code test files to obtain a merged test file, wherein the multiple target code test files correspond one-to-one to the multiple servers; and obtaining a code coverage test result based on the merged test file.
[0049] It should be noted that since the application may be deployed on multiple servers at the same time, the corresponding application code test needs to be completed through multiple different servers, and then the target code test files corresponding to the multiple servers are obtained. By merging multiple target code test files, the data in each test file can be integrated into one file, which is convenient for comprehensive analysis of the application code coverage test results and analysis and comparison of the overall test results.
[0050] Through the above steps S102 to S106, it can be achieved that the code coverage test process is reset due to the version update of the application, and the code test file can be traced by setting the activation state, so that even when the code coverage test process is reset, the continuity of the code coverage test process can be guaranteed, thereby achieving the technical effect of ensuring the continuity of the code coverage test process, and further solving the technical problem in the related technology that when determining the code coverage, the code coverage determination process is restarted due to the restart of the application, the code coverage evaluation process is interrupted, and the continuity of the code coverage test process cannot be guaranteed.
[0051] Based on the above embodiments and optional embodiments, the present invention proposes an optional implementation mode: Figure 2 is a flowchart of an optional code coverage testing method according to an embodiment of the present invention. Figure 3 is a flowchart of an optional code coverage testing method according to an embodiment of the present invention. Figure 2 and Figure 3 As shown, the method includes:
[0052] S1, transform the code coverage tool jacocoAgent. After the application is successfully deployed on the corresponding server (such as AL platform), the application will trigger JacocoAgent to start monitoring and recording whether the code is covered. The server side executes functional test cases and automated test cases to test the application. The Agent triggers messages to the message queue (Message Queue, MQ) at regular intervals to notify the dump and node to perform the dump code coverage report file (exec file) operation (that is, download and save the exec file). Before the scheduled sending, it will check whether the checksum of the last generated exec file is consistent with the checksum of the current exec file. If they are consistent, the information will not be sent to MQ;
[0053] S2, the node Internet Protocol IP is transmitted through the Agent, the node IP is specified to dump the exec file and upload it to the mini object storage minio server, where the node IP is the IP of the server used for code coverage testing;
[0054] S3, through the node IP, reverse query application name, code submission identifier commitId, create a dump record with application name, commitId, node IP, minio bucket Bucket, minio object Object, set the created dump record as the active version, and persist it to the database;
[0055] S4: Because data collection is one step behind, the dump record of the current version is being collected. After the collection is completed, it is ready to be stored in the database. The dump record of the last activated version needs to be set to an inactivated version, and the corresponding file on the minio storage needs to be deleted. This ensures that even if the currently collected data is lost, the historical data can be traced through the activated state.
[0056] S5, then the dump record of the previous version will be changed to the activated state;
[0057] S6, through the use case platform, find the latest dump record according to the application name, commitId, activation ID, and multiple node IPs (corresponding to multiple servers), and download the exec files corresponding to multiple nodes to the local computer;
[0058] S7, merge multiple exec files into one exec file, create an identification directory and place the merged exec file in the identification directory;
[0059] S8, uses the merged exec file to analyze and generate a report to obtain the code coverage test results to confirm the coverage quality.
[0060] Through the above steps S1 to S8, when the code coverage test process is reset due to a version update of the application, the code test file can be traced by setting the activation state. In this way, even when the code coverage test process is reset, the continuity of the code coverage test process can be guaranteed, thereby achieving the technical effect of ensuring the continuity of the code coverage test process, and further solving the technical problem in the related art that when determining the code coverage, the code coverage determination process is restarted due to the restart of the application, the code coverage evaluation process is interrupted, and the continuity of the code coverage test process cannot be guaranteed.
[0061] In this embodiment, a code coverage testing device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the terms "module" and "device" can implement a combination of software and / or hardware for a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0062] According to an embodiment of the present invention, there is also provided an apparatus embodiment for implementing the above code coverage testing method. Figure 4 is a schematic diagram of the structure of a code coverage testing device according to an embodiment of the present invention. Figure 4As shown, the above-mentioned code coverage test device includes: a dump record determination module 400, a test file determination module 402, and a code coverage test module 404, wherein:
[0063] The dump record determination module 400 is used to determine an activated target dump record from a plurality of dump records stored in a database when detecting that the application is undergoing a version update during a code coverage test on the application, wherein the plurality of dump records are respectively used to store a version number of a corresponding version of the application and storage information of a code test file of the corresponding version of the application;
[0064] A test file determination module 402, connected to the dump record determination module 400, is used to determine a target code test file from a plurality of code test files based on a target dump record, wherein the plurality of code test files are obtained by executing a code coverage test;
[0065] The code coverage test module 404 is connected to the test file determination module 402 and is used to obtain the code coverage test result of the application program based on the target code test file.
[0066] In the embodiment of the present invention, a dump record determination module 400 is provided to determine a target dump record in an activated state from a plurality of dump records stored in a database when it is detected that a version update of the application is performed during a code coverage test of the application, wherein the plurality of dump records are respectively used to store a version number of the corresponding version application and storage information of a code test file of the corresponding version application; a test file determination module 402 is connected to the dump record determination module 400 and is used to determine a target code test file from a plurality of code test files based on the target dump record, wherein the plurality of code test files are obtained by executing a code coverage test; and a code coverage test module 404 , connected to the test file determination module 402, is used to obtain the code coverage test result of the application based on the target code test file, so that when the code coverage test process is reset due to the version update of the application, the code test file can be traced by setting the activation state, so that even when the code coverage test process is reset, the continuity of the code coverage test process can be guaranteed, thereby achieving the technical effect of ensuring the continuity of the code coverage test process, and further solving the technical problem in the related art that when the code coverage determination process is performed, the code coverage determination process is restarted due to the restart of the application, the code coverage evaluation process is interrupted, and the continuity of the code coverage test process cannot be guaranteed.
[0067] In an optional embodiment, the above-mentioned device also includes: a first version determination sub-module, which is used to determine the version of the application before the version update as the target version when it is detected that the application has been updated during the code coverage testing of the application; a first state switching sub-module, which is used to switch the dump record corresponding to the target version among multiple dump records stored in the database from an inactivated state to an activated state.
[0068] In an optional embodiment, the above-mentioned device also includes: a second state switching sub-module, which is used to switch the dump record corresponding to the previous version of the target version among multiple dump records stored in the database from an activated state to an inactivated state when it is detected that the application has been updated during the code coverage testing of the application.
[0069] In an optional embodiment, the above-mentioned device also includes: a first generation sub-module, used to generate a current code test file based on a preset scheduled task during a code coverage test on an application; a first upload sub-module, used to upload the current code test file to an object storage server; a first construction sub-module, used to construct a dump record of the current code test file based on the application name, application version information, server identifier, and storage information of the current code test file in the object storage server, wherein the server identifier is a server that performs code coverage testing on the application; a first recording sub-module, used to store the dump record of the current code test file in a database.
[0070] In an optional embodiment, the above-mentioned first recording submodule includes: a first sending submodule, used to send the current code test file to the message queue; and a second uploading submodule, used to upload the current code test file to the object storage server through the message queue.
[0071] In an optional embodiment, the above-mentioned first sending submodule includes: a first detection submodule, used to detect whether the current code test file is consistent with the previous code test file; a second sending submodule, used to send the current code test file to the message queue when the current code test file is inconsistent with the previous code test file.
[0072] In an optional embodiment, the above-mentioned code coverage test module includes: a first merging sub-module, used to merge the multiple target code test files to obtain a merged test file when there are multiple target code test files, and the multiple target code test files are obtained by performing code coverage tests on an application on multiple servers, wherein the multiple target code test files correspond one-to-one to the multiple servers; and a second generating sub-module, used to obtain a code coverage test result based on the merged test file.
[0073] It should be noted that the above modules can be implemented by software or hardware. For example, for the latter, it can be implemented in the following ways: the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.
[0074] It should be noted that the dump record determination module 400, the test file determination module 402, and the code coverage test module 404 correspond to steps S102 to S106 in the embodiment, and the examples and application scenarios implemented by the modules and the corresponding steps are the same, but are not limited to the contents disclosed in the above embodiments. It should be noted that the modules as part of the device can be run in a computer terminal.
[0075] It should be noted that the optional or preferred implementation of this embodiment can refer to the relevant description in the embodiment, which will not be repeated here.
[0076] The above-mentioned code coverage testing device may also include a processor and a memory. The above-mentioned dump record determination module 400, test file determination module 402, code coverage testing module 404, etc. are all stored in the memory as program modules, and the processor executes the above-mentioned program modules stored in the memory to realize corresponding functions.
[0077] The processor includes a kernel, which retrieves the corresponding program module from the memory. The kernel may be one or more. The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. The memory includes at least one memory chip.
[0078] According to an embodiment of the present application, an embodiment of a non-volatile storage medium is also provided. Optionally, in this embodiment, the non-volatile storage medium includes a stored program, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute any of the above code coverage testing methods.
[0079] Optionally, in this embodiment, the non-volatile storage medium may be located in any computer terminal in a computer terminal group in a computer network, or in any mobile terminal in a mobile terminal group, and the non-volatile storage medium includes a stored program.
[0080] Optionally, when the program is running, the device where the non-volatile storage medium is located is controlled to perform the following functions: during code coverage testing of an application, if it is detected that an application version update is performed, an activated target dump record is determined from multiple dump records stored in a database, wherein the multiple dump records are respectively used to store the version number of the corresponding version of the application and the storage information of the code test file of the corresponding version of the application; based on the target dump record, a target code test file is determined from multiple code test files, wherein the multiple code test files are obtained by executing a code coverage test; based on the target code test file, a code coverage test result of the application is obtained.
[0081] According to an embodiment of the present application, an embodiment of a processor is also provided. Optionally, in this embodiment, the processor is used to run a program, wherein any one of the code coverage testing methods is executed when the program is running.
[0082] According to an embodiment of the present application, an embodiment of a computer program product is also provided, which, when executed on a data processing device, is suitable for executing a program that initializes any one of the above-mentioned code coverage testing method steps.
[0083] Optionally, the above-mentioned computer program product, when executed on a data processing device, is suitable for executing a program initialized with the following method steps: in the process of performing code coverage testing on an application, when it is detected that an application has been updated, determining an activated target dump record from multiple dump records stored in a database, wherein the multiple dump records are respectively used to store the version number of the corresponding version of the application, and the storage information of the code test file of the corresponding version of the application; based on the target dump record, determining a target code test file from multiple code test files, wherein the multiple code test files are obtained by performing code coverage testing; based on the target code test file, obtaining the code coverage test result of the application.
[0084] An embodiment of the present invention provides an electronic device, which includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, the following steps are implemented: in the process of performing code coverage testing on an application, when it is detected that the application is updated, a target dump record in an activated state is determined from multiple dump records stored in a database, wherein the multiple dump records are respectively used to store the version number of the corresponding version of the application and the storage information of the code test file of the corresponding version of the application; based on the target dump record, a target code test file is determined from multiple code test files, wherein the multiple code test files are obtained by performing code coverage testing; based on the target code test file, a code coverage test result of the application is obtained.
[0085] The above sequence of the embodiments of the present invention is for description only and does not represent the superiority or inferiority of the embodiments.
[0086] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0087] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the above modules can be a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, modules or indirect coupling or communication connection of modules, which can be electrical or other forms.
[0088] The modules described above as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed on multiple modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment.
[0089] In addition, each functional module in each embodiment of the present invention may be integrated into one processing module, or each module may exist physically separately, or two or more modules may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of software functional modules.
[0090] If the above-mentioned integrated module is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable non-volatile storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a non-volatile storage medium, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the various embodiments of the present invention. The aforementioned non-volatile storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
[0091] The above are only preferred embodiments of the present invention. It should be pointed out that, for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A code coverage testing method, characterized in that: include: In the process of performing code coverage test on an application, when it is detected that the application is updated, determining an activated target dump record from a plurality of dump records stored in a database, wherein the plurality of dump records are respectively used to store a version number of a corresponding version of the application and storage information of a code test file of the corresponding version of the application; Based on the target dump record, determining a target code test file from a plurality of code test files, wherein the plurality of code test files are obtained by executing the code coverage test; Based on the target code test file, a code coverage test result of the application program is obtained.
2. The method according to claim 1, characterized in that Before determining the target dump record in an activated state from the plurality of dump records stored in the database, the method further comprises: In the process of performing the code coverage test on the application, if it is detected that the application is updated, determining the version of the application before the update as the target version; Among the plurality of dump records stored in the database, the dump record corresponding to the target version is switched from an inactive state to an active state.
3. The method according to claim 2, characterized in that In the process of performing the code coverage test on the application, if it is detected that the application is updated, the method further includes: Among the plurality of dump records stored in the database, the dump record corresponding to the previous version of the target version is switched from an activated state to an inactivated state.
4. The method according to claim 1, characterized in that: The method further comprises: In the process of performing the code coverage test on the application, generating a current code test file based on a preset scheduled task; Upload the current code test file to the object storage server; Based on the application name, application version information, server identifier of the application, and storage information of the current code test file in the object storage server, construct a dump record of the current code test file, wherein the server identifier is a server that performs the code coverage test on the application; The dump record of the current code test file is stored in the database.
5. The method according to claim 4, characterized in that The uploading of the current code test file to the object storage server includes: Sending the current code test file to a message queue; The current code test file is uploaded to the object storage server through the message queue.
6. The method according to claim 5, characterized in that The sending the current code test file to the message queue includes: Detecting whether the current code test file is consistent with the previous code test file; When the current code test file is inconsistent with the previous code test file, the current code test file is sent to the message queue.
7. The method according to any one of claims 1 to 6, characterized in that: In the case where there are multiple target code test files, and the multiple target code test files are obtained by performing code coverage tests on the application on multiple servers, obtaining the code coverage test results of the application based on the target code test files includes: Merging the multiple target code test files to obtain a merged test file, wherein the multiple target code test files correspond to the multiple servers one by one; Based on the merged test file, the code coverage test result is obtained.
8. A code coverage testing device, characterized in that: include: A dump record determination module is used to determine an activated target dump record from a plurality of dump records stored in a database when it is detected that the application is undergoing a version update during a code coverage test on the application, wherein the plurality of dump records are respectively used to store a version number of a corresponding version of the application and storage information of a code test file of the corresponding version of the application; A test file determination module, used to determine a target code test file from a plurality of code test files based on the target dump record, wherein the plurality of code test files are obtained by executing the code coverage test; The code coverage test module is used to obtain the code coverage test result of the application program based on the target code test file.
9. A non-volatile storage medium, characterized in that: The non-volatile storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the code coverage testing method described in any one of claims 1 to 7.
10. An electronic device, characterized in that: It includes one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the code coverage testing method described in any one of claims 1 to 7.