Log-based code automatic testing method and device, equipment and medium

Through the automatic code testing method based on logs, the test logs are analyzed and the number of overwritten code lines is stored, which solves the problem of low code testing efficiency in the existing technology, and realizes the effect of automatically identifying uncovered codes and improving testing efficiency.

CN119576767APending Publication Date: 2025-03-07PING AN BANK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411618363.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-12
Publication Date
2025-03-07

AI Technical Summary

Technical Problem

The collection and improvement suggestions for code coverage in the prior art require a lot of manual work and technical knowledge, resulting in low code testing efficiency.

Method used

Through the preset test case library, the target business code is executed, the test log is obtained, the use case execution results are analyzed, the number of overwritten code lines is stored in the code coverage database, and the uncovered code in the updated business code is determined based on the database.

Benefits of technology

Without the participation of testers, developers can automatically identify uncovered code, improving code testing efficiency and use case optimization efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119576767A_ABST
    Figure CN119576767A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of artificial intelligence, and discloses an automatic code testing method and device based on logs, equipment and a medium. The method comprises the following steps: executing a code test on a target business code through a preset test case library, wherein a plurality of test cases corresponding to the target business code are stored in the test case library; obtaining a test log corresponding to the code test; obtaining a target case execution result corresponding to each test case through the test log, wherein the target case execution result comprises a coverage method and a coverage code line number corresponding to the test case; storing the line number of each coverage code into a code coverage database according to a corresponding coverage method; and obtaining an updated service code of the target service code, and determining an uncovered code in the updated service code according to the code coverage database. By implementing the method provided by the embodiment of the invention, the code testing efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the fields of artificial intelligence and financial technology, and in particular to a log-based code automation testing method, device, equipment and medium. Background Art

[0002] Code coverage is an important indicator for measuring the quality of software testing. It describes the proportion of code executed during the test to the total code. High code coverage usually means lower defect rate and higher software quality, especially in financial scenarios. Once a problem occurs after the business code is launched, it will have a very big impact. For example, the code of insurance systems, banking systems, trading systems or order systems will be strictly tested before going online.

[0003] However, collecting code coverage and providing improvement suggestions usually requires a lot of manual work and technical knowledge. The current model is mainly to use dedicated testers to perform code coverage testing, analyze which codes are not covered after the test is completed, and then communicate with developers to let them optimize the test cases. This process requires the participation of testers and developers, and the code testing efficiency is low. Summary of the invention

[0004] The embodiments of the present application provide a log-based code automation testing method, device, equipment and medium, which can improve code testing efficiency.

[0005] In a first aspect, an embodiment of the present application provides a log-based code automation testing method, which includes:

[0006] Perform code testing on the target business code through a preset test case library, wherein the test case library stores multiple test cases corresponding to the target business code;

[0007] Obtain the test log corresponding to the code test;

[0008] Obtaining target case execution results corresponding to each of the test cases through the test log, wherein the target case execution results include the coverage methods and the number of covered code lines corresponding to the test case;

[0009] Store the number of each covered code line in the code coverage database according to the corresponding coverage method;

[0010] An updated service code of the target service code is obtained, and uncovered codes in the updated service code are determined according to the code coverage database.

[0011] In a second aspect, an embodiment of the present application further provides a log-based code automation testing device, which includes:

[0012] An execution unit, configured to execute code testing on a target business code through a preset test case library, wherein the test case library stores a plurality of test cases corresponding to the target business code;

[0013] A first acquisition unit, used to acquire a test log corresponding to the code test;

[0014] A second acquisition unit is used to acquire, through the test log, target case execution results corresponding to each of the test cases, wherein the target case execution results include coverage methods and coverage code lines corresponding to the test case;

[0015] A storage unit, used for storing the number of each covered code line in a code coverage database according to a corresponding coverage method;

[0016] A determination unit is used to obtain an updated service code of the target service code, and determine uncovered codes in the updated service code according to the code coverage database.

[0017] In a third aspect, an embodiment of the present application further provides a computer device, which includes a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the above method when executing the computer program.

[0018] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein the storage medium stores a computer program, wherein the computer program includes program instructions, and wherein the program instructions can implement the above method when executed by a processor.

