Unit test method and device, electronic equipment and computer readable medium

By receiving unit test requests, determining the target branch, obtaining the difference file, generating a signature information summary, and inserting probe code, the problem of low code testing efficiency and reliability is solved, and efficient and accurate code testing is achieved.

CN119271546APending Publication Date: 2025-01-07CHINA CONSTRUCTION BANK +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411272634.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-11
Publication Date
2025-01-07

AI Technical Summary

Technical Problem

During the coding research and development process, with the increase in the number of project codes and the number of participants, it is difficult to ensure the quality of the code, resulting in low code testing efficiency and reliability, increasing the development cycle and possibly causing quality problems.

Method used

By receiving unit test requests, determine the target branch, obtain the differential file name set between the target branch and the main branch, generate a summary of signature information, determine the differential method set, and insert probe code to improve the efficiency and reliability of code testing.

Benefits of technology

Improve the efficiency and reliability of code testing, accurately identify and targeted code changes, reduce test time and resources, and ensure code quality and progress.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119271546A_ABST
    Figure CN119271546A_ABST
Patent Text Reader

Abstract

The invention discloses a unit testing method and device, electronic equipment and a computer readable medium, and relates to the technical field of computers.The specific implementation mode comprises the steps that a unit testing request is received, and a corresponding target branch is determined; obtaining a difference file name set between the target branch and the main branch, and determining a difference file set according to the difference file name set; obtaining a method of each binary executable file in the difference file set, and generating a signature information abstract corresponding to the method; determining a difference method set based on the signature information abstract; and inserting a probe code into each difference method in the difference method set, and outputting the collected byte codes to a target file. And the code testing efficiency and reliability are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a unit testing method, device, electronic device and computer-readable medium. Background Art

[0002] At present, in the process of coding development, as the amount of code in the project gradually increases and the number of participants increases, it is difficult to ensure the quality of the written code and to quickly and accurately locate problems in the code, which not only increases the development cycle but also may cause quality problems. The efficiency and reliability of code testing are low. Summary of the invention

[0003] In view of this, embodiments of the present application provide a unit testing method, device, electronic device, and computer-readable medium, which can solve the problems of low efficiency and reliability of existing code testing.

[0004] To achieve the above-mentioned purpose, according to one aspect of an embodiment of the present application, a unit testing method is provided, including: receiving a unit testing request, determining the corresponding target branch; obtaining a set of difference file names between the target branch and the main branch, and determining a difference file set based on the difference file name set; obtaining a method for each binary executable file in the difference file set, and generating a signature information summary corresponding to the method; determining a difference method set based on the signature information summary; inserting probe code into each difference method in the difference method set, and outputting the collected bytecode to the target file.

[0005] Optionally, obtaining a set of difference file names between a target branch and a main branch includes: respectively obtaining a first code of the target branch and a second code stored in a node on the main branch corresponding to the target branch: obtaining a difference file name between the first code and the second code, and then obtaining a set of difference file names.

[0006] Optionally, a difference file set is determined based on the difference file name set, including: copying all binary executable files stored in the nodes corresponding to the target branch on the main branch to a temporary directory at the same level as the target project, and copying all binary executable files corresponding to the target branch to the temporary directory; deleting binary executable files that are not in the difference file name set from the temporary directory to obtain a difference file set.

[0007] Optionally, the signature information digest corresponding to the generation method includes: calculating the signature information digest of basic information and related instructions corresponding to the method based on an information digest algorithm.

[0008] Optionally, determining the difference method set based on the signature information digest includes: obtaining a source code signature information digest corresponding to a corresponding method in the source code; comparing the source code signature information digest with the signature information digest, and then summarizing methods corresponding to signature information digests that are inconsistent with the source code signature information digest to obtain the difference method set.

[0009] Optionally, the method also includes: in response to the end of the unit test, obtaining all compiled files of the project and corresponding version corresponding to the unit test request; calling the code coverage tool to merge the Boolean arrays in the compiled files, and in response to the failure of the merge process, discarding the old Boolean array of the corresponding class, and then generating an output report based on the marking method corresponding to the preset coverage.

[0010] In addition, the present application also provides a unit testing device, including: a receiving unit, configured to receive a unit test request and determine the corresponding target branch; a difference file set determination unit, configured to obtain a difference file name set between the target branch and the main branch, and determine a difference file set based on the difference file name set; a signature information summary generation unit, configured to obtain a method for each binary executable file in the difference file set, and generate a signature information summary corresponding to the method; a difference method set determination unit, configured to determine a difference method set based on the signature information summary; an output unit, configured to insert probe code into each difference method in the difference method set, and output the collected bytecode to the target file.

[0011] Optionally, the difference file set determination unit is further configured to: respectively obtain the first code of the target branch and the second code stored in the node corresponding to the target branch on the main branch: obtain the difference file name between the first code and the second code, and then obtain the difference file name set.

[0012] Optionally, the difference file set determination unit is further configured to: copy all binary executable files stored in the nodes corresponding to the target branch on the main branch to a temporary directory at the same level as the target project, and copy all binary executable files corresponding to the target branch to the temporary directory; delete the binary executable files that are not in the difference file name set from the temporary directory to obtain a difference file set.

[0013] Optionally, the signature information digest generating unit is further configured to: calculate the signature information digest of basic information and related instructions corresponding to the information digest algorithm calculation method.

[0014] Optionally, the difference method set determining unit is further configured to: obtain a source code signature information digest corresponding to a corresponding method in the source code; compare the source code signature information digest with the signature information digest, and then summarize the methods corresponding to the signature information digests that are inconsistent with the source code signature information digest, so as to obtain the difference method set.

[0015] Optionally, the device also includes a report output unit, which is configured to: in response to the end of the unit test, obtain all compiled files of the project and the corresponding version corresponding to the unit test request; call the code coverage tool to merge the Boolean arrays in the compiled files, and in response to the failure of the merge process, discard the old Boolean array of the corresponding class, and then generate an output report based on the marking method corresponding to the preset coverage.

