Automatic testing method, device and equipment based on code change and storage medium
By analyzing code change records and automatically matching test cases, the problem of traditional regression testing methods relying on manual evaluation is solved, and the testing efficiency and coverage are improved.
Patent Information
- Application Number
- CN202411362692.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2025-02-14
AI Technical Summary
Traditional regression testing methods rely on manually evaluating the impact of code changes on existing functions, resulting in blind spots and inefficiency in testing.
By analyzing the current code change record, determining the scope of code changes, and automatically matching or generating corresponding test cases based on the code change record, ensuring that all affected functions are covered by the test.
It reduces the error introduced by manual evaluation, improves test coverage, reduces the time for manual testing and report writing, and improves code testing efficiency during software testing.
Smart Images

Figure CN119441024A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology and is applied to the field of financial business technology, and in particular to an automated testing method, device, equipment and storage medium based on code changes. Background Art
[0002] During the software development lifecycle, software systems often need to be iteratively updated to introduce new features, fix defects, or optimize performance. Each iteration may affect the existing functions of the system. In the traditional regression testing method, during the iteration process, developers or testers need to manually evaluate the impact of code changes on existing functions, and based on the evaluation results, decide whether to perform manual testing or execute pre-written test case scripts. Traditional regression testing methods rely on testers to manually perform tests, record test results, and verify the correctness of functions. With the iteration of software, test cases need to be continuously updated and maintained to ensure that they are consistent with the current software version. Manual evaluation is difficult to fully cover all functions that may be affected, which may lead to testing blind spots. Therefore, how to improve the efficiency of code testing in the software testing process has become a technical problem that needs to be solved urgently. Summary of the invention
[0003] The present application provides an automated testing method, apparatus, device and storage medium based on code changes to improve the efficiency of code testing during software testing.
[0004] In a first aspect, the present application provides an automated testing method based on code changes, the method comprising:
[0005] Based on the current code, determining a current code change record corresponding to the current code;
[0006] Determine, according to the code change record, a target code test case corresponding to the current code;
[0007] The current code is tested through the target code test case, and a target test report of the current code is generated.
[0008] In a second aspect, the present application further provides an automated testing device based on code changes, the device comprising:
[0009] A current code change record determination module, used to determine, based on the current code, the current code change record corresponding to the current code;
[0010] A target code test case determination module, used to determine a target code test case corresponding to the current code according to the code change record;
[0011] The code testing module is used to test the current code through the target code test case and generate a target test report for the current code.
[0012] In a third aspect, the present application also provides a computer device, comprising a memory and a processor; the memory is used to store a computer program; the processor is used to execute the computer program and implement the above-mentioned automated testing method based on code changes when executing the computer program.
[0013] In a fourth aspect, the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor implements the above-mentioned automated testing method based on code changes.
[0014] The present application discloses an automated testing method, apparatus, device and storage medium based on code changes, wherein the automated testing method based on code changes includes determining the current code change record corresponding to the current code based on the current code; determining the target code test case corresponding to the current code according to the code change record; testing the current code through the target code test case, and generating a target test report for the current code. In the above manner, the present application can accurately identify the scope of code changes by analyzing the current code change record, thereby reducing the errors introduced by manual evaluation. Automatically matching or generating corresponding test cases according to the code change record ensures that all affected functions are covered by the test, thereby reducing the time for manual testing and report writing, improving test coverage, and thus improving the efficiency of code testing during software testing. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] 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.
[0016] Figure 1 is a schematic flow chart of an automated testing method based on code changes provided by the first embodiment of the present application;
[0017] Figure 2 is a schematic flow chart of an automated testing method based on code changes provided in the second embodiment of the present application;
[0018] Figure 3 A schematic block diagram of an automated testing device based on code changes provided in an embodiment of the present application;
[0019] Figure 4 A schematic block diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0020] 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.
[0021] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may also be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.
[0022] It should 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.
[0023] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0024] The embodiments of the present application provide an automated testing method, apparatus, device and storage medium based on code changes. Among them, the automated testing method based on code changes can be applied to a server. By analyzing the current code change record, the scope of the code change can be accurately identified, reducing the errors introduced by manual evaluation. According to the code change record, the corresponding test cases are automatically matched or generated to ensure that all affected functions are covered by the test, which reduces the time for manual testing and report writing, improves the test coverage, and thus improves the code testing efficiency during the software testing process. Among them, the server can be an independent server or a server cluster.
[0025] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0026] See also Figure 1 , Figure 1This is a schematic flow chart of an automated testing method based on code changes provided by the first embodiment of the present application. The automated testing method based on code changes can be applied to a server, and is used to accurately identify the scope of code changes by analyzing the current code change records, thereby reducing errors introduced by manual evaluation. According to the code change records, corresponding test cases are automatically matched or generated to ensure that all affected functions are covered by the test, which reduces the time for manual testing and report writing, improves test coverage, and thus improves the efficiency of code testing during software testing.
[0027] like Figure 1 As shown, the automated testing method based on code changes specifically includes steps S10 to S30.
[0028] Step S10: Based on the current code, determine the current code change record corresponding to the current code;
[0029] Specifically, the API (Application Programming Interface) or command line tool of the code management system is used to obtain the change record of the current code branch, analyze the change record, and identify the newly added, modified, and deleted code parts.
[0030] Get the change record of the current code from the version control system, including the number of new, modified or deleted code lines, file name, author, date and other information.
[0031] Step S20: determining a target code test case corresponding to the current code according to the code change record;
[0032] Specifically, according to the code change record, select the test cases related to the changed code. By analyzing the impact scope of the code change, you can determine the functional points that need to be tested, and then select the corresponding test cases. Use static code analysis tools to analyze the hierarchy and dependencies of the changed code and determine the functions or interfaces corresponding to the changed code.
[0033] Step S30: Test the current code using the target code test case, and generate a target test report for the current code.
[0034] Specifically, according to the changed functions or interfaces, corresponding test cases are matched from the automated test case library.
[0035] If a matching test case exists, it is used directly; if not, a test case is automatically generated or supplemented according to the interface definition. For deleted functions, the corresponding test case is removed from the test case library.
[0036] Use the selected test cases to test the current code, including unit testing, integration testing, system testing, etc. You can use automated testing tools or execute test cases manually. Generate a test report based on the test results, including information such as test case execution status, number of defects, and defect severity. The test report can help the development team understand the quality status of the current code, fix defects in a timely manner, and improve software quality.
[0037] The present embodiment discloses an automated testing method, apparatus, device and storage medium based on code changes, wherein the automated testing method based on code changes includes determining the current code change record corresponding to the current code based on the current code; determining the target code test case corresponding to the current code according to the code change record; testing the current code through the target code test case, and generating a target test report for the current code. In the above manner, the present application can accurately identify the scope of code changes by analyzing the current code change record, thereby reducing errors introduced by manual evaluation. Automatically matching or generating corresponding test cases according to the code change record ensures that all affected functions are covered by the test, thereby reducing the time for manual testing and report writing, improving test coverage, and thus improving code testing efficiency during software testing.
[0038] See also Figure 2 , Figure 2 This is a schematic flow chart of an automated testing method based on code changes provided by the second embodiment of the present application. This automated testing method based on code changes can be applied to a server, and is used to determine the current code level and current code dependencies of the current code through a preset static code analysis tool. It can more accurately identify code changes, determine the code function change list and / or code interface change list of the current code, and more clearly understand the specific content and scope of the code changes, which helps to better manage and maintain the code. According to the code change record, the target code test case corresponding to the current code is determined, so that code testing can be performed more accurately, thereby improving the efficiency of code testing during software testing.
[0039] based on Figure 1 The embodiment shown, this embodiment Figure 2 As shown, step S10 includes steps S101 to S103.
[0040] Step S101: determining the current code level and current code dependency of the current code by using a preset static code analysis tool;
[0041] Specifically, use the preset static code analysis tool to analyze the current code and determine the hierarchical structure and dependency of the code, including the module division of the code, function call relationship, variable definition and use, etc.
[0042] Run static code analysis tools to analyze the current code base to determine the hierarchical structure of the code. The analysis tool will identify the classes, methods, functions, etc. in the code and determine the dependencies between them.
[0043] Step S102: determining a code function change list and / or a code interface change list of the current code according to the current code level and the current code dependency;
[0044] Specifically, determine the code function change list and / or code interface change list: Analyze the code function changes and interface changes according to the code hierarchy and dependencies. Function changes include new, modified or deleted function points; interface changes include new, modified or deleted interfaces. Obtain the change record of the current code branch through the version control system to determine the new, modified and deleted parts of the code since the last release.
[0045] Step S103: Determine the code function change list and / or the code interface change list as the current code change record.
[0046] Specifically, the code function change list and / or code interface change list are determined as the current code change record: the analyzed code function change list and / or code interface change list are used as the current code change record for subsequent test case selection and test execution. Combined with the static code analysis results and change records, the functional points affected by the change are identified. Functional points are usually associated with user-perceivable behaviors or system modules. Identify the code interfaces affected by the change, including newly added, modified or deleted APIs, methods, functions, etc. Interface changes may affect the interaction between external systems or internal modules and the current code.
[0047] For each function or interface change, specify the specific content of the change, including the change type (addition, modification, deletion) and change description, and determine the scope of impact and potential impact points of the change.
[0048] The present embodiment discloses an automated testing method, device, equipment and storage medium based on code changes, wherein the automated testing method based on code changes includes determining the current code level and current code dependency of the current code through a preset static code analysis tool; determining the code function change list and / or code interface change list of the current code according to the current code level and the current code dependency; determining the code function change list and / or code interface change list as the current code change record; determining the target code test case corresponding to the current code according to the code change record; testing the current code through the target code test case, and generating a target test report for the current code. In the above manner, the present application determines the current code level and current code dependency of the current code through a preset static code analysis tool, can more accurately identify the code changes, determine the code function change list and / or code interface change list of the current code, can more clearly understand the specific content and scope of the code changes, and is helpful for better code management and maintenance. According to the code change record, the target code test case corresponding to the current code is determined, and code testing can be performed more accurately, thereby improving the code testing efficiency during software testing.
[0049] based on Figure 1 In the embodiment shown, in this embodiment, step S20 includes:
[0050] Determine, according to the code change record, a code function change list and / or a code interface change list of the current code;
[0051] Specifically, identify the code interfaces affected by the change, including newly added, modified, or deleted APIs, methods, functions, etc. Interface changes may affect the interaction between external systems or internal modules and the current code. Associate the function change list and interface change list with the code change record to determine the specific code files and code lines corresponding to each change point.
[0052] According to the code function change list and / or the code interface change list, the target code test case matching the current code is called from a preset code test case library.
[0053] In one embodiment, according to the code change record, the function change and interface change of the code are analyzed. Function change includes newly added, modified or deleted function points; interface change includes newly added, modified or deleted interfaces. According to the code function change list and / or the code interface change list, a test case matching the current code is selected from the preset code test case library. This can be achieved by matching the relationship between the function point or interface change and the test case.
[0054] Test the current code using selected test cases, including unit testing, integration testing, system testing, etc. Test cases can be executed using automated testing tools or manually.
[0055] Generate a test report based on the test results, including information such as test case execution, number of defects, and defect severity. The test report can help the development team understand the quality status of the current code, fix defects in a timely manner, and improve software quality.
[0056] In a more preferred embodiment, step S20 includes:
[0057] In the case where the current code change record is the code modification record, extracting key code characters of the current code;
[0058] Specifically, according to the code modification record, locate the specific code file and code line, extract the key code characters, which may include function names, class names, method signatures, specific variable names, comments, etc. Preprocess the extracted key code characters, such as removing spaces, comments, special symbols, etc., and standardize the code characters for easy matching.
[0059] Matching the key code characters with each preset code test case in the preset code test case library to generate a matching result;
[0060] Specifically, the extracted key code characters are matched with the test cases in the preset test case library. For example, a text matching algorithm (such as a regular expression, a string matching algorithm, etc.) can be used to identify the test cases related to the key code characters.
[0061] Based on the matching result, the target code test case matching the current code is determined.
[0062] In one embodiment, when the current code change record is a code modification record, the key code characters are extracted. This can be done by analyzing the code change record, determining the modified code lines, and extracting the key code characters therein.
[0063] The extracted key code characters are matched with each preset code test case in the preset code test case library to generate a matching result. This can be achieved by comparing the key code characters with the code fragments in the preset code test case. According to the matching result, a test case matching the current code is selected. This can be achieved by selecting a test case matching the key code characters.
[0064] Use the selected test cases to test the current code, including unit testing, integration testing, system testing, etc. You can use automated testing tools or execute test cases manually. Generate a test report based on the test results, including information such as test case execution status, number of defects, and defect severity. The test report can help the development team understand the quality status of the current code, fix defects in a timely manner, and improve software quality.
[0065] The present embodiment discloses an automated testing method, device, equipment and storage medium based on code changes, wherein the automated testing method based on code changes includes determining the current code change record corresponding to the current code based on the current code; extracting the key code characters of the current code when the current code change record is the code modification record; matching the key code characters with each preset code test case in the preset code test case library to generate a matching result; determining the target code test case that matches the current code based on the matching result; testing the current code through the target code test case and generating a target test report for the current code. Through the above-mentioned manner, the present application extracts the key code characters of the current code when the current code change record is a code modification record, which can more accurately identify the content of the code change, and is helpful for better code management and maintenance; matching the key code characters with each preset code test case in the preset code test case library to generate a matching result, which can more accurately determine the target code test case that matches the current code, thereby improving the code testing efficiency during software testing.
[0066] In a more preferred embodiment, step S20 includes:
[0067] Parsing the current code to determine the relevant interface definition of the current code;
[0068] Based on the relevant interface definition, creating a target code test case corresponding to the current code;
[0069] The target code test case is synchronized to the preset code test case library.
[0070] In one embodiment, the current code is parsed and the interface definition therein is analyzed. This can be achieved by analyzing the function definition, parameter transfer, return value and other information in the code. According to the interface definition, a new test case corresponding to the current code is created. This can be achieved by designing test cases to cover various input and output situations of the interface.
[0071] Synchronize the newly created test cases to the preset code test case library for subsequent use. This can be achieved by saving the test cases to a database or file system. Use the newly created test cases to test the current code, including unit testing, integration testing, system testing, etc. You can use automated testing tools or manually execute test cases, and generate a test report based on the test results, including information such as test case execution status, number of defects, and defect severity. The test report can help the development team understand the quality status of the current code, fix defects in a timely manner, and improve software quality.
[0072] The present embodiment discloses an automated testing method, apparatus, device and storage medium based on code changes, wherein the automated testing method based on code changes includes determining the current code change record corresponding to the current code based on the current code; parsing the current code to determine the relevant interface definition of the current code; creating a target code test case corresponding to the current code based on the relevant interface definition; synchronizing the target code test case to the preset code test case library; testing the current code through the target code test case, and generating a target test report for the current code. Through the above-mentioned method, the present application can more clearly understand the function and interface design of the code by determining the relevant interface definition of the current code, and can create a target code test case corresponding to the current code based on the relevant interface definition, so as to perform code testing more accurately, improve code quality and stability, and help to better manage and maintain code.
[0073] In a more preferred embodiment, step S20 includes:
[0074] Determining a code test case to be deleted that matches the code deletion record from the preset code test case library;
[0075] Specifically, by using the version control system to obtain the deletion records of the current code, we can determine the parts of the code that have been deleted since the last release. According to the code deletion records, we can locate the specific code files and code lines, and then extract key code characters, which may include function names, class names, method signatures, etc.
[0076] In the case where the current code change record is the code deletion record, uploading a deletion request corresponding to the code deletion record to the preset code test case library;
[0077] The code test case to be deleted is deleted from the preset code test case library.
[0078] In one embodiment, it is necessary to analyze the code deletion record to determine which codes or interfaces are deleted. Then, the test cases related to these deleted codes or interfaces are searched in the preset code test case library, and these test cases are the test cases of the code to be deleted. When the current code change record is confirmed to be a code deletion record, a deletion request needs to be generated, and the request should contain detailed information of the deleted code or interface so that the preset code test case library can identify and process it. Then, this deletion request is uploaded to the preset code test case library.
[0079] After receiving the deletion request and confirming it is correct, the preset code test case library will perform the deletion operation and delete the previously determined code test cases to be deleted from the library. This ensures the accuracy of the test case library and avoids using non-existent code or interfaces in subsequent tests.
[0080] The present embodiment discloses an automated testing method, device, equipment and storage medium based on code changes, wherein the automated testing method based on code changes includes determining the current code change record corresponding to the current code based on the current code; determining the to-be-deleted code test case that matches the code deletion record from the preset code test case library; when the current code change record is the code deletion record, uploading the deletion request corresponding to the code deletion record to the preset code test case library; deleting the to-be-deleted code test case from the preset code test case library; testing the current code through the target code test case, and generating a target test report for the current code. In the above manner, the present application can accurately identify the scope of code changes by analyzing the current code change record, thereby reducing the errors introduced by manual evaluation. Automatically matching or generating corresponding test cases according to the code change record ensures that all affected functions are covered by the test, thereby reducing the time for manual testing and report writing, improving test coverage, and thus improving the efficiency of code testing during software testing.
[0081] Based on any of the above embodiments, in this embodiment, step S30 includes:
[0082] Determining whether the target code test case is a complete test case based on the current code and the target code test case;
[0083] Specifically, analyze the target test cases, check whether all functional points and interfaces of the current code are covered, and confirm whether the test cases include all necessary test conditions, such as boundary conditions, abnormal situations, etc.
[0084] In the case where the target code test case is the complete test case, starting a test script of the target code test case, testing the current code through the test script, and generating a test result;
[0085] In a specific embodiment, if the target test case is determined to be a complete test case, an automated test script is started. The test script may be written using an automated test framework, and then the test script is run to test the current code.
[0086] A preset test report template is obtained, and the target test report is generated based on the preset test report template and the test result.
[0087] In one embodiment, it is necessary to compare the current code with the target code test case to check whether the target code test case covers all functional points of the current code. If the target code test case can completely test all functions of the current code, it is considered to be a complete test case.
[0088] Once the target code test case is confirmed to be complete, the corresponding test script can be started. The test script will automatically execute a series of test steps according to the settings of the target code test case and record the data during the test. These data will eventually be summarized into test results.
[0089] After the test is completed, you need to obtain a preset test report template. This template usually contains some fixed formats and contents, such as test date, tester, test environment, etc. Then, fill the test results into the template to generate the final test report. In this way, you can get a test report with clear structure and comprehensive information for relevant personnel to review and use.
[0090] The present embodiment discloses an automated testing method, device, equipment and storage medium based on code changes, wherein the automated testing method based on code changes includes determining the current code change record corresponding to the current code based on the current code; determining the target code test case corresponding to the current code according to the code change record; determining whether the target code test case is a complete test case according to the current code and the target code test case; when the target code test case is the complete test case, starting the test script of the target code test case, testing the current code through the test script, and generating a test result; obtaining a preset test report template, and generating the target test report based on the preset test report template and the test result. In the above manner, the present application can accurately identify the scope of code changes by analyzing the current code change record, reducing the error introduced by manual evaluation. Automatically matching or generating corresponding test cases according to the code change record ensures that all affected functions are covered by the test, which reduces the time of manual testing and report writing, improves the test coverage, and thus improves the code testing efficiency during software testing.
[0091] See also Figure 3 , Figure 3 The embodiment of the present application provides a schematic block diagram of an automated testing device based on code changes, which is used to execute the aforementioned automated testing method based on code changes. The automated testing device based on code changes can be configured on a server.
[0092] like Figure 3 As shown, the automatic testing device 400 based on code changes includes:
[0093] A current code change record determination module 410 is used to determine, based on the current code, the current code change record corresponding to the current code;
[0094] A target code test case determination module 420, configured to determine a target code test case corresponding to the current code according to the code change record;
[0095] The code testing module 430 is used to test the current code through the target code test case and generate a target test report for the current code.
[0096] Furthermore, the current code change record determination module 410 includes:
[0097] A code analysis unit, used to determine the current code level and current code dependency of the current code by using a preset static code analysis tool;
[0098] A code list determination unit, configured to determine a code function change list and / or a code interface change list of the current code according to the current code level and the current code dependency;
[0099] The current code change record determining unit is used to determine the code function change list and / or the code interface change list as the current code change record.
[0100] Furthermore, the target code test case determination module 420 includes:
[0101] A code list determination unit, configured to determine a code function change list and / or a code interface change list of the current code according to the code change record;
[0102] The target code test case calling unit is used to call the target code test case matching the current code from a preset code test case library according to the code function change list and / or the code interface change list.
[0103] Furthermore, the target code test case determination module 420 includes:
[0104] A key code character extraction unit, used for extracting the key code character of the current code when the current code change record is the code modification record;
[0105] A matching unit, used for matching the key code characters with each preset code test case in the preset code test case library to generate a matching result;
[0106] A target code test case determination unit is used to determine the target code test case that matches the current code based on the matching result.
[0107] Furthermore, the target code test case determination module 420 includes:
[0108] A related interface definition determining unit, used for parsing the current code and determining the related interface definition of the current code;
[0109] A target code test case creation unit, used for creating a target code test case corresponding to the current code based on the relevant interface definition;
[0110] A test case synchronization unit is used to synchronize the target code test case to the preset code test case library.
[0111] Furthermore, the automatic testing device 400 based on code changes includes:
[0112] A module for determining code test cases to be deleted, used to determine the code test cases to be deleted that match the code deletion record from the preset code test case library;
[0113] A deletion request uploading module, used for uploading a deletion request corresponding to the code deletion record to the preset code test case library when the current code change record is the code deletion record;
[0114] The to-be-deleted code test case deleting module is used to delete the to-be-deleted code test case from the preset code test case library.
[0115] Furthermore, the code testing module 430 includes:
[0116] A complete test case testing unit, used to determine whether the target code test case is a complete test case based on the current code and the target code test case;
[0117] A test result generating unit, configured to start a test script of the target code test case when the target code test case is the complete test case, test the current code through the test script, and generate a test result;
[0118] The target test report generating unit is used to obtain a preset test report template, and generate the target test report based on the preset test report template and the test result.
[0119] It should be noted that those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described device and each module can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0120] The above-mentioned device can be implemented in the form of a computer program. Figure 4 Runs on the computer device shown.
[0121] See also Figure 4 , Figure 4 1 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device may be a server.
[0122] See also Figure 4 The computer device includes a processor, a memory and a network interface connected through a system bus, wherein the memory may include a non-volatile storage medium and an internal memory.
[0123] The non-volatile storage medium can store an operating system and a computer program. The computer program includes program instructions, and when the program instructions are executed, the processor can execute any automated testing method based on code changes.
[0124] The processor is used to provide computing and control capabilities and support the operation of the entire computer equipment.
[0125] The internal memory provides an environment for the operation of the computer program in the non-volatile storage medium. When the computer program is executed by the processor, the processor can execute any automated testing method based on code changes.
[0126] The network interface is used for network communication, such as sending assigned tasks, etc. Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0127] It should be understood that the processor may be a central processing unit (CPU), and the processor 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.
[0128] In one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:
[0129] Based on the current code, determining a current code change record corresponding to the current code;
[0130] Determine, according to the code change record, a target code test case corresponding to the current code;
[0131] The current code is tested through the target code test case, and a target test report of the current code is generated.
[0132] In one embodiment, based on the current code, a current code change record corresponding to the current code is determined to achieve:
[0133] Determine the current code level and current code dependency of the current code by using a preset static code analysis tool;
[0134] Determine a code function change list and / or a code interface change list of the current code according to the current code level and the current code dependency;
[0135] The code function change list and / or the code interface change list are determined as the current code change record.
[0136] In one embodiment, according to the code change record, a target code test case corresponding to the current code is determined to achieve:
[0137] Determine, according to the code change record, a code function change list and / or a code interface change list of the current code;
[0138] According to the code function change list and / or the code interface change list, the target code test case matching the current code is called from a preset code test case library.
[0139] In one embodiment, according to the code change record, a target code test case corresponding to the current code is determined to achieve:
[0140] In the case where the current code change record is the code modification record, extracting key code characters of the current code;
[0141] Matching the key code characters with each preset code test case in the preset code test case library to generate a matching result;
[0142] Based on the matching result, the target code test case matching the current code is determined.
[0143] In one embodiment, according to the code change record, a target code test case corresponding to the current code is determined to achieve:
[0144] Parsing the current code to determine the relevant interface definition of the current code;
[0145] Based on the relevant interface definition, creating a target code test case corresponding to the current code;
[0146] The target code test case is synchronized to the preset code test case library.
[0147] In one embodiment, after determining the target code test case corresponding to the current code according to the code change record, it is used to implement:
[0148] Determining a code test case to be deleted that matches the code deletion record from the preset code test case library;
[0149] In the case where the current code change record is the code deletion record, uploading a deletion request corresponding to the code deletion record to the preset code test case library;
[0150] The code test case to be deleted is deleted from the preset code test case library.
[0151] In one embodiment, the current code is tested by the target code test case, and a target test report of the current code is generated, for achieving:
[0152] Determining whether the target code test case is a complete test case based on the current code and the target code test case;
[0153] In the case where the target code test case is the complete test case, starting a test script of the target code test case, testing the current code through the test script, and generating a test result;
[0154] A preset test report template is obtained, and the target test report is generated based on the preset test report template and the test result.
[0155] A computer-readable storage medium is also provided in an embodiment of the present application, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and the processor executes the program instructions to implement any one of the automated testing methods based on code changes provided in the embodiments of the present application.
[0156] The computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiment, such as a hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (Smart Medi a Card, SMC), a secure digital (Secure Digital, SD) card, a flash memory card (Flash Card), etc., equipped on the computer device.
[0157] 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. An automated testing method based on code changes, characterized in that: include: Based on the current code, determining a current code change record corresponding to the current code; Determine, according to the code change record, a target code test case corresponding to the current code; The current code is tested through the target code test case, and a target test report of the current code is generated.
2. The automated testing method based on code changes according to claim 1, characterized in that: The determining, based on the current code, a current code change record corresponding to the current code includes: Determine the current code level and current code dependency of the current code by using a preset static code analysis tool; Determine a code function change list and / or a code interface change list of the current code according to the current code level and the current code dependency; The code function change list and / or the code interface change list are determined as the current code change record.
3. The automated testing method based on code changes according to claim 1, characterized in that: The step of determining a target code test case corresponding to the current code according to the code change record includes: Determine, according to the code change record, a code function change list and / or a code interface change list of the current code; According to the code function change list and / or the code interface change list, the target code test case matching the current code is called from a preset code test case library.
4. The automated testing method based on code changes according to claim 3, characterized in that: The current code change record includes a code modification record, and determining a target code test case corresponding to the current code according to the code change record includes: In the case where the current code change record is the code modification record, extracting key code characters of the current code; Matching the key code characters with each preset code test case in the preset code test case library to generate a matching result; Based on the matching result, the target code test case matching the current code is determined.
5. The automated testing method based on code changes according to claim 3, characterized in that: The current code change record includes a code new addition record, and determining a target code test case corresponding to the current code according to the code change record includes: Parsing the current code to determine the relevant interface definition of the current code; Based on the relevant interface definition, creating a target code test case corresponding to the current code; The target code test case is synchronized to the preset code test case library.
6. The automated testing method based on code changes according to claim 3, characterized in that: The current code change record includes a code deletion record, and after determining the target code test case corresponding to the current code according to the code change record, the method includes: Determining a code test case to be deleted that matches the code deletion record from the preset code test case library; In the case where the current code change record is the code deletion record, uploading a deletion request corresponding to the code deletion record to the preset code test case library; The code test case to be deleted is deleted from the preset code test case library.
7. The automated testing method based on code changes according to any one of claims 1 to 6, characterized in that: The testing of the current code by the target code test case and generating a target test report of the current code includes: Determining whether the target code test case is a complete test case based on the current code and the target code test case; In the case where the target code test case is the complete test case, starting a test script of the target code test case, testing the current code through the test script, and generating a test result; A preset test report template is obtained, and the target test report is generated based on the preset test report template and the test result.
8. An automated testing device based on code changes, characterized in that: include: A current code change record determination module, used to determine, based on the current code, the current code change record corresponding to the current code; A target code test case determination module, used to determine a target code test case corresponding to the current code according to the code change record; The code testing module is used to test the current code through the target code test case and generate a target test report for the current code.
9. A computer device, characterized in that: The computer device includes a memory and a processor; The memory is used to store computer programs; The processor is used to execute the computer program and implement the automatic testing method based on code changes as described in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor implements the automatic testing method based on code changes according to any one of claims 1 to 7.
Citation Information
Patent Citations
Code automatic analysis and test method and device and computer readable storage medium
CN110389896A
Interface test method and device, server and storage medium
CN111538651A
Test method and system based on code change analysis engine and computer equipment
CN115794638A
Accurate test method and system based on code coverage rate evaluation
CN117009230A
Test case supplementing method and device, equipment and storage medium
CN117539761A
Cited By
Software testing method and device, equipment and medium
CN120743790A