[0019] The embodiment of the present application provides a log-based code automation testing method, device, equipment and medium. The method includes: performing code testing on the target business code through a preset test case library, wherein the test case library stores multiple test cases corresponding to the target business code; obtaining the test log corresponding to the code test; obtaining the target case execution results corresponding to each of the test cases through the test log, wherein the target case execution results include the coverage method corresponding to the test case and the number of covered code lines; storing each number of covered code lines in a code coverage database according to the corresponding coverage method; obtaining the updated business code of the target business code, and determining the uncovered code in the updated business code according to the code coverage database. The embodiment of the present application can determine the number of covered code lines of existing test cases by analyzing the test logs, and store the analyzed covered code lines in the code coverage database. When the updated business code is obtained, the uncovered code in the updated business code can be automatically analyzed based on the covered code lines in the code coverage database. Without the participation of testers, developers can automatically determine which codes are uncovered codes, allowing developers to optimize use cases more efficiently. It can be seen that the present application can not only automatically perform code testing, but also automatically identify which codes are uncovered codes, thereby improving code testing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0021] Figure 1 A schematic diagram of an application scenario of the log-based code automation testing method provided in an embodiment of the present application;

[0022] Figure 2 A flow chart of a log-based code automation testing method provided in an embodiment of the present application;

[0023] Figure 3 A schematic diagram of a sub-process of a log-based code automation testing method provided in an embodiment of the present application;

[0024] Figure 4 A schematic block diagram of a log-based code automation testing device provided in an embodiment of the present application;

[0025] Figure 5 A schematic block diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0026] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0027] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.

[0028] It should also be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0029] It should be further understood that the term “and / or” used in the specification and appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0030] The embodiments of the present application provide a log-based code automation testing method, device, equipment and medium.

[0031] The executor of the log-based code automation testing method may be the log-based code automation testing device provided in the embodiment of the present application, or a computer device integrating the log-based code automation testing device, wherein the log-based code automation testing device may be implemented in hardware or software, the computer device may be a terminal or a server, and the terminal may be a smart phone, a tablet computer, a PDA, or a laptop computer, etc.

[0032] See also Figure 1 , Figure 1 Schematic diagram of an application scenario of the log-based code automation testing method provided in the embodiment of the present application. The log-based code automation testing method is applied to Figure 1In a computer device in the present invention, the computer device performs code testing on a target business code through a preset test case library, wherein the test case library stores a plurality of test cases corresponding to the target business code; obtains a test log corresponding to the code test; obtains the target case execution results corresponding to each of the test cases through the test log, wherein the target case execution results include the coverage method corresponding to the test case and the number of covered code lines; stores each number of covered code lines in a code coverage database according to the corresponding coverage method; obtains the updated business code of the target business code, and determines the uncovered code in the updated business code according to the code coverage database. Through the present application, developers can automatically determine which codes are uncovered codes without the participation of testers, so that developers can optimize use cases more efficiently, thereby improving code testing efficiency.

[0033] Among them, the target business code in this application can be the code of an insurance system, banking system, transaction system or order system to be launched or updated.

[0034] Figure 2 Schematic diagram of the flow of the log-based code automation testing method provided in the embodiment of the present application. Figure 2 As shown, the method includes the following steps S110-S150.

[0035] S110. Perform code testing on the target business code through a preset test case library, wherein the test case library stores a plurality of test cases corresponding to the target business code.

[0036] In this embodiment, a test case model is first constructed; then, each test case in the test case library is executed on the target business code through the test case model to complete the code test of the target business code.

[0037] Specifically, building a test case model means building a use case execution platform for each test case in the test case library. The test case model pre-configures the use case execution process and use case execution environment of each use case, and then performs code testing on the target business code based on the test case model.

[0038] S120: Obtain a test log corresponding to the code test.

[0039] In this embodiment, during the test execution, a test log is collected, and the test log includes a test case execution log corresponding to each test case.