[0016] In addition, the present application also provides a unit testing electronic device, including: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by one or more processors, the one or more processors implement the unit testing method as described above.

[0017] In addition, the present application also provides a computer-readable medium on which a computer program is stored, and when the program is executed by a processor, the unit testing method as described above is implemented.

[0018] To achieve the above objective, according to another aspect of the embodiments of the present application, a computer program product is provided.

[0019] A computer program product according to an embodiment of the present application includes a computer program, and when the program is executed by a processor, the unit testing method provided by the embodiment of the present application is implemented.

[0020] An embodiment of the above invention has the following advantages or beneficial effects: the application determines the corresponding target branch by receiving a unit test request; obtains a difference file name set between the target branch and the main branch, and determines a difference file set based on the difference file name set; obtains a method of each binary executable file in the difference file set, generates a signature information digest corresponding to the method; determines a difference method set based on the signature information digest; inserts probe code into each difference method in the difference method set, and outputs the collected bytecode to the target file. Improve the efficiency and reliability of code testing.

[0021] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] The accompanying drawings are used to better understand the present application and do not constitute an improper limitation on the present application.

[0023] Figure 1 is a schematic diagram of the main process of a unit testing method according to an embodiment of the present application;

[0024] Figure 2 is a schematic diagram of the main process of a unit testing method according to an embodiment of the present application;

[0025] Figure 3 It is a schematic diagram of an incremental code unit testing process of a unit testing method according to an embodiment of the present application;

[0026] Figure 4 is a schematic diagram of the main units of the unit testing device according to an embodiment of the present application;

[0027] Figure 5 is an exemplary system architecture diagram to which the embodiments of the present application can be applied;

[0028] Figure 6 It is a structural diagram of a computer system of a terminal device or server suitable for implementing an embodiment of the present application. DETAILED DESCRIPTION

[0029] The following is an explanation of the exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for the sake of clarity and conciseness, the description of known functions and structures is omitted in the following description. It should be noted that the acquisition, transmission, storage, use, and processing of data in the technical solution of the present application are in compliance with the relevant provisions of national laws and regulations. It should be noted that in the embodiments of the present application, certain software, components, models, and other existing solutions in the industry may be mentioned, which should be considered as exemplary, and their purpose is only to illustrate the feasibility of the implementation of the technical solution of the present application, but it does not mean that the applicant has or must have used the solution. In the technical solution of the present application, the collection, analysis, use, transmission, storage, and other aspects of the user's personal information involved are in compliance with the provisions of relevant laws and regulations, and are used for legal and reasonable purposes, and are not shared, leaked, or sold outside of these legal uses, and are subject to supervision and management by regulatory authorities. Take necessary measures to prevent illegal access to such personal information, ensure that persons with access to personal information comply with relevant laws and regulations, and ensure the security of personal information. Once such personal information is no longer needed, risks should be minimized by limiting or even prohibiting data collection and / or deleting data.

[0030] When used, including in certain related applications, user privacy is protected by de-identifying data, such as by removing specific identifiers when used, controlling the amount or specificity of data stored, controlling how data is stored, and / or other methods of de-identification.

[0031] Figure 1 is a schematic diagram of the main process of the unit testing method according to an embodiment of the present application, such as Figure 1 As shown, the unit testing method mainly includes the following steps S101 to S105.

[0032] Step S101, receiving a unit test request and determining a corresponding target branch.

[0033] In this embodiment, the execution subject of the unit test method (for example, it can be an incremental code testing tool in a server) can receive a unit test request through a wired connection or a wireless connection. Unit testing refers to checking and verifying the smallest testable unit in the software. When the execution subject receives the unit test request, it can determine the target branch corresponding to the request, and the target branch can be a sub-branch of the main branch to be tested.

[0034] Step S102, obtaining a set of difference file names between the target branch and the main branch, and determining a difference file set according to the set of difference file names.

[0035] Compare the target branch with the file names corresponding to the corresponding nodes on the main branch to obtain a set of inconsistent difference file names.

[0036] Specifically, based on the difference file name set, a difference file set is determined, including: copying all binary executable files stored in the nodes corresponding to the target branch on the main branch to a temporary directory at the same level as the target project, and copying all binary executable files corresponding to the target branch to the temporary directory; deleting binary executable files that are not in the difference file name set from the temporary directory to obtain a difference file set.

[0037] Binary executable files, i.e. class files. The target project may be the project corresponding to the project identifier contained in the unit test request received by the execution subject. All binary executable files stored in the nodes corresponding to the main branch and the target branch and all binary executable files corresponding to the target branch are copied to a temporary directory at the same level as the target project, and the binary executable files that are not in the difference file name set are deleted from the temporary directory to accurately obtain the difference file set.

[0038] Step S103, obtaining the method of each binary executable file in the differential file set, and generating a signature information digest corresponding to the method.

[0039] Specifically, the signature information digest corresponding to the generation method includes: calculating the signature information digest of basic information and related instructions corresponding to the method based on the information digest algorithm.

[0040] In some embodiments, each method of a binary executable file may include basic information and related instructions. The execution subject may fuse the basic information and related execution to obtain fused data, and perform information summary algorithm calculation on the fused data to obtain the signature information summary.

[0041] For example, the basic information and related instructions that can be included in the method of each binary executable file are integrated, including: converting the basic information into a basic information vector based on a word embedding method, converting the related instructions into a related instruction vector based on a word embedding method, adding the basic information vector and the related instruction vector to obtain a sum vector, and performing information summary calculation on the sum vector to obtain a signature information summary. By introducing the vector calculation signature information summary, the security of the unit test data can be guaranteed, and the accuracy of determining the incremental data of the difference method can be guaranteed.

[0042] Step S104: determining a difference method set based on the signature information digest.

[0043] Specifically, based on the signature information digest, determining the difference method set includes: obtaining the source code signature information digest corresponding to the corresponding method in the source code; comparing the source code signature information digest with the signature information digest, and then summarizing the methods corresponding to the signature information digests that are inconsistent with the source code signature information digest to obtain the difference method set.

