Code test coverage rate detection method and device, electronic equipment and storage medium
By automatically collecting and merging the test environment operation logs, automatically generating code test coverage information, solving the problem of invasiveness of existing tools on product code and insufficient automatic statistics capabilities, and achieving efficient and accurate code test coverage statistics and display.
Patent Information
- Application Number
- CN202411741282.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-03-07
AI Technical Summary
Existing code coverage testing tools are intrusive to product code, unable to automatically count and branch iterate, and are inconvenient to configure and deploy, resulting in additional work burdens for developers and testers.
By obtaining the project code information and pipeline information of the target project, using preset probes to automatically collect the test environment operation log, perform preset transformation and merging operations, and automatically generate test coverage information of each branch code to achieve non-invasive automated statistics and display.
Improves the statistical efficiency and accuracy of code test coverage, reduces the work burden of developers and testers, supports automatic statistics and branch iteration, and facilitates configuration and deployment.
Smart Images

Figure CN119576784A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of code test coverage monitoring, and in particular to a code test coverage detection method, a code test coverage detection device, an electronic device and a computer-readable storage medium. Background Art
[0002] At present, software projects have frequent version iterations, and there is a lack of visual tools to summarize and count the changed codes. Usually, the code modified by developers needs to be self-tested and self-verified before it can be submitted to testers for functional testing. If developers forget the code they have changed, it may lead to insufficient testing and cause production problems. Usually, when testing code, testers perform functional testing according to test cases. Test cases usually need to cover the developer's changed code and all conditional branches to ensure that the test is effective. Coverage is a means of measuring test integrity and a measure of test effectiveness. At present, some existing code coverage testing tools require more than 20 pieces of information to be entered, including code address, branch, user password, test environment information, development start time, test start time, etc. There is a lot of information to be recorded, and manual operation is required. At the same time, existing tools usually invade existing product codes, do not support automatic statistics and branch iteration, are not convenient for configuration and deployment, and manual operation imposes additional workload on developers and testers. Summary of the invention
[0003] The present application provides a code test coverage detection method, a code test coverage detection device, an electronic device and a computer-readable storage medium, which are used to solve the problems that existing tools usually invade existing product codes, do not support automatic statistics and branch iteration, and are inconvenient to configure and deploy.
[0004] In a first aspect of the present application, a method for detecting code test coverage is provided, comprising:
[0005] Get the project code information of the target project;
[0006] Acquire pipeline information of the target project based on project code information of the target project, wherein the pipeline information includes a test environment address;
[0007] Based on the preset probe, all test environment operation logs of each branch code in the target project are obtained through the test environment address;
[0008] For each branch code, traverse each line of log information in the running log of each test environment, perform preset transformation on each line of log information to obtain the identification code corresponding to each line of log information, perform a merge operation on the log information in the running log of each test environment based on all the identification codes obtained, and obtain the test coverage information of the current branch code based on the merge operation result.
[0009] Optionally, the project code information includes a first creation time of each branch code in the target project, and the pipeline information includes a second creation time of each branch code in the target project; after obtaining the test coverage information of the current branch code based on the merge operation result, the method further includes:
[0010] Matching the first creation time and the second creation time of each branch code;
[0011] If the current branch code is determined to be the target branch code according to the matching result of the first creation time and the second creation time of each branch code, the test coverage information of the target branch code is identified and displayed.
[0012] Optionally, determining the current branch code as the target branch code according to the matching result of the first creation time and the second creation time of each branch code includes:
[0013] If the first creation time and the second creation time of the current branch code are inconsistent, the current branch code is determined to be the target branch code.
[0014] Optionally, the preset transformation includes:
[0015] Calculate the log information based on the preset cryptographic hash function;
[0016] Perform a preset transformation on each line of log information to obtain the identification code corresponding to each line of log information, including:
[0017] The preset encrypted hash function is called to calculate the characters of each line of log information to obtain an identification code for each line of log information, so that when the characters of any two lines of log information are the same, the identification codes calculated by the preset encrypted hash function are the same, and when the characters of any two lines of log information are different, the identification codes calculated by the preset encrypted hash function are different.
[0018] Optionally, performing a merging operation on log information in the running logs of each test environment based on all the obtained identification codes includes:
[0019] Determine whether there is a duplicate identification code among all the obtained identification codes;
[0020] If there are duplicate identification codes, the duplicate identification codes are deduplicated, and the log information corresponding to all the deduplicated identification codes is merged;
[0021] If there is no duplicate identification code, a merge operation is performed on all log information in the running logs of each test environment.
[0022] Optionally, after obtaining the test coverage information of the current branch code based on the merge operation result, the method further includes:
[0023] Acquire the source code of each branch code in the target project based on the project code information;
[0024] Determine the tested code block information in each branch code based on the test coverage information of each branch code;
[0025] The tested code block information in each branch code is used as an index to determine the corresponding code block in the source code of each branch code as the target code block, and the target code block is dyed with a preset color and displayed.
[0026] In a second aspect of the present application, a code test coverage detection device is provided, comprising:
[0027] A first data acquisition module is configured to obtain project code information of a target project;
[0028] A second data acquisition module is configured to obtain pipeline information of the target project based on the project code information of the target project, wherein the pipeline information includes a test environment address;
[0029] A log collection module is configured to obtain all test environment operation logs of each branch code in the target project through the test environment address based on a preset probe;
[0030] The coverage calculation module is configured to traverse each line of log information in the running log of each test environment for each branch code, perform a preset transformation on each line of log information to obtain the identification code corresponding to each line of log information, perform a merge operation on the log information in the running log of each test environment based on all the obtained identification codes, and obtain the test coverage information of the current branch code based on the merge operation result.
[0031] According to a third aspect of the present application, an electronic device is provided, comprising: a processor, and a memory communicatively connected to the processor;
[0032] The memory stores computer-executable instructions;
[0033] The processor executes the computer-executable instructions stored in the memory to implement the above method.
[0034] In a fourth aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to implement the above-mentioned method when executed by a processor.
[0035] In a fifth aspect of the present application, a computer program product is provided, including a computer program, which implements the above method when executed by a processor.
[0036] This application automatically collects the test environment operation log based on the probe, without modifying the source code. By performing a preset transformation on each line of log information in the test environment operation log into a corresponding identification code, when performing the log information merging operation, the log information is identified and screened according to the identification code of each line of log information to automatically generate test coverage information for each branch code, effectively improving the statistical efficiency and accuracy of code test coverage. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] 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.
[0038] Figure 1 A method flow chart of a code test coverage detection method provided in an embodiment of the present application;
[0039] Figure 2 A schematic diagram of the code test coverage statistics process provided for the embodiment of the present application;
[0040] Figure 3 A schematic block diagram of a code test coverage detection device provided in an embodiment of the present application;
[0041] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0042] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the specific implementation methods described herein are only used to illustrate and explain the embodiments of the present application, and are not used to limit the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0044] It should be noted that if the embodiments of the present application involve directional indications (such as up, down, left, right, front, back...), the directional indications are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.
[0045] In addition, if there are descriptions of "first", "second", etc. in the embodiments of the present application, the descriptions of "first", "second", etc. are only for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection required by this application. It can be understood that in the technical solution of this application, the acquisition, collection, storage, use, processing, transmission, provision, disclosure and application of data are all in compliance with the provisions of relevant laws and regulations. It should be noted that in the embodiments of the present application, some existing solutions in the industry such as software, components, models, etc. may be mentioned, and they should be considered as exemplary. Their purpose is only to illustrate the feasibility of the implementation of the technical solution of this application, but it does not mean that the applicant has or must use the solution.
[0046] like Figure 1 As shown, in a first aspect of the present application, a method for detecting code test coverage is provided, comprising:
[0047] S100, obtaining project code information of the target project;
[0048] S200, acquiring pipeline information of the target project based on the project code information of the target project, where the pipeline information includes a test environment address;
[0049] S300, based on the preset probe, obtain all test environment operation logs of each branch code in the target project through the test environment address;
[0050] S400. For each branch code, traverse each line of log information in the running log of each test environment, perform a preset transformation on each line of log information to obtain the identification code corresponding to each line of log information, perform a merge operation on the log information in the running log of each test environment based on all the obtained identification codes, and obtain the test coverage information of the current branch code based on the merge operation result.
[0051] In this way, the present application automatically collects the test environment operation log based on the probe without modifying the source code. By performing a preset transformation on each line of log information in the test environment operation log into a corresponding identification code, when executing the log information merging operation, the log information is identified and screened according to the identification code of each line of log information to automatically generate test coverage information for each branch code, thereby effectively improving the statistical efficiency and accuracy of the code test coverage.
[0052] like Figure 2 As shown, in step S100, the common code warehouse information can be obtained through the pre-built code warehouse synchronization module, and the code information of all projects can be obtained from the specified code warehouse, such as code directory hierarchy, source code, branch information, branch code creation time, branch code submission record, etc. It can be understood that the code directory hierarchy represents the organizational structure of each file and folder in the project, for example, including the file address of the source code, the file address of the test code, the document file address, the configuration file address, etc.; the source code is the actual code file content in the project, including source files written in various programming languages, which define the business logic and functions of the software; each project can contain multiple branches for different development processes and version management, wherein the branch information generally includes the main branch, development branch, functional branch, etc.; the branch code creation time is used to record the specific time when each branch is created, which is convenient for project development management and traceability; the submission record includes the code submission record of each branch, which generally includes the submission time, submitter, change description, code difference, etc. Among them, the code warehouse synchronization module can obtain the code information of all projects from the specified code warehouse periodically, for example, updating the obtained project code information regularly every day.
[0053] In step S200, the pipeline refers to the complete process from code writing to deployment. Usually, the pipeline performs code building, testing, deployment and other tasks through automated scripts or tools to ensure that the code can be released quickly and safely. For example, the pipeline usually includes processes such as code compilation, unit testing, integration testing, deployment to the test environment, and deployment to the production environment. Among them, the pipeline information includes the coding code branch, which refers to the branch of the code warehouse that the current pipeline compiles; the compilation directory, that is, the physical directory path where the code is stored during the construction process; the test environment address, whenever the new code is deployed to the test environment, there will be a corresponding test server or environment address, and the developer can perform functional, integrated or system testing in this environment. It can be understood that the test environment operation log is usually stored in a specified directory in the test server or test environment, and the test environment operation log can be accessed and analyzed through the test environment address. This application uses a pre-built pipeline synchronization module to automatically obtain all pipeline information based on the project code information of the target project, such as the compilation code branch, compilation directory, test environment address, execution user, deployment directory, etc.
[0054] In step S300, the preset probe is specifically javaagent, that is, a Java probe. It can be understood that compared with inserting monitoring code into the source code, javaagent can monitor the behavior of Java applications without modifying the source code, so that developers can analyze the program at runtime and monitor information such as method calls, parameters and return values. For example, javaagent can record which methods are called, the calling time, etc.; as well as implement error capture and logging, and help developers diagnose runtime exceptions by analyzing the call stack information; at the same time, javaagent can also modify the bytecode at runtime, such as adding, deleting or replacing method implementations. The present application builds and deploys a test environment operation log collection tool based on javaagent. The log collection tool can automatically collect the test environment operation log at a fixed time, for example, collecting the test environment operation log once an hour. Among them, the test environment operation log collection tool can create an agent class, register a class converter, and implement a specific interface such as the ClassFileTransformer interface through the class converter to modify the bytecode for a specific class or method. For example, modify the specific bytecode, add log monitoring code, and load the probe through the javaagent parameter when the JVM is started. At the same time, you can configure scheduled tasks to regularly collect and store test environment operation logs. For example, you can use Java's ScheduledExecutorService interface to create a scheduled execution task, which is not limited here. In this way, the deployment of the test environment operation log collection tool based on javaagent can achieve non-intrusive analysis and recording of the code operation logic in the java runner, so as to mark the executed code information.
[0055] In step S400, for the acquired test environment operation log, the acquired test environment operation log can be analyzed and counted by the pre-built test coverage statistics module. For example, for all associated test environment operation logs of each branch code, each line of log information in each test environment operation log is traversed. It can be understood that in the test environment operation log, each line of information includes the occurrence time, log level, message content, exception information, etc. of the log event. Among them, the occurrence time is the specific time when the event occurs; the log level indicates the importance of the current log message, for example, DEBUG, INFO, WARN, ERRO, FATAL, etc., wherein DEBUG indicates detailed debugging information, INFO indicates information when the program is running normally, such as start, stop, etc., WARN indicates an expected non-serious error, ERROR indicates an error has occurred, but the system can continue to run, FATAL indicates a serious error, the system may not be able to continue to run, etc.; the message content indicates the detailed information of the event, for example, the called method, class name, line number, etc., that is, the class and method corresponding to the log generation, so as to facilitate the location of the code; the exception information indicates the detailed information of the error record, including the exception type, description and stack information, etc.
[0056] In the present application, a preset transformation is performed on each line of log information in the test environment operation log to obtain an identification code corresponding to the log information, so that the same log information has the same identification code, and the identification codes corresponding to different log information are different. In the present application, the preset transformation includes calculating the log information based on a preset encrypted hash function, wherein the preset encrypted hash function can use the MD5 algorithm. Performing a preset transformation on each line of log information to obtain the identification code corresponding to each line of log information includes: calling a preset encrypted hash function, such as the MD5 algorithm to calculate the characters of each line of log information to obtain the identification code of each line of log information, that is, calculating all the characters in each line of log information through the MD5 algorithm to obtain the MD5 code corresponding to the characters of the line, that is, converting each line of log information into a corresponding MD5 code, so that when the characters of any two lines of log information are the same, the identification codes calculated by the preset encrypted hash function such as the MD5 algorithm are the same, and when the characters of any two lines of log information are different, the identification codes calculated by the preset encrypted hash function are different. That is, if the characters of any two lines of log information are different, the MD5 codes calculated by the MD5 algorithm are different; if the characters of any two lines of log information are the same, the MD5 codes calculated by the MD5 algorithm are the same. In this way, for all the collected test environment operation logs, by converting each line of log information into the corresponding MD5 code, the log information can be merged more efficiently and accurately. Compared with the existing technology that only realizes log merging by simple addition and subtraction of lines, this application can accurately calculate the coverage information of each line.
[0057] In the present application, a merge operation is performed on the log information in each test environment operation log based on all the obtained identification codes, including: determining whether there are duplicate identification codes in all the obtained identification codes, and if there are duplicate identification codes, deduplicating the duplicate identification codes, and performing a merge operation on the log information corresponding to all the identification codes after the deduplication process; if there are duplicate identification codes, deduplicating the duplicate identification codes, and performing a merge operation on the log information corresponding to all the identification codes after the deduplication process; if there are no duplicate identification codes, a merge operation is performed on all the log information in each test environment operation log. For example, after all the log information is converted to MD5 codes, if it is determined that there are duplicate MD5 codes in all the obtained MD5 codes, for example, there is an MD5 code in test environment operation log A that is the same as an MD5 code in test environment operation log B, then it means that the same test is performed on the same part of the code in test A and test B, and the two are duplicate test contents, then only one of them can be retained. After deduplication of all log information based on the obtained MD5 code, log merging is performed on the log information corresponding to the deduplication MD5 code, so as to obtain the test status of the current branch code. The code blocks that have been tested in the current branch code can be located through the merged log information, and the test coverage information of the current branch code can be obtained by comparing the tested code blocks and source code. It can be understood that if there is no duplicate MD5 code after MD5 code conversion of all log information, the log merging operation can be directly performed on each log information.
[0058] In the present application, after obtaining the test coverage information of the current branch code based on the result of the merge operation, the method also includes: obtaining the source code of each branch code in the target project based on the project code information, the test coverage statistics module determines the source code location through the project code information, and pulls the source code to the designated storage location; determining the tested code block information in each branch code based on the test coverage information of each branch code, for example, determining the code block for executing the test based on the line number of the code in the log information; using the tested code block information in each branch code as an index, determining the corresponding code block in the source code of each branch code as the target code block, dyeing and displaying the target code block with a preset color, for example, dyeing and displaying the code block determined as tested in the source code, so that the user can intuitively observe the test coverage of the code.
[0059] It can be understood that the project code information includes the first creation time of each branch code in the target project, that is, the initial creation time of each branch code, and the pipeline information includes the second creation time of each branch code in the target project, that is, the update time of each branch code; in the present application, after the test environment operation log of each branch code is executed to merge the logs to obtain the test coverage information of the current branch code, the changes of each branch code are further detected, that is, after the test coverage information of the current branch code is obtained based on the result of the merge operation, the method of the present application also includes: matching the first creation time and the second creation time of each branch code; if the current branch code is determined to be the target branch code based on the matching result of the first creation time and the second creation time of each branch code, the test coverage information of the target branch code is identified and displayed. Among them, if the first creation time of the current branch code is inconsistent with the second creation time, the current branch code is determined to be the target branch code. For example, the test coverage statistics module can be configured to automatically update each branch code and pipeline version information at a regular interval. For example, each branch code and pipeline version information is updated through the pipeline synchronization module on a daily basis. If the update time of the current branch code is inconsistent with the initial creation time of the current branch code, it means that there is a change in the current branch code, and the test coverage information of the current branch code is marked, for example, the test coverage information of the current branch code is marked as a changed code, or the test coverage information of the current branch code is colored.
[0060] It is understandable that in order to monitor the code changes more accurately, when it is determined that the first creation time of the current branch code is inconsistent with the second creation time, the present application further determines whether the current second creation time is consistent with the second creation time when the current branch code performs the log information merge operation of the last test environment operation log. If they are consistent, it means that the current branch code has not changed relative to the last log merge operation, and the test coverage information of the current branch code is not marked and displayed; if they are inconsistent, it means that the current branch code has changed relative to the last log merge operation, and the test coverage information of the current branch code is marked and displayed. It is understandable that the code changes can be determined through the version information of each branch code. Based on the version information of each branch code, the changed code can be intuitively displayed by pulling the source code of the current branch code and coloring the changed part of the code.
[0061] like Figure 3 As shown, in a second aspect of the present application, a code test coverage detection device is provided, comprising:
[0062] A first data acquisition module is configured to obtain project code information of a target project;
[0063] A second data acquisition module is configured to obtain pipeline information of the target project based on the project code information of the target project, where the pipeline information includes a test environment address;
[0064] The log collection module is configured to obtain all test environment operation logs of each branch code in the target project through the test environment address based on the preset probe;
[0065] The coverage calculation module is configured to traverse each line of log information in the running log of each test environment for each branch code, perform a preset transformation on each line of log information to obtain the identification code corresponding to each line of log information, perform a merge operation on the log information in the running log of each test environment based on all the obtained identification codes, and obtain the test coverage information of the current branch code based on the merge operation result.
[0066] It should be noted that it should be understood that the division of the various modules of the above device is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software called by processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software called by processing elements, and some modules can be implemented in the form of hardware. For example, the data acquisition module can be a separately established processing element, or it can be integrated in a chip of the above device. In addition, it can also be stored in the memory of the above device in the form of program code, and called and executed by a processing element of the above device. The function of the above data acquisition module. The implementation of other modules is similar. In addition, all or part of these modules can be integrated together, or they can be implemented independently. The processing element here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.
[0067] According to a third aspect of the present application, an electronic device is provided, comprising: a processor, and a memory communicatively connected to the processor;
[0068] The memory stores computer-executable instructions;
[0069] The processor executes the computer-executable instructions stored in the memory to implement the above method.
[0070] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 4 As shown, the electronic device may include: a transceiver 121 , a processor 122 , and a memory 123 .
[0071] The processor 122 executes the computer execution instructions stored in the memory, so that the processor 122 executes the scheme in the above embodiment. The processor 122 can be a general-purpose processor, including a central processing unit CPU, a network processor (network processor, NP), etc.; it can also be a digital signal processor DSP, an application-specific integrated circuit ASIC, a field programmable gate array FPGA or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
[0072] The memory 123 is connected to the processor 122 via a system bus and completes communication between them. The memory 123 is used to store computer program instructions.
[0073] The transceiver 121 may be used to obtain tasks to be executed and configuration information of the tasks to be executed.
[0074] The system bus can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The system bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The transceiver is used to realize the communication between the database access device and other computers (such as clients, read-write libraries, and read-only libraries). The memory may include random access memory (RAM) and may also include non-volatile memory.
[0075] The electronic device provided in the embodiment of the present application may be the terminal device of the above embodiment.
[0076] In a fourth aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to implement the above-mentioned method when executed by a processor.
[0077] In a fifth aspect of the present application, a computer program product is provided, including a computer program, which implements the above method when executed by a processor.
[0078] In summary, this application obtains all project information by automatically scanning the code repository, thus eliminating the tedious project configuration steps; automatically scans the CI / CD pipeline, obtains the project code version branch and deployment environment by matching the project information obtained from the code repository, automatically deploys the listening program, and automatically obtains the test coverage execution file for subsequent test coverage statistics; automatically scans the code repository and pipeline to automatically count the test coverage of each project; through code merging and coloring, the developer's code changes and test execution status are intuitively displayed in a graphical way.
[0079] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0080] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A code test coverage detection method, characterized in that: include: Get the project code information of the target project; Acquire pipeline information of the target project based on project code information of the target project, wherein the pipeline information includes a test environment address; Based on the preset probe, all test environment operation logs of each branch code in the target project are obtained through the test environment address; For each branch code, traverse each line of log information in the running log of each test environment, perform preset transformation on each line of log information to obtain the identification code corresponding to each line of log information, perform a merge operation on the log information in the running log of each test environment based on all the identification codes obtained, and obtain the test coverage information of the current branch code based on the merge operation result.
2. The code test coverage detection method according to claim 1, characterized in that: The project code information includes a first creation time of each branch code in the target project, and the pipeline information includes a second creation time of each branch code in the target project; After obtaining the test coverage information of the current branch code based on the merge operation result, the method further includes: Matching the first creation time and the second creation time of each branch code; If the current branch code is determined to be the target branch code according to the matching result of the first creation time and the second creation time of each branch code, the test coverage information of the target branch code is identified and displayed.
3. The code test coverage detection method according to claim 2, characterized in that: Determining the current branch code as the target branch code according to the matching result of the first creation time and the second creation time of each branch code includes: If the first creation time and the second creation time of the current branch code are inconsistent, the current branch code is determined to be the target branch code.
4. The code test coverage detection method according to claim 1, characterized in that: The preset transformation includes: Calculate the log information based on the preset cryptographic hash function; Perform a preset transformation on each line of log information to obtain the identification code corresponding to each line of log information, including: The preset encrypted hash function is called to calculate the characters of each line of log information to obtain an identification code for each line of log information, so that when the characters of any two lines of log information are the same, the identification codes calculated by the preset encrypted hash function are the same, and when the characters of any two lines of log information are different, the identification codes calculated by the preset encrypted hash function are different.
5. The code test coverage detection method according to claim 1, characterized in that: Based on all the obtained identification codes, the log information in the running logs of each test environment is merged, including: Determine whether there is a duplicate identification code among all the obtained identification codes; If there are duplicate identification codes, the duplicate identification codes are deduplicated, and the log information corresponding to all the deduplicated identification codes is merged; If there is no duplicate identification code, a merge operation is performed on all log information in the running logs of each test environment.
6. The code test coverage detection method according to claim 1, characterized in that: After obtaining the test coverage information of the current branch code based on the merge operation result, the method further includes: Acquire the source code of each branch code in the target project based on the project code information; Determine the tested code block information in each branch code based on the test coverage information of each branch code; The tested code block information in each branch code is used as an index to determine the corresponding code block in the source code of each branch code as the target code block, and the target code block is dyed with a preset color and displayed.
7. A code test coverage detection device, characterized in that: include: A first data acquisition module is configured to obtain project code information of a target project; A second data acquisition module is configured to obtain pipeline information of the target project based on the project code information of the target project, wherein the pipeline information includes a test environment address; A log collection module is configured to obtain all test environment operation logs of each branch code in the target project through the test environment address based on a preset probe; The coverage calculation module is configured to traverse each line of log information in the running log of each test environment for each branch code, perform a preset transformation on each line of log information to obtain the identification code corresponding to each line of log information, perform a merge operation on the log information in the running log of each test environment based on all the obtained identification codes, and obtain the test coverage information of the current branch code based on the merge operation result.
8. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 6 when executed by a processor.
10. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 6 when being executed by a processor.