[0040] Specifically, the use case execution log includes the execution log of successful tests and the execution log of failed tests. For example, when the test case model executes a test case, if the test case is a transaction check request, the test case model will verify the Uniform Resource Locator (URL) of the transaction check request through the interface rules of the code method corresponding to the test case in the target business code, and verify whether the length of the field corresponding to the request meets the interface verification rules, etc. If the above verification fails, the corresponding use case execution log is a test failure log, otherwise the corresponding use case execution log is a test success log.

[0041] S130. Obtain, through the test log, target case execution results corresponding to each of the test cases, wherein the target case execution results include coverage methods and the number of covered code lines corresponding to the test case.

[0042] Specifically, this embodiment determines the test success log in the test case as the target test case, and the target case execution result includes the coverage method and the number of covered code lines corresponding to the test case, wherein the coverage method is the code method covered by the test case, and the number of covered code lines is the number of code lines of the code branches specifically covered in the code method covered by the test case, and a code method contains multiple code branches.

[0043] In some embodiments, the target use case execution result also includes a corresponding coverage class, where one code class contains multiple code methods. The coverage class is used to classify the coverage methods to better store the number of covered code lines based on the classified coverage methods, making it easier for developers to view the number of covered code lines in the coverage database and improve the efficiency of subsequent searches for uncovered code.

[0044] Furthermore, in some embodiments, the target use case execution result also includes corresponding test case keywords (such as test scenario keywords), which are associated with the corresponding number of covered code lines and stored in the database, making it convenient for developers to view which test cases have covered which code in the code coverage database.

[0045] Furthermore, for the test failure log in the test log, the present application will also input the test failure log into a preset log anomaly analysis model, analyze the reason for the test failure, and output the reason for the test failure.

[0046] S140. Store the number of covered code lines in a code coverage database according to the corresponding coverage method.

[0047] In this embodiment, the code coverage database is specifically a MySQL database. In some embodiments, storing each covered code line number in the code coverage database according to the corresponding coverage method includes: classifying each covered code line number according to the coverage method; and storing the classified covered code line number in the code coverage database.

[0048] For example, test case 1 covers branch b in method code A, and branch b corresponds to lines 1-10 in method code A. It can be seen that the coverage method corresponding to test case 1 is method code A, and the corresponding coverage code lines are lines 1-10 under method code A.

[0049] Furthermore, each coverage method is first classified and stored according to the coverage class, and then each coverage code line number is stored under the corresponding coverage method. In some embodiments, when storing the coverage code line number, the corresponding test case keyword is stored in association with the coverage code line number.

[0050] In some embodiments, the test log also includes the execution time corresponding to each test case. In this case, after obtaining the test log corresponding to the code test, the method further includes:

[0051] The execution time corresponding to each test case executed by the test case model is obtained through the test log; it is determined whether there is an overtime execution time greater than a preset time threshold among the multiple execution times; if there is an overtime execution time, a test case execution timeout warning is generated.

[0052] This test case execution timeout warning is used to indicate an abnormal problem in the code or an abnormal problem in the server running the test case model.

[0053] S150: Obtain an updated service code of the target service code, and determine uncovered codes in the updated service code according to the code coverage database.

[0054] Specifically, see Figure 3 , step S150 includes:

[0055] S1501, determining the number of code lines corresponding to each code method in the updated business code;

[0056] S1502, comparing the number of lines of code corresponding to each of the code methods with the number of lines of covered code corresponding to each of the covered methods in the code coverage database, and determining the number of lines of code in the updated business code that does not exist in the code coverage database as the number of uncovered code lines;

[0057] S1503: Determine the code corresponding to the number of uncovered code lines in the updated business code as the uncovered code.

[0058] Specifically, the updated business code is the business code that needs to be tested in the next round of code. The business code can be the original target business code business, or it can be the updated target business code business (including newly added code).

[0059] Furthermore, in order to facilitate developers to identify which codes are not covered, after determining the uncovered codes, this embodiment also dyes the uncovered codes in the updated business code, for example, dyeing them into a yellow background.

[0060] In this embodiment, after the developer prepares the updated business code, the updated business code can be input into the log-based code automation testing device provided by the present application. At this time, the device automatically identifies which codes in the updated business code are not covered by the test case library, so as to facilitate the developer to optimize the test cases for the uncovered codes. At this time, the method further includes:

[0061] Get new use cases built by developers for the uncovered code;