[0044] The signature information digest can be recorded as an MD5 signature. The execution subject can locate the corresponding source code based on the class name, method name and method description corresponding to the method of each binary executable file, and obtain the source code signature information digest corresponding to the corresponding source code. Compare the signature information digest corresponding to the method of each binary executable file with the source code signature information digest of the corresponding source code, and summarize the inconsistent signature information digests to accurately obtain the difference method set consisting of the methods corresponding to the inconsistent signature information digests.

[0045] Step S105 , inserting a probe code into each difference method in the difference method set, and outputting the collected bytecode to a target file.

[0046] By inserting probe codes only for each difference method, the bytecodes collected by the probe codes can be quickly and accurately obtained and output to the target file for subsequent analysis.

[0047] Specifically, the unit testing method also includes: in response to the end of the unit test, obtaining all compiled files of the project and the corresponding version corresponding to the unit test request; calling the code coverage tool to merge the Boolean arrays in the compiled files, and in response to the failure of the merge process, discarding the old Boolean array of the corresponding class, and then generating an output report based on the marking method corresponding to the preset coverage.

[0048] Compiled files are ec files. They contain bytecode, resources, and other related files generated by the Android development tool chain. They are compiled application files and contain the compilation results of the application. By analyzing these files, we can understand the structure and performance characteristics of the application and help developers optimize and debug the application. Boolean arrays are boolean arrays. The marking method corresponding to the preset coverage rate, for example, green: indicates that the line is fully covered, red: indicates uncovered lines, and blank: indicates that the method has not been modified and does not need to be covered.

[0049] When generating a report, the boolean arrays in the ec folder will be merged. Since multiple runs will generate multiple boolean arrays, they need to be processed by merging and taking the OR method. However, if the source code of a class is modified, resulting in inconsistencies in the code in the two packages, this will cause the merging of the boolean arrays of the class to fail. In this case, the old class boolean array needs to be discarded to ensure the accuracy of the report.

[0050] This embodiment receives a unit test request, determines the corresponding target branch; obtains a difference file name set between the target branch and the main branch, and determines a difference file set based on the difference file name set; obtains the method of each binary executable file in the difference file set, generates a signature information summary corresponding to the method; determines a difference method set based on the signature information summary; inserts probe code into each difference method in the difference method set, and outputs the collected bytecode to the target file. Improve the efficiency and reliability of code testing.

[0051] Figure 2 is a schematic diagram of the main flow of a unit testing method according to an embodiment of the present application, such as Figure 2 As shown, the unit testing method mainly includes the following steps S201 to S207.

[0052] Step S201, receiving a unit test request and determining a corresponding target branch.

[0053] Step S202, respectively obtain the first code of the target branch and the second code stored in the node corresponding to the target branch on the main branch.

[0054] In the version control system git, there are nodes corresponding to each sub-branch on the main branch. The main branch refers to the main development line of the project, and the sub-branch is forked from this main branch and is used to develop specific functions or projects. To obtain the first code of the target branch is to obtain the code on the sub-branch corresponding to the main branch that needs unit testing. To obtain the second code stored in the node corresponding to the target branch on the main branch is to obtain the source code stored in the node corresponding to the sub-branch on the main branch that needs unit testing.

[0055] Step S203, obtaining the difference file names between the first code and the second code, and then obtaining a difference file name set.

[0056] The file names in the first code corresponding to the target branch (i.e., the sub-branch) are compared with the file names in the second code stored in the node corresponding to the target branch on the main branch to obtain the file names with differences, and then the file names with differences are summarized to obtain a set of difference file names.

[0057] Step S204, determining a difference file set according to the difference file name set.

[0058] Summarize the binary executable files in the main branch and the target branch, delete the binary executable files that are not in the difference file name set, and form the remaining binary executable files into a difference file set.

[0059] Specifically, the execution subject can compare the file names of the binary executable files in the aggregated main branch and target branch with the file names in the difference file name set, and keep them if they are consistent, and delete them if they are inconsistent, and form the difference file set with the remaining binary executable files, thereby improving the efficiency and accuracy of determining the difference file set.

[0060] Step S205, obtaining the method of each binary executable file in the differential file set, and generating a signature information digest corresponding to the method.

[0061] The execution subject may first concatenate the basic information and related instructions of the method of each binary executable file to obtain concatenated data, and calculate the information digest algorithm for the concatenated data to obtain the signature information digest quickly and accurately.

[0062] Step S206: Determine a difference method set based on the signature information digest.

[0063] The execution subject can locate the corresponding source code based on the class name, method name and method description corresponding to the method of each binary executable file, and obtain the source code signature information digest corresponding to the corresponding source code. The signature information digest corresponding to the method of each binary executable file is compared with the source code signature information digest of the corresponding source code, and inconsistent signature information digests are summarized to accurately obtain a differential method set consisting of methods corresponding to the inconsistent signature information digests.

[0064] Step S207: inserting probe code into each difference method in the difference method set, and outputting the collected bytecode to the target file.

[0065] By inserting probe codes only for each difference method, the bytecodes collected by the probe codes can be quickly and accurately obtained and output to the target file for subsequent analysis.

[0066] Figure 3 It is a schematic diagram of an incremental code unit testing process of a unit testing method according to an embodiment of the present application.

[0067] Diff files: Diff files are text files that record the differences between two code files. A specific format is usually used to represent the differences. Each difference section in the diff file indicates which lines have changed and what has changed, such as new, deleted, or modified lines of code. Diff files are very important tools for software developers because they can help them track code changes, find errors, and solve problems.

[0068] Source code: Source code is the original computer program text written by programmers. It is the basis of application development. Source code contains program logic and instructions to implement specific functions, usually written in a programming language (such as Java). Source code is not only the core of the program, but also an important medium for programmers to collaborate and communicate. In the source code, programmers can make it easier for other programmers to understand and maintain the code through comments and naming conventions. At the same time, source code is also an object of comparison and analysis. In code comparison tools, programmers can find errors and improvements in the code by comparing and analyzing the source code. In short, source code is an indispensable and important part of application development. It is not only the core of the program, but also an important medium for programmers to collaborate and communicate.

[0069] Git: is a distributed version control system widely used in software development. Its main function is to track file changes and record the history of these changes, so as to facilitate development team collaboration, code management, bug tracking, error rollback, etc. Here are some important features and workflows of Git: First, the distributed nature of Git enables each developer to have a complete copy of the code base. This means that developers can work locally without having to connect to the central server all the time. This can greatly improve development efficiency and continue to work even when the network is unstable or there is no network connection. Secondly, Git uses snapshots to store files instead of differences. Each commit creates a snapshot, which can more effectively manage and store historical versions of files. At the same time, Git can also quickly compare files, which facilitates code review and merging. In addition, Git provides powerful branch management functions. Developers can easily create, switch, merge and delete branches, so that multiple parallel development work can be carried out at the same time. This allows team members to develop independently without affecting the main line code, and finally merge the work results into the main branch. Git also has a highly flexible workflow. Developers can choose the appropriate workflow according to the needs of the team and the characteristics of the project, such as centralized workflow, functional branch workflow, Gitflow, etc. These workflows can help the team better organize and manage the code and improve development efficiency. Git branch management: Git's branch management is one of its most powerful features. It enables the team to carry out multiple parallel development work at the same time without affecting the main line code. Branch management allows developers to carry out multiple parallel development work in the same code base at the same time. By creating branches, developers can carry out new feature development, bug fixes, etc. without affecting the main line code. When merging branches, the changes of each branch can be integrated into the main branch in an orderly manner to ensure the stability and integrity of the code. Branch management can also help team members collaborate better, reduce the risk of code conflicts, and improve development efficiency. By using branch management properly, the team can respond to changes in project requirements more flexibly and carry out software development more efficiently.

[0070] Inserting probes: In Android projects, inserting probes is a common technical means for monitoring, debugging and performance optimization of application operations. Inserting probes is usually achieved by inserting specific monitoring points or log outputs in the code to obtain various information about the application at runtime. First, inserting probes can be used to monitor the running status and behavior of the application. By inserting monitoring points at key locations, developers can record information such as the execution path, method calls, event triggers, etc. of the application. This information is very helpful for troubleshooting application errors, analyzing performance bottlenecks, optimizing code structure, etc. Secondly, inserting probes can also be used to debug applications. Developers can insert log outputs where problems need to be troubleshooted to output information such as the values ​​of related variables and the execution status of methods. This can help developers locate problems more quickly, thereby speeding up debugging and repairing. In addition, inserting probes can also be used for performance optimization. By inserting monitoring points at key performance points, developers can monitor the performance indicators of the application in real time, such as CPU usage, memory usage, response time, etc., and can optimize based on the monitoring results. For example, if it is found that the execution time of a method is too long, the method can be optimized in a targeted manner to improve the performance of the application.

[0071] ec file: ec file usually refers to the compiled file (EC) in Android. These files contain bytecode, resources and other related files compiled by the Android development tool chain. They are compiled application files. ec files are files generated after Android compilation and contain the compilation results of the application. By analyzing these files, you can understand the structure and performance characteristics of the application and help developers optimize and debug the application.

[0072] Unit testing: Android unit testing is a software testing method that aims to verify that the functions of individual units in an Android application operate as expected. These units can be classes, methods, modules, or components, which are tested in an isolated environment to ensure that they behave properly in terms of interaction and functionality in the application. The main purpose of Android unit testing is to improve code quality, reduce defects, and ensure the stability of the application. It helps developers quickly find and fix errors in the code and ensure that the code does not break existing functions when adding new features or refactoring. This testing method can find and solve problems in the early stages of the development cycle, saving time and cost. When performing Android unit testing, testing frameworks such as JUnit are usually used. Developers write test cases to test individual units in the application. Test cases include input data, expected output, and code to perform the test. By running these test cases, developers can verify that the code is written as expected and that when changes are made, they can ensure that existing functions are not broken. Incremental code: Android's incremental code is an application update technology. The basic principle is to compare and apply only the changed parts of the code instead of the entire source code. This method compares the differences between the new and old versions. Android's incremental code technology usually relies on differential algorithms. These algorithms compare the differences between two application versions and then generate an incremental difference that contains the changes between the new version and the old version. This allows the source code to be updated to the latest version. This method avoids the need to download the entire source code, greatly improving the efficiency of the update.

[0073] Code coverage: Code coverage is an important indicator in software testing, which is used to measure the coverage of the code by test cases. It indicates the proportion of code lines or code blocks involved in the test process. Coverage is usually divided into several types, including statement coverage, branch coverage, function coverage, etc. Each type is used to measure code coverage at different levels. Monitoring and improving code coverage is an important part of software quality assurance. It helps to improve the stability and reliability of the software and reduce potential risks caused by uncovered code paths.

[0074] Automation: Automation plays a key role in software development, accelerating the development process by reducing manual operations, improving efficiency, and reducing error rates. Developers can use the code hints, automatic formatting, and refactoring functions provided by automation tools to improve code quality and readability. In the build and test phases, automation can accelerate the build process, provide quick feedback, and ensure code quality and functional stability through automated build tools and test frameworks. Automated task scheduling tools can automate regular tasks and workflows to improve work efficiency. In general, automation helps development teams improve efficiency, reduce costs, and focus more on creative work, thereby accelerating the software development process and improving software quality.

[0075] like Figure 3 As shown, the incremental code unit test process includes instrumentation during code compilation - program runtime - report generation. Specifically, instrumentation is performed during code compilation, including the following processes: class git management: submit classes files to git; obtain difference method: obtain two branch codes respectively, analyze the differences between the two branches through scripts, and generate a difference code set; insert probes into the difference code. When the program is running: the program runtime state changes, the runtime data is saved and the ec file is generated, and the ec file is uploaded to the server when the program is run next time. Generate report: download all ec files, obtain difference sets, merge files, generate ec files, analyze class files, and generate reports.