[0062] Adding the newly added test case to the test case library to update the test case library;

[0063] The updated business code is used as the target business code, and the step of performing code testing on the target business code through a preset test case library is returned to be executed.

[0064] Specifically, in this embodiment, the developer constructs test cases based on the uncovered code automatically identified by the device to obtain multiple new test cases. The developer then inputs the new test cases into the device, which automatically adds the new test cases to the test case library, and automatically performs code testing on the updated business code based on the updated test case library, and automatically identifies the uncovered code in the updated business code.

[0065] It can be seen that the log-based code automation testing method provided in this application can not only automate the code testing, but also automatically identify which codes in the code are not covered, making it convenient for developers to optimize test cases.

[0066] In summary, the present application performs code testing on the target business code through a preset test case library, wherein the test case library stores a plurality of test cases corresponding to the target business code; obtains the test log corresponding to the code test; obtains the target case execution results corresponding to each of the test cases through the test log, wherein the target case execution results include the coverage method corresponding to the test case and the number of covered code lines; stores each number of covered code lines in a code coverage database according to the corresponding coverage method; obtains the updated business code of the target business code, and determines the uncovered code in the updated business code according to the code coverage database. The embodiment of the present application can determine the number of covered code lines of the existing test case by analyzing the test log, and stores the number of covered code lines obtained by the analysis in the code coverage database. When the updated business code is obtained, the uncovered code in the updated business code can be automatically analyzed based on the number of covered code lines in the code coverage database. Without the participation of testers, developers can automatically determine which codes are uncovered codes, so that developers can optimize use cases more efficiently, thereby improving code testing efficiency.

[0067] Figure 4 4 is a schematic block diagram of a log-based code automation testing device 400 provided in an embodiment of the present application. Figure 4 As shown, corresponding to the above log-based code automation testing method, the present application also provides a log-based code automation testing device 400. The log-based code automation testing device 400 includes a unit for executing the above log-based code automation testing method. The log-based code automation testing device 400 can be configured in a desktop computer, a tablet computer, a laptop, and other terminals. For details, please refer to Figure 4 The log-based code automation testing device 400 includes an execution unit 401, a first acquisition unit 402, a second acquisition unit 403, a storage unit 404, and a determination unit 405, wherein:

[0068] An execution unit 401 is used to perform code testing on a target business code through a preset test case library, wherein the test case library stores a plurality of test cases corresponding to the target business code;

[0069] In this embodiment, a test case model is first constructed; then, each test case in the test case library is executed on the target business code through the test case model to complete the code test of the target business code.

[0070] Specifically, building a test case model means building a use case execution platform for each test case in the test case library. The test case model pre-configures the use case execution process and use case execution environment of each use case, and then performs code testing on the target business code based on the test case model.

[0071] A first acquisition unit 402 is used to acquire a test log corresponding to the code test;

[0072] In this embodiment, during the test execution, a test log is collected, and the test log includes a test case execution log corresponding to each test case.

[0073] Specifically, the use case execution log includes the execution log of successful tests and the execution log of failed tests. For example, when the test case model executes a test case, if the test case is a transaction check request, the test case model will verify the URL of the transaction check request through the interface rules of the code method corresponding to the test case in the target business code, and verify whether the length of the field corresponding to the request meets the interface verification rules, etc. If the above verification fails, the corresponding use case execution log is a test failure log, otherwise the corresponding use case execution log is a test success log.

[0074] A second acquisition unit 403 is used to acquire, through the test log, target case execution results corresponding to each of the test cases, wherein the target case execution results include the covered methods and the number of covered code lines corresponding to the test case;

[0075] Specifically, this embodiment determines the test success log in the test case as the target test case, and the target case execution result includes the coverage method and the number of covered code lines corresponding to the test case, wherein the coverage method is the code method covered by the test case, and the number of covered code lines is the number of code lines of the code branches specifically covered in the code method covered by the test case, and a code method contains multiple code branches.

[0076] In some embodiments, the target use case execution result also includes a corresponding coverage class, where one code class contains multiple code methods. The coverage class is used to classify the coverage methods to better store the number of covered code lines based on the classified coverage methods, making it easier for developers to view the number of covered code lines in the coverage database and improve the efficiency of subsequent searches for uncovered code.