[0076] For example, the project code management tool is GIT, which can also be written as git. There are many branches based on the master branch line. During development, branches will be pulled from the master, and development, testing, and joint debugging will be performed on this branch. After the test is correct, the closed board will be merged into the master branch. Specifically, open the visual interface; select the development branch; click Run; and finally, the unit test of the corresponding incremental code can be produced.

[0077] The unit test principle of the embodiment of the present application is briefly described as follows:

[0078] Instrumentation is performed when the code is compiled:

[0079] 1. Class git management: The project contains Java and Kotlin source codes, which need to be adapted to the two languages ​​for parsing. After compilation, they are all class files, which can be parsed by ASM. At the same time, ASM is also required to use Jacoco, so the class files corresponding to the source code need to be saved, but only the class files with custom package names (such as com.ttpc) are saved. The third-party source code is considered stable and does not require coverage testing. The compiled class files are copied to the project app directory (at the same level as src) and managed through git. Subsequently, the git add, commit, and push commands are automatically executed to submit the changes to the git server in order to obtain the difference file names between the two server branches.

[0080] 2. Get two branch difference method sets: During the compilation and report generation process, you must get "two branch difference method sets". One branch is the current development branch (such as dev_3), and the other is the master branch (configurable). The difference method definition includes new and modified methods. Even if only one line of code is modified, it is considered a difference method and the entire method needs to be covered. The current branch can be obtained through the git name-rev --name-only HEAD command.

[0081] 2.1. Get the set of difference file names: With git, you can easily get the difference file names between two branches. After executing the command git diff origin / dev_3 origin / master --name-only, a list of difference file names will be output, with each file name separated by a newline character \n. In order to get a set of difference class file names, you need to filter out non-class files and non-package name files. After completing this step, you get the difference class file names between the two branches. However, this is not accurate enough, and we need to further determine which methods are actually different.

[0082] 2.2. Copy the difference files between the two branches: Switch to the master branch and copy all class files to a temporary directory at the same level as the project. Then, return to the current dev_3 branch and copy all class files to the temporary directory again. Next, delete the files that are not in the difference file name set to obtain the difference file set.

[0083] 2.3. Generate differential method sets: Use the ASM (Automatic Storage Management) library to traverse all class files in the two branch directories, read and visit the methods of each class file, and collect relevant method information. MethodVisitor provides many visitXxx methods, covering the basic information and related instructions of the methods. By applying the MD5 algorithm to these methods, the MD5 signature of the method can be generated. Combining the class name className, method name methodName and description desc, you can accurately locate a specific method and compare whether its MD5 signature is consistent. If the signatures are consistent, it means that the code has not been modified. In this process, you need to pay special attention to the visitLdcInsn method that obtains the string constant because it involves accessing the constant pool. Since the resource ID may change every time you compile, you need to filter these IDs. After visiting all classes, you can compare the two branch method sets to get the differential method set.

[0084] 2.4. Insert probe code: Use the instrument function of Jacoco to output the bytecode after the probe is inserted to the specified file. Instrument is a testing tool for performance analysis, dynamic tracking and analysis of OS X and iOS code. It provides functions such as CPU performance testing, graphics performance testing, and memory performance testing, allowing users to track the process of program running, collect data, and check the collected data. In the visitMethod of ClassInstrumenter, accurately determine whether it is a difference method, and decide whether to insert code based on this. This method ensures that code is only inserted for difference methods, improving efficiency and accuracy.

[0085] When the program is running: The coverage principle of Jacoco is that each class will be assigned a boolean array, which is an array of Boolean values. Before each line of code, an operation array[x]=true will be inserted. When the code is executed, the corresponding array[x] will be set to true, indicating that the code has been executed. At the end of the program, all boolean arrays will be saved as local ec files. The next time the application is started, these data will be uploaded to the server.

[0086] Generate report: Generating report is a flexible task that can be triggered actively on demand or automatically executed during packaging. Its core logic is as follows: First, download all ec files of this version of the project from the server, that is, the data files uploaded at runtime. Then, according to the logic at compile time, obtain the difference method set. Finally, call the report generation method of the open source code coverage tool jacoco, pass in parameters such as ec folder, class folder path, source code path and report output path, and a detailed html report can be generated. When generating the report, the Boolean array in the ec folder will be merged. The ec file is an electronic document format used to store and transmit various types of data. This file format may contain a variety of media content such as text, images, audio, video, etc., depending on the design and needs of the file creator. Since multiple runs will generate multiple boolean arrays, they need to be processed by merging and taking or. However, if the source code of a class is modified, resulting in inconsistent code in the two packages, this will cause the merging of the boolean array of the class to fail. In this case, the old class boolean array needs to be discarded to ensure the accuracy of the report. The final report is an HTML file. You can see the overall coverage by opening the output report. You can click in to view the coverage of a certain class. Green means that the line is fully covered; red means that the line is not covered; blank means that the method has not been modified and does not need to be covered.

[0087] The unit testing method of the embodiment of the present application can improve the efficiency of development and testing, and ensure the quality and progress of the project. Through incremental code testing, the newly added or modified code parts in the project code submission record can be accurately identified, and targeted unit tests can be performed on them, so that unit testing work can be performed more efficiently. Developers can run tests before submitting the code to ensure that the newly added or modified code will not introduce new errors, thereby improving the quality of the code. Testers can focus more on testing the newly added or modified functions, reducing the repeated testing of the entire project code and improving the testing efficiency. Efficiency improvement: The embodiment of the present application has obvious advantages in terms of efficiency improvement. Through the embodiment of the present application, testing for the newly added or modified code can avoid retesting the entire program, thereby greatly saving time and computing resources, thereby improving efficiency. Through rigorous algorithms and fine comparisons, only the newly added or modified code is tested, without the need to test the entire program. The advantage of doing this is that it can help developers quickly discover and fix potential problems, while also reducing the time and resources required for testing. With the development and changes of software projects, most of the code may be stable and unchanged, so retesting the entire program may be inefficient and unnecessary, which can help the team develop and test more efficiently. Higher accuracy: The algorithm and processing technology of the embodiment of the present application, by focusing more on the changed code, the incremental code testing tool can locate the problem more accurately and improve the accuracy of the test. Traditional code unit testing usually involves a complete test of the entire program, which may be difficult to accurately locate the problems encountered in this open process, because it will cause the unit test to have low accuracy. Through rigorous algorithms to ensure that the code is more focused on the changes, the incremental testing tool can review each change in the program more deeply and ensure targeted unit testing. This method helps to focus the test on the areas where problems are most likely to occur, thereby improving the accuracy of the test. Automation: The embodiment of the present application introduces an efficient automation method. In this way, the whole process of code comparison, project construction, unit testing, test report generation, and test report display can be completed without human intervention. This automated process greatly improves the efficiency of development and testing, saving valuable time and human resources. Not only that, the automated method can also reduce the possibility of human error and ensure the accuracy and consistency of the testing process. In addition, through the detailed test reports generated by automation, the team can have a clearer understanding of the test coverage and quality status of the project, so as to make adjustments and improvements in time. The automation of the entire process also provides strong support for continuous integration and continuous delivery, making the software development process smoother and more efficient. Easier to maintain: Through the embodiments of the present application, clearer test reports and logs can be obtained. These reports and logs not only provide detailed test results, but also present key information in the test process, making the test results easier to understand and maintain.Through these reports and logs, team members can quickly understand the progress and results of the test, reducing communication costs and improving the team's work efficiency.

[0088] In addition, the embodiments of the present application can also help teams better cooperate and pass on knowledge. During the testing process, team members can exchange ideas, discover problems, and solve them in a timely manner by sharing test reports and logs. This spirit of cooperation promotes communication and collaboration between teams, allowing team members to work together to solve problems together.

[0089] In addition, the embodiment of the present application records the historical information of each test, including the test environment, test cases, test results, etc., which helps team members understand the evolution and changes of the system, so as to better carry out knowledge inheritance and technology accumulation. Team members can quickly understand the functional changes and problem repairs of the system by consulting the test reports and logs, so as to better maintain and iterate the system.

[0090] Higher code coverage: The embodiments of the present application identify and analyze changes in the code and conduct targeted testing to ensure that each change is fully covered. This means that even minor code changes can be effectively captured and tested, thereby improving the ability to detect potential problems.

[0091] The embodiment of the present application focuses on the changed code, and is committed to more accurately covering the potential problems that may be caused by the change, thereby greatly improving the coverage of the test. Compared with the traditional overall test method, it no longer needs to fully test the entire program, thereby reducing the consumption of resources and time. Although the traditional overall test method is comprehensive, it may still be impossible to fully test the partially modified code, so there is a risk of missing problems. The embodiment of the present application ensures that each change can be tested in a targeted manner by accurately identifying and analyzing the changes in the code, thereby achieving comprehensive coverage of the changes.

[0092] The introduction of incremental code testing tools can effectively improve test efficiency and reliability, help reduce test cycles, reduce test costs, accelerate feedback loops, improve test coverage, optimize test resource utilization, and improve the stability of test results, thereby promoting the smooth progress of software development, testing, and release processes, and promoting the smooth delivery of projects and the improvement of user satisfaction. Through the embodiments of the present application, the code coverage of unit tests can be significantly improved, and the software quality can be effectively ensured. By implementing the embodiments of the present application, not only can the project cost be effectively reduced, but also the economic benefits can be significantly improved. By implementing the embodiments of the present application, the development efficiency will be greatly improved, the software quality will be ensured, and a better experience will be brought to users. The embodiments of the present application are intended to optimize the code testing process, improve code quality, and reduce potential risks, thereby ensuring the stability and reliability of software development. The embodiments of the present application have the ability to accurately locate problems and quickly overcome thorny problems in development and testing. Through the incremental code unit testing tool, the entire R&D, testing, and production process can be fully optimized. This tool not only significantly improves development efficiency and makes code writing faster and more accurate, but also significantly improves code coverage and ensures the quality and stability of the software. In addition, through automated testing, testing costs have been effectively reduced, reducing the time and resources required for manual testing. More importantly, this tool plays an important role in reducing the rate of error introduction, reducing software failures and maintenance costs caused by code errors.

[0093] Incremental code unit testing tools also play an important role in continuous integration, continuous delivery, and agile development. Through automated testing and continuous integration, development teams can work together more efficiently to ensure the quality and stability of the code. At the same time, continuous delivery allows software products to be brought to market faster to meet user needs. The application of this tool allows development teams to focus more on innovation and user experience optimization, thereby achieving greater success.

[0094] In general, incremental code unit testing tools play an important role in the entire software development process, not only improving development efficiency and code coverage, but also reducing testing costs, error introduction and maintenance costs. By promoting continuous integration, continuous delivery and agile development, these tools bring higher work efficiency and better software quality to the development team, providing strong support for the success of the enterprise.

[0095] Incremental code unit testing tools quickly test the modified parts of the code, avoiding the tedious process of running the entire test suite every time. This precise testing method greatly saves time, allowing developers to focus more on solving specific problems without waiting for the entire test suite to complete to get results. This fast feedback loop effectively accelerates the development iteration cycle and improves the productivity and efficiency of the development team.

[0096] Incremental code unit testing tools are very important software development tools that are specifically designed to ensure that each code change is covered by the appropriate tests. The main advantage of this tool is that it can focus on testing the modified parts, thereby more comprehensively covering different paths and edge cases of the code. In this way, incremental code unit testing tools can help developers improve overall code coverage and ensure that all parts of the software are fully tested.

[0097] Compared with traditional overall testing, incremental code unit testing tools can significantly reduce testing costs. Because only the modified parts need to be tested, there is no need to run the full test suite every time, saving a lot of time and resources. This is especially important for large projects or frequent code modifications, which can effectively control the cost of the testing process.