[0077] Furthermore, in some embodiments, the target use case execution result also includes corresponding test case keywords (such as test scenario keywords), which are associated with the corresponding number of covered code lines and stored in the database, making it convenient for developers to view which test cases have covered which code in the code coverage database.

[0078] Furthermore, for the test failure log in the test log, the present application will also input the test failure log into a preset log anomaly analysis model, analyze the reason for the test failure, and output the reason for the test failure.

[0079] A storage unit 404, used to store the number of each covered code line in a code coverage database according to a corresponding coverage method;

[0080] In this embodiment, the code coverage database is specifically a MySQL database. In some embodiments, storing each covered code line number in the code coverage database according to the corresponding coverage method includes: classifying each covered code line number according to the coverage method; and storing the classified covered code line number in the code coverage database.

[0081] For example, test case 1 covers branch b in method code A, and branch b corresponds to lines 1-10 in method code A. It can be seen that the coverage method corresponding to test case 1 is method code A, and the corresponding coverage code lines are lines 1-10 under method code A.

[0082] Furthermore, each coverage method is first classified and stored according to the coverage class, and then each coverage code line number is stored under the corresponding coverage method. In some embodiments, when storing the coverage code line number, the corresponding test case keyword is stored in association with the coverage code line number.

[0083] In some embodiments, the test log also includes the execution time corresponding to each test case. In this case, after obtaining the test log corresponding to the code test, the method further includes:

[0084] The execution time corresponding to each test case executed by the test case model is obtained through the test log; it is determined whether there is an overtime execution time greater than a preset time threshold among the multiple execution times; if there is an overtime execution time, a test case execution timeout warning is generated.

[0085] This test case execution timeout warning is used to indicate an abnormal problem in the code or an abnormal problem in the server running the test case model.

[0086] The determination unit 405 is used to obtain the updated service code of the target service code, and determine the uncovered code in the updated service code according to the code coverage database.

[0087] In some embodiments, the determining unit 405 is specifically configured to:

[0088] Determine the number of code lines corresponding to each code method in the updated business code; compare the number of code lines corresponding to each code method with the number of covered code lines corresponding to each covered method in the code coverage database, and determine the number of code lines in the updated business code that does not exist in the code coverage database as the number of uncovered code lines; determine the code corresponding to the number of uncovered code lines in the updated business code as the uncovered code.

[0089] Specifically, the updated business code is the business code that needs to be tested in the next round of code. The business code can be the original target business code business, or it can be the updated target business code business (including newly added code).

[0090] Furthermore, in order to facilitate developers to identify which codes are not covered, after determining the uncovered codes, this embodiment also dyes the uncovered codes in the updated business code, for example, dyeing them into a yellow background.

[0091] In some embodiments, the log-based code automation testing device 400 further includes:

[0092] A coloring unit is used to color the uncovered code in the updated business code.

[0093] In some embodiments, the execution unit 401 is specifically used for:

[0094] Construct a test case model; execute each test case in the test case library on the target business code through the test case model to complete the code test of the target business code.

[0095] In some embodiments, the log-based code automation testing device 400 further includes:

[0096] A third acquisition unit is used to acquire, through the test log, the execution time corresponding to each test case executed by the test case model;

[0097] A judging unit, configured to judge whether there is an overtime execution duration greater than a preset duration threshold among the plurality of execution durations;

[0098] The warning unit is used to generate a use case execution timeout warning if the timeout execution duration exists.

[0099] In some embodiments, the storage unit 404 is specifically used for:

[0100] Classify the covered code lines according to the coverage method; and store the classified covered code lines in the code coverage database.

[0101] In some embodiments, the log-based code automation testing device 400 further includes:

[0102] A fourth acquisition unit, used for acquiring a new use case constructed by a developer for the uncovered code;

[0103] An updating unit, used for adding the newly added test case to the test case library to update the test case library;

[0104] The returning unit is used to take the updated service code as the target service code and return to execute the executing unit 401.

[0105] Specifically, in this embodiment, the developer constructs test cases based on the uncovered code automatically identified by the device to obtain multiple new test cases. The developer then inputs the new test cases into the device, which automatically adds the new test cases to the test case library, and automatically performs code testing on the updated business code based on the updated test case library, and automatically identifies the uncovered code in the updated business code.

[0106] It can be seen that the log-based code automation testing method provided in this application can not only automate the code testing, but also automatically identify which codes in the code are not covered, making it convenient for developers to optimize test cases.

[0107] In summary, the log-based code automation testing device 400 in the present application performs code testing on the target business code through a preset test case library, wherein the test case library stores multiple test cases corresponding to the target business code; obtains the test log corresponding to the code test; obtains the target case execution results corresponding to each of the test cases through the test log, wherein the target case execution results include the coverage method corresponding to the test case and the number of covered code lines; stores each number of covered code lines in a code coverage database according to the corresponding coverage method; obtains the updated business code of the target business code, and determines the uncovered code in the updated business code according to the code coverage database. The embodiment of the present application can determine the number of covered code lines of the existing test case by analyzing the test log, and stores the number of covered code lines obtained by the analysis in the code coverage database. When the updated business code is obtained, the uncovered code in the updated business code can be automatically analyzed based on the number of covered code lines in the code coverage database. Without the participation of testers, developers can automatically determine which codes are uncovered codes, so that developers can optimize use cases more efficiently, thereby improving code testing efficiency.

[0108] It should be noted that technicians in the relevant field can clearly understand that the specific implementation process of the above-mentioned log-based code automation testing device and each unit can refer to the corresponding description in the aforementioned method embodiment, and for the convenience and conciseness of the description, it will not be repeated here.

[0109] The above-mentioned log-based code automation testing device can be implemented in the form of a computer program. The computer program can be used in Figure 5 Runs on the computer device shown.

[0110] See also Figure 5 , Figure 5 5 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device 500 may be a terminal or a server, wherein the terminal may be an electronic device with communication functions such as a smart phone, a tablet computer, a laptop computer, a desktop computer, a personal digital assistant, and a wearable device. The server may be an independent server or a server cluster composed of multiple servers.

[0111] See also Figure 5 The computer device 500 includes a processor 502 , a memory and a network interface 505 connected via a system bus 501 , wherein the memory may include a non-volatile storage medium 503 and an internal memory 504 .

[0112] The non-volatile storage medium 503 can store an operating system 5031 and a computer program 5032. The computer program 5032 includes program instructions, and when the program instructions are executed, the processor 502 can execute a log-based code automation testing method.

[0113] The processor 502 is used to provide computing and control capabilities to support the operation of the entire computer device 500 .

[0114] The internal memory 504 provides an environment for the operation of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute a log-based code automation testing method.

[0115] The network interface 505 is used to communicate with other devices over the network. Figure 5 The structure shown in the figure is merely a block diagram of a portion of the structure related to the solution of the present application, and does not constitute a limitation on the computer device 500 to which the solution of the present application is applied. The specific computer device 500 may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0116] The processor 502 is used to run the computer program 5032 stored in the memory to implement the following steps:

[0117] Perform code testing on the target business code through a preset test case library, wherein the test case library stores multiple test cases corresponding to the target business code;

[0118] Obtain the test log corresponding to the code test;

[0119] Obtaining target case execution results corresponding to each of the test cases through the test log, wherein the target case execution results include the coverage methods and the number of covered code lines corresponding to the test case;

[0120] Store the number of each covered code line in the code coverage database according to the corresponding coverage method;

[0121] An updated service code of the target service code is obtained, and uncovered codes in the updated service code are determined according to the code coverage database.

[0122] It should be understood that in the embodiment of the present application, the processor 502 may be a central processing unit (CPU), and the processor 502 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0123] It can be understood by those skilled in the art that all or part of the processes in the method for implementing the above embodiment can be completed by instructing the relevant hardware through a computer program. The computer program includes program instructions, and the computer program can be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the embodiment of the above method.

[0124] Therefore, the present application also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program, wherein the computer program includes program instructions. When the program instructions are executed by a processor, the processor executes the following steps:

[0125] Perform code testing on the target business code through a preset test case library, wherein the test case library stores multiple test cases corresponding to the target business code;