[0098] By running unit tests immediately after code modifications, incremental testing tools can promptly discover and locate errors introduced by modifications. This fast feedback loop helps developers find and resolve problems before the code is written to the version control system, thereby reducing the propagation of errors in the code base and reducing maintenance costs.

[0099] Incremental code unit testing tools are an integral part of continuous integration and continuous delivery. They automatically run unit tests to reveal and report potential problems in real time, thereby ensuring the stability and reliability of each code submission. This tool not only reduces integration risks and speeds up delivery, but also enhances the team's confidence in software quality.

[0100] Incremental code unit testing tools are an integral part of the agile development and iteration process. As requirements continue to change and code is updated quickly, unit testing tools can quickly adapt and provide timely test feedback. This feedback mechanism enables teams to respond to customer needs more flexibly, adjust development plans in a timely manner, and deliver high-quality software products in a shorter cycle. In addition, unit testing tools can also help teams identify and fix defects and vulnerabilities in the code, thereby improving code quality and maintainability. Therefore, in the agile development and iteration process, incremental code unit testing tools play a vital role and provide strong support for the team's successful delivery.

[0101] In short, incremental code unit testing tools not only improve development efficiency, code coverage and software quality, but also reduce testing costs, error introduction and maintenance costs, while promoting continuous integration, continuous delivery and agile development. By using these tools, development teams can develop and deliver high-quality software products more efficiently, thereby achieving greater success.

[0102] The embodiment of the present application aims to help developers and testers test only the modified part of the code through the incremental code testing tool, thereby greatly reducing the cost and time of testing. The embodiment of the present application can help developers and testers to automatically run relevant tests for each code modification, ensure that more code paths are covered, and improve test coverage. The embodiment of the present application can help developers quickly view code changes and promptly discover errors caused by code modifications, and provide detailed error reports and location information to help developers quickly fix problems. The embodiment of the present application can make the testing process more automated and efficient, thereby supporting the practice of continuous integration and continuous deployment. Through the embodiment of the present application, by running tests on each incremental code, providing real-time test results and timely feedback, it can help developers quickly adjust and fix problems. Through the embodiment of the present application, the demand for test environment resources can be reduced, because only the modified part of the code needs to be tested each time, thereby saving resource costs. Through the embodiment of the present application, only the modified part of the code is focused on, unnecessary interference factors are reduced, the test results are more reliable, and more stable test results are provided.

[0103] The introduction of incremental code testing tools can effectively improve testing efficiency and reliability, help reduce testing cycles, reduce testing costs, accelerate feedback loops, improve test coverage, optimize test resource utilization, and improve the stability of test results, thereby promoting the smooth progress of software development, testing, and release processes, and promoting the smooth delivery of projects and the improvement of user satisfaction.

[0104] Figure 4 Schematic diagram of the main units of the unit testing device according to an embodiment of the present application. Figure 4 As shown, the unit testing device 400 includes a receiving unit 401 , a difference file set determining unit 402 , a signature information digest generating unit 403 , a difference method set determining unit 404 and an output unit 405 .

[0105] The receiving unit 401 is configured to receive a unit test request and determine a corresponding target branch.

[0106] The difference file set determining unit 402 is configured to obtain a difference file name set between the target branch and the main branch, and determine a difference file set according to the difference file name set.

[0107] The signature information digest generating unit 403 is configured to obtain the method of each binary executable file in the difference file set and generate a signature information digest corresponding to the method.

[0108] The difference method set determining unit 404 is configured to determine a difference method set based on the signature information digest.

[0109] The output unit 405 is configured to insert a probe code into each difference method in the difference method set, and output the collected bytecode to a target file.

[0110] In some embodiments, the difference file set determination unit 402 is further configured to: respectively obtain the first code of the target branch and the second code stored in the node corresponding to the target branch on the main branch: obtain the difference file name between the first code and the second code, and then obtain the difference file name set.

[0111] In some embodiments, the difference file set determination unit 402 is further configured to: copy all binary executable files stored in the nodes corresponding to the target branch on the main branch to a temporary directory at the same level as the target project, and copy all binary executable files corresponding to the target branch to the temporary directory; delete the binary executable files that are not in the difference file name set from the temporary directory to obtain a difference file set.

[0112] In some embodiments, the signature information digest generating unit 403 is further configured to: calculate the signature information digest of the basic information and related instructions corresponding to the information digest algorithm.

[0113] In some embodiments, the difference method set determining unit 404 is further configured to: obtain a source code signature information digest corresponding to a corresponding method in the source code; compare the source code signature information digest with the signature information digest, and then summarize the methods corresponding to the signature information digests that are inconsistent with the source code signature information digest to obtain the difference method set.

[0114] In some embodiments, the unit testing device further includes Figure 4 The report output unit not shown in the figure is configured to: in response to the end of the unit test, obtain all compiled files of the project and the corresponding version corresponding to the unit test request; call the code coverage tool to merge the Boolean arrays in the compiled files, and in response to the failure of the merge process, discard the old Boolean array of the corresponding class, and then generate an output report based on the marking method corresponding to the preset coverage.

[0115] It should be noted that the unit testing method and the unit testing device of the present application have a corresponding relationship in terms of specific implementation contents, so the repeated contents will not be described again.

[0116] Figure 5 An exemplary system architecture 500 is shown to which the unit testing method or unit testing apparatus according to the embodiment of the present application can be applied.

[0117] like Figure 5As shown, system architecture 500 may include terminal devices 501, 502, 503, a network 504 and a server 505. Network 504 is used to provide a medium for communication links between terminal devices 501, 502, 503 and server 505. Network 504 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0118] Users can use terminal devices 501, 502, 503 to interact with server 505 through network 504 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 501, 502, 503, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only for example).

[0119] The terminal devices 501 , 502 , and 503 may be various electronic devices having a unit test processing screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0120] Server 505 can be a server that provides various services, such as a background management server that provides support for unit test requests submitted by users using terminal devices 501, 502, and 503 (only as an example). The background management server can receive the unit test request and determine the corresponding target branch; obtain the difference file name set between the target branch and the main branch, and determine the difference file set based on the difference file name set; obtain the method of each binary executable file in the difference file set, and generate the signature information summary corresponding to the method; determine the difference method set based on the signature information summary; insert probe code into each difference method in the difference method set, and output the collected bytecode to the target file. Improve the efficiency and reliability of code testing.

[0121] It should be noted that the unit testing method provided in the embodiment of the present application is generally executed by the server 505 , and accordingly, the unit testing device is generally set in the server 505 .

[0122] It should be understood that Figure 5 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0123] Reference below Figure 6 , which shows a schematic diagram of the structure of a computer system 600 of a terminal device suitable for implementing an embodiment of the present application. Figure 6 The terminal device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0124] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the computer system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0125] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.

[0126] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present application are executed.

[0127] It should be noted that the computer-readable medium shown in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. Computer-readable storage media may include, for example, but are not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0128] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the above-mentioned module, program segment or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0129] The units involved in the embodiments described in the present application may be implemented by software or hardware. The units described may also be set in a processor, for example, it may be described as: a processor includes a receiving unit, a difference file set determination unit, a signature information summary generation unit, a difference method set determination unit and an output unit. The names of these units do not constitute limitations on the units themselves in some cases.

[0130] As another aspect, the present application also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs. When the above one or more programs are executed by a device, the device receives a unit test request and determines the corresponding target branch; obtains a difference file name set between the target branch and the main branch, and determines a difference file set based on the difference file name set; obtains the method of each binary executable file in the difference file set, and generates a signature information summary corresponding to the method; determines a difference method set based on the signature information summary; inserts probe code into each difference method in the difference method set, and outputs the collected bytecode to the target file.

[0131] The computer program product of the present application includes a computer program, and when the computer program is executed by a processor, the unit testing method in the embodiment of the present application is implemented.

[0132] According to the technical solution of the embodiment of the present application, the efficiency and reliability of code testing can be improved.

[0133] The above specific implementations do not constitute a limitation on the protection scope of this application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of this application should be included in the protection scope of this application.

Claims

1. A unit testing method, characterized in that: include: Receive unit test requests and determine the corresponding target branch; Obtain a set of difference file names between the target branch and the main branch, and determine a difference file set based on the set of difference file names; A method for obtaining each binary executable file in the differential file set, and generating a signature information digest corresponding to the method; Based on the signature information digest, determining a difference method set; A probe code is inserted into each difference method in the difference method set, and the collected bytecode is output to a target file.

2. The method according to claim 1, characterized in that The step of obtaining a set of difference file names between the target branch and the main branch includes: Respectively obtain the first code of the target branch and the second code stored in the node corresponding to the target branch on the main branch: The difference file names between the first code and the second code are obtained, thereby obtaining a difference file name set.

3. The method according to claim 1, characterized in that: Determining the difference file set according to the difference file name set includes: Copy all binary executable files stored in the node corresponding to the target branch on the main branch to a temporary directory at the same level as the target project, and copy all binary executable files corresponding to the target branch to the temporary directory; The binary executable files that are not in the difference file name set are deleted from the temporary directory to obtain a difference file set.

4. The method according to claim 1, characterized in that: The generating of the signature information digest corresponding to the method includes: The basic information corresponding to the method and the signature information digest of the related instructions are calculated based on the information digest algorithm.

5. The method according to claim 1, characterized in that The determining of a difference method set based on the signature information digest includes: Get the source code signature information summary corresponding to the corresponding method in the source code; The source code signature information digest is compared with the signature information digest, and methods corresponding to signature information digests that are inconsistent with the source code signature information digest are summarized to obtain a difference method set.

6. The method according to claim 1, characterized in that The method further comprises: In response to the unit test being completed, obtaining all compiled files of the project and the corresponding version corresponding to the unit test request; A code coverage tool is called to merge the Boolean arrays in the compiled file, and in response to a merging failure, an old Boolean array of the corresponding class is discarded, and an output report is generated based on a marking method corresponding to a preset coverage.

7. A unit testing device, characterized in that: include: A receiving unit, configured to receive a unit test request and determine a corresponding target branch; a difference file set determining unit, configured to obtain a difference file name set between the target branch and the main branch, and determine a difference file set according to the difference file name set; A signature information digest generating unit, configured to obtain a method for each binary executable file in the difference file set, and generate a signature information digest corresponding to the method; a difference method set determining unit, configured to determine a difference method set based on the signature information digest; The output unit is configured to insert a probe code into each difference method in the difference method set, and output the collected bytecode to a target file.

8. The device according to claim 7, characterized in that The difference file set determining unit is further configured to: Respectively obtain the first code of the target branch and the second code stored in the node corresponding to the target branch on the main branch: The difference file names between the first code and the second code are obtained, thereby obtaining a difference file name set.

9. The device according to claim 7, characterized in that The difference file set determining unit is further configured to: Copy all binary executable files stored in the node corresponding to the target branch on the main branch to a temporary directory at the same level as the target project, and copy all binary executable files corresponding to the target branch to the temporary directory; The binary executable files that are not in the difference file name set are deleted from the temporary directory to obtain a difference file set.

10. The device according to claim 7, characterized in that The signature information digest generation unit is further configured to: The basic information corresponding to the method and the signature information digest of the related instructions are calculated based on the information digest algorithm.

11. The device according to claim 7, characterized in that The difference method set determination unit is further configured to: Get the source code signature information summary corresponding to the corresponding method in the source code; The source code signature information digest is compared with the signature information digest, and methods corresponding to signature information digests that are inconsistent with the source code signature information digest are summarized to obtain a difference method set.

12. The device according to claim 7, characterized in that The apparatus further comprises a report output unit configured to: In response to the unit test being completed, obtaining all compiled files of the project and the corresponding version corresponding to the unit test request; A code coverage tool is called to merge the Boolean arrays in the compiled file, and in response to a merging failure, an old Boolean array of the corresponding class is discarded, and an output report is generated based on a marking method corresponding to a preset coverage.

13. A unit testing electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.

14. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.