[0126] Obtain the test log corresponding to the code test;

[0127] Obtaining target case execution results corresponding to each of the test cases through the test log, wherein the target case execution results include the coverage methods and the number of covered code lines corresponding to the test case;

[0128] Store the number of each covered code line in the code coverage database according to the corresponding coverage method;

[0129] An updated service code of the target service code is obtained, and uncovered codes in the updated service code are determined according to the code coverage database.

[0130] The storage medium may be a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk, etc., which are computer-readable storage media that can store program codes.

[0131] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0132] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of each unit is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.

[0133] The steps in the method of the embodiment of the present application can be adjusted in order, combined and deleted according to actual needs. The units in the device of the embodiment of the present application can be combined, divided and deleted according to actual needs. In addition, the functional units in the various embodiments of the present application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0134] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, terminal, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application.

[0135] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. A log-based code automation testing method, characterized in that: include: Perform code testing on the target business code through a preset test case library, wherein the test case library stores multiple test cases corresponding to the target business code; Obtain the test log corresponding to the code test; Obtaining target case execution results corresponding to each of the test cases through the test log, wherein the target case execution results include the coverage methods and the number of covered code lines corresponding to the test case; Store the number of each covered code line in the code coverage database according to the corresponding coverage method; An updated service code of the target service code is obtained, and uncovered codes in the updated service code are determined according to the code coverage database.

2. The method according to claim 1, characterized in that The obtaining of the updated service code of the target service code and determining the uncovered code in the updated service code according to the code coverage database includes: Determine the number of code lines corresponding to each code method in the updated business code; Compare the number of lines of code corresponding to each of the code methods with the number of covered lines of code corresponding to each covered method in the code coverage database, and determine the number of lines of code in the updated business code that does not exist in the code coverage database as the number of uncovered lines of code; The code corresponding to the number of uncovered code lines in the updated business code is determined as the uncovered code.

3. The method according to claim 2, characterized in that After determining the code corresponding to the number of uncovered code lines in the updated business code as the uncovered code, the method further includes: The uncovered code in the updated business code is dyed.

4. The method according to claim 1, characterized in that: The code testing of the target business code is performed through a preset test case library, including: Build test case models; Each of the test cases in the test case library is executed on the target business code through the test case model to complete the code test of the target business code.

5. The method according to claim 4, characterized in that After obtaining the test log corresponding to the code test, the method further includes: Obtaining, through the test log, the execution time corresponding to each test case executed by the test case model; Determine whether there is an overtime execution duration greater than a preset duration threshold among the multiple execution durations; If the execution time exceeds the specified execution duration, a use case execution timeout warning is generated.

6. The method according to claim 1, characterized in that The storing of each number of covered code lines in a code coverage database according to the corresponding coverage method includes: Classify and process the number of covered code lines according to the coverage method; The classified covered code lines are stored in the code coverage database.

7. The method according to any one of claims 1 to 6, characterized in that After obtaining the updated service code of the target service code and determining the uncovered code in the updated service code according to the code coverage database, the method further includes: Get new use cases built by developers for the uncovered code; Adding the newly added test case to the test case library to update the test case library; The updated business code is used as the target business code, and the step of performing code testing on the target business code through a preset test case library is returned to be executed.

8. A log-based code automation testing device, characterized in that: include: An execution unit, configured to execute code testing on a target business code through a preset test case library, wherein the test case library stores a plurality of test cases corresponding to the target business code; A first acquisition unit, used to acquire a test log corresponding to the code test; A second acquisition unit is used to acquire, through the test log, target case execution results corresponding to each of the test cases, wherein the target case execution results include coverage methods and coverage code lines corresponding to the test case; A storage unit, used for storing the number of each covered code line in a code coverage database according to a corresponding coverage method; A determination unit is used to obtain an updated service code of the target service code, and determine uncovered codes in the updated service code according to the code coverage database.

9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the log-based code automation testing method according to any one of claims 1 to 7 is implemented.

10. A storage medium, characterized in that: The storage medium stores a computer program, which includes program instructions. When the program instructions are executed by a processor, the processor executes the log-based code automation testing method according to any one of claims 1 to 7.