Automatic test script repairing method and related device

By acquiring feature data during the execution of test scripts and using various technical means to detect and automatically repair errors in test scripts, the problems of high maintenance costs and low efficiency in existing technologies are solved, and efficient and accurate automated test script repair is achieved.

CN120973669APending Publication Date: 2025-11-18YANCHI ZHONGYING CHUANGNENG NEW ENERGY CO LTD +2
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202511061135.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-30
Publication Date
2025-11-18

AI Technical Summary

Technical Problem

Existing automated test scripts are costly and inefficient to maintain when faced with changes in software interface elements, interface adjustments, and logical errors. Manual repairs can easily introduce new errors, failing to meet the needs of rapid iterative software development.

Method used

By acquiring feature data during the execution of the test script, errors are detected using techniques such as regular expressions, syntax tree parsing, natural language processing, and image recognition. Combined with decision tree algorithms, the optimal repair strategy is selected, and code modification, parameter adjustment, and element location updates are automated.

Benefits of technology

It enables rapid and accurate detection and automatic repair of errors in test scripts, significantly improving testing efficiency and accuracy, reducing human error, adapting to changes in software requirements, shortening development cycles, and reducing costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120973669A_ABST
    Figure CN120973669A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of software test automation, and discloses an automatic test script repair method and related device.The method comprises the steps that feature data in the test script execution process are obtained; detecting a preset error problem of the test script based on the feature data in the execution process of the test script to obtain a problem detection result of the test script; wherein the preset error problem of the test script comprises a grammar error, a logic error, an interface error and an interface error of the test script; based on the problem detection result of the test script, selecting an optimal repair strategy from a pre-constructed repair strategy library, and generating a repair instruction based on the optimal repair strategy; based on the repair instruction, performing automatic repair operation on the test script; according to the method and the device, automatic repair of the test script is realized, a tester does not need to manually check and modify codes related to the interface elements in the script one by one, time and labor cost are greatly saved, and test efficiency is remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application belongs to the technical field of software test automation, and particularly relates to a method for repairing an automated test script and a related device. BACKGROUND

[0002] In the software development life cycle, automated testing has become an important means to ensure software quality and improve testing efficiency. Among them, automated test scripts are used to simulate user operations, verify software functions and performance, thereby improving testing efficiency. However, with the continuous expansion of the scale of software systems, the increasing complexity of functions, and frequent requirement changes and code refactoring during software development, automated test scripts face many challenges, resulting in high maintenance costs and low efficiency.

[0003] Specifically, due to changes in software interface elements (such as position, name, attribute, and level modification), automated test scripts based on interface element positioning will not be able to accurately position or operate target elements. Secondly, adjustments to software interfaces (such as changes in parameter types and changes in calling methods) will also cause errors in test scripts involving interface calls. In addition, logical errors in automated test scripts themselves (such as improper handling of boundary conditions, missing exception handling, or logical errors in the scripts themselves) will also affect the accuracy and completeness of testing.

[0004] Currently, when the above problems occur in automated test scripts, test personnel mainly rely on manual troubleshooting and repair, which generally has low testing efficiency and is prone to introducing new human errors. Manual troubleshooting not only consumes time and effort, but also easily introduces new errors due to manual repair, affecting testing quality. Furthermore, for rapidly iterating software development projects, manual processing cannot meet the needs of timely testing, resulting in testing progress lagging behind, increasing software development costs and cycle time. Therefore, there is an urgent need for a self-repairing technology that can automatically detect and repair problems in automated test scripts to improve the effectiveness and reliability of automated testing. SUMMARY

[0005] To solve the technical problems of relying on test personnel to manually troubleshoot and repair problems in automated test scripts, which generally has low testing efficiency and is prone to introducing new human errors, the present application provides a method for repairing an automated test script and a related device.

[0006] To achieve the above-mentioned purposes, the technical solution adopted by the present application is as follows: The present application provides a method for repairing an automated test script, comprising: acquire feature data in a test script execution process; wherein the feature data in the test script execution process includes code text data of the test script, business process state information, business description text data, interface call request parameters, interface call protocol information, interface return status code, and software interface screenshots; detect preset error problems of the test script based on the feature data in the test script execution process, and obtain a problem detection result of the test script; wherein the preset error problems of the test script include syntax errors, logic errors, interface errors, and interface errors of the test script; select an optimal repair strategy from a pre-constructed repair strategy library based on the problem detection result of the test script, and generate a repair instruction based on the optimal repair strategy; perform an automatic repair operation on the test script based on the repair instruction; wherein the automatic repair operation includes code modification, parameter adjustment, and element positioning update operations.

[0007] Further, the process of detecting syntax errors of the test script based on the feature data in the test script execution process is as follows: According to the code text data of the test script, a pre-constructed regular expression and a syntax tree parsing method are used to detect syntax errors of the test script, and a syntax error detection result of the test script is obtained.

[0008] Further, the process of detecting logic errors of the test script based on the feature data in the test script execution process is as follows: Based on the business process state information of the test script, a state transition graph of the test script is constructed. Compare the state transition graph of the test script with a pre-constructed standard business process state graph to obtain logic error detection information of the test script; wherein the pre-constructed standard business process state graph is constructed based on an automated test business rule knowledge base and a finite state machine model; Use natural language processing technology to extract the actual business semantics text of the test script from the business description data of the test script. Compare the actual business semantics text of the test script with the pre-determined standard automated test business semantics to obtain business semantics error detection information of the test script.

[0009] Further, the process of detecting interface errors of the test script based on the feature data in the test script execution process is as follows: Based on the interface call request parameters, interface call protocol information, and interface return status code of the test script, an actual interface call behavior of the test script is generated. Compare the actual interface call behavior of the test script with the predetermined standard interface call behavior to obtain an interface error detection result of the test script.

[0010] Further, based on the feature data in the test script execution process, the process of detecting the interface error of the test script is as follows: Obtain a software interface element monitoring result from a software interface screenshot of the test script. According to the software interface element monitoring result, compare the change difference of element attributes when the software interface element changes to determine whether element positioning failure occurs, and obtain an interface error detection result of the test script.

[0011] Further, based on the problem detection result of the test script, the process of selecting an optimal repair strategy from a pre-constructed repair strategy library and generating a repair instruction based on the optimal repair strategy is as follows: Classify and prioritize the problem detection result of the test script. According to the classification and priority evaluation result of the problem detection result of the test script, a plurality of candidate repair strategies are selected from the pre-constructed repair strategy library. Based on the current software environment and the historical repair record of the test software, a preset decision algorithm is used to evaluate the plurality of candidate repair strategies to obtain an optimal repair strategy. Generate a repair instruction based on the optimal repair strategy.

[0012] The application also provides an automatic test script repair system, comprising: A feature data acquisition module is configured to acquire feature data in a test script execution process; wherein the feature data in the test script execution process includes code text data of the test script, business process state information, business description text data, interface call request parameters, interface call protocol information, interface return status code, and a software interface screenshot. A problem detection module is configured to detect preset error problems of a test script based on feature data in a test script execution process to obtain a problem detection result of the test script; wherein the preset error problems of the test script include syntax errors, logic errors, interface errors, and interface errors of the test script. A repair decision module is configured to select an optimal repair strategy from a pre-constructed repair strategy library based on a problem detection result of a test script, and generate a repair instruction based on the optimal repair strategy. A repair execution module is configured to perform automatic repair operations on a test script based on a repair instruction; wherein the automatic repair operations include code modification operations, parameter adjustment operations, and element positioning update operations.

[0013] The application also provides an electronic device, comprising: a processor adapted to execute a computer program; A computer readable storage medium, wherein a computer program is stored in the computer readable storage medium, and the computer program is executed by the processor to implement the method for repairing the automated test script.

[0014] The application further provides a computer readable storage medium, wherein a computer program is stored in the computer readable storage medium, and the computer program is executed by the processor to implement the method for repairing the automated test script.

[0015] The application further provides a computer program product, wherein the computer program product comprises a computer program, and the computer program is executed by the processor to implement the method for repairing the automated test script.

[0016] Compared with the prior art, the application has the following beneficial effects: The application provides a method for repairing an automated test script, which can quickly and accurately find error problems of the test script by acquiring feature data in a test script execution process and detecting preset error problems of the test script, and then generates a repair instruction based on the found error problems of the test script by selecting an optimal repair strategy from a pre-constructed repair strategy library, and performs an automated repair operation on the test script, so that the automated repair of the test script is realized, and the test personnel do not need to manually check and modify codes related to interface elements in the script one by one, which greatly saves time and labor cost and significantly improves the test efficiency; wherein, by acquiring multi-dimensional feature data in the test script execution process, such as code text data, business process state information, business description text data, interface call request parameters, interface call protocol information, interface return status code and software interface screenshots of the test script, and based on the acquired multi-dimensional feature data, a comprehensive analysis and detection are performed on various preset error problems including syntax errors, logic errors, interface errors and interface errors of the test script, so that various potential problems can be found, the comprehensive analysis and detection mechanism makes the test process more rigorous, reduces software quality problems caused by undetected errors, and improves the effect and reliability of the automated test; meanwhile, when the repair strategy is selected, the optimal strategy is selected from the pre-constructed repair strategy library, which is high in flexibility and can provide the most suitable solution according to different problem conditions, and significantly improves the efficiency and accuracy of the automated test script repair.

[0017] The automated test script repair system, the electronic device, the computer readable storage medium and the computer program product provided by the application have all the advantages of the method for repairing the automated test script. BRIEF DESCRIPTION OF DRAWINGS

[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the accompanying drawings needed to be used in the embodiments or prior art description will be briefly introduced. Obviously, the accompanying drawings in the following description only represent some embodiments of the present application, and for those skilled in the art, other drawings can be obtained without creative labor based on these drawings.

[0019] Figure 1 A flowchart of the repair method of the automated test script provided for Embodiment 1; Figure 2 A structural block diagram of the repair system of the automated test script provided for Embodiment 2; Figure 3 A structural block diagram of the electronic device provided for Embodiment 3. DETAILED DESCRIPTION

[0020] In order to make the technical problems, technical solutions and beneficial effects solved by the present application more clearly understood, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments only represent some of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.

[0021] The present application provides a repair method of an automated test script, comprising the following steps: Step 100, acquiring feature data in a test script execution process; wherein the feature data in the test script execution process comprises code text data of the test script, business process state information, business description text data, interface call request parameters, interface call protocol information, interface return status code and software interface screenshots.

[0022] Step 200, detecting preset error problems of the test script based on the feature data in the test script execution process to obtain a problem detection result of the test script; wherein the preset error problems of the test script comprise syntax errors, logic errors, interface errors and interface errors of the test script.

[0023] Step 300, selecting an optimal repair strategy from a pre-constructed repair strategy library based on the problem detection result of the test script, and generating a repair instruction based on the optimal repair strategy.

[0024] Step 400, performing an automated repair operation on the test script based on the repair instruction.

[0025] The repair method of the automatic test script provided by the application can comprehensively and accurately detect various preset error problems such as syntax, logic, interface and interface, quickly locate script faults caused by software interface element changes, interface adjustments and the like, subsequently select an optimal strategy from a pre-constructed and extensible repair strategy library to generate a repair instruction and automatically repair, greatly reduce manual intervention, reduce maintenance costs and human error risks, significantly improve test efficiency and accuracy, ensure that tests can keep up with the development rhythm in time, effectively shorten the software development cycle and reduce costs, and comprehensively improve the effect and reliability of automated testing.

[0026] The repair method of the automatic test script provided by the application is further explained below with some specific embodiments: Embodiment 1 As shown in the accompanying Figure 1 Embodiment 1 provides a repair method of an automatic test script, including the following steps: Step 1, obtaining feature data in the test script execution process. The feature data in the test script execution process includes code text data of the test script, business process state information, business description text data, interface call request parameters, interface call protocol information, interface return status code and software interface screenshots.

[0027] Specifically, the test script is started and executed according to the starting order of the test script, and the code text data of the test script, the business process state information, the business description text data, the interface call request parameters, the interface call protocol information, the interface return status code and the software interface screenshots in the test script execution process are recorded to obtain the feature data in the test script execution process.

[0028] Step 2, detecting preset error problems of the test script based on the feature data in the test script execution process to obtain problem detection results of the test script. When the problem detection results of the test script are blank, the method ends; if the problem detection results of the test script are not blank, jump to step 3.

[0029] The preset error problems of the test script include syntax errors, logic errors, interface errors and interface errors of the test script; the problem detection results of the test script include syntax error detection results, logic error detection results, interface error detection results and interface error detection results of the test script; the logic errors include logic error detection information and business semantic detection error information of the test script.

[0030] (1) The process of detecting syntax errors in the test script based on the feature data during the execution of the test script includes: using pre-built regular expressions and syntax tree parsing methods to detect syntax errors in the test script based on the code text data of the test script, and obtaining the syntax error detection results of the test script.

[0031] Specifically, the process is as follows: Step 211: Use pre-built regular expressions to check the bracket matching and variable definition information of the code text data of the test script; specifically, use pre-built regular expressions to perform matching operations on the code text; if the matching fails, there are syntax errors in bracket matching or variable definition in the code text.

[0032] For example, using regular expressions " The regular expression matches parentheses in the code text of a test script. If a mismatched parenthesis exists in the code text, the regular expression will fail to match correctly, thus obtaining the parenthesis matching result. For example, based on the syntax rules of variable definitions in scripting languages, a regular expression can be designed to detect whether a variable is defined according to the prescribed format. In Python, variable names typically begin with a letter or underscore, followed by letters, numbers, or underscores; the regular expression "..." can be used to achieve this. "To perform a preliminary check on the validity of variable names."

[0033] Step 212: Construct the parser required for the syntax tree; for Python, use the ast (Abstract Syntax Trees) module to construct the abstract syntax tree; for JavaScript, use the Esprima parser or Acor parser to construct the abstract syntax tree; for Java, use the ANTLR tool or JavaParser tool to construct the abstract syntax tree.

[0034] Step 213: Based on the parser required to construct the syntax tree, the code text of the test script is parsed into a syntax tree according to the syntax rules of the scripting language; where each node of the syntax tree represents a syntax structure, such as a statement, expression, and variable declaration.

[0035] Step 214: Use depth-first traversal or breadth-first traversal to traverse the syntax tree to decompose the code text of the test script into several syntax nodes; where different syntax nodes represent different syntax structures.

[0036] Step 215: Match and verify the structure of each syntax node according to the syntax rules of the scripting language; if the structure of a syntax node does not conform to the syntax rules of the scripting language, the corresponding syntax node is determined to be a statement structure error.

[0037] (2) A process of detecting logical errors of the test script based on feature data in the execution process of the test script, comprising the following steps: Step 221, constructing a state transition graph of the test script based on the business process state information of the test script; wherein the business process state information of the test script includes each state of the business process in the test script and the transition relationship between the states.

[0038] Step 222, constructing a standard business process state graph based on the automatic test business rule knowledge base and the finite state machine model to obtain a pre-constructed standard business state graph; comparing the state transition graph of the test script with the pre-constructed standard business state graph to detect whether there is a logical error such as process jump abnormality or state omission to obtain logical error detection information of the test script.

[0039] Step 223, using natural language processing technology to perform semantic extraction on the business description data of the test script to obtain actual business semantic text of the test script; Step 224, comparing the actual business semantic text of the test script with the pre-determined standard automatic test business semantics to obtain business semantic error detection information of the test script; specifically, calculating the actual business semantic text of the test script and the pre-determined standard automatic test business semantics by a cosine similarity formula to obtain a semantic similarity calculation result; comparing the semantic similarity calculation result with a pre-set similarity threshold to determine whether the business logic meets the expectation, that is, obtaining the business semantic error detection information of the test script; wherein the cosine similarity formula is as follows:

[0040]

[0041]

[0042] wherein, is the semantic similarity calculation result of the actual business semantic text of the test script; is the semantic vector of the pre-determined standard automatic test business semantics; is the semantic vector of the actual business semantic text of the test script; is the first element of the semantic vector of the actual business semantic text of the test script; is the first element of the semantic vector of the actual business semantic text of the test script. i is the first element of the semantic vector of the actual business semantic text of the test script. is the first element of the semantic vector of the actual business semantic text of the test script. is the first element of the semantic vector of the actual business semantic text of the test script. i is the first element of the semantic vector of the actual business semantic text of the test script.

[0043] It should be noted that when the semantic similarity calculation result of the actual business semantic text of the test script is less than the pre-set similarity threshold, the business semantic error detection information of the test script is obtained. If the similarity is less than the preset similarity threshold, it is determined that the actual business semantic text of the test script has a business logic error.

[0044] (3) A process of detecting interface errors of the test script based on feature data in the execution process of the test script, including: generating actual interface call behaviors of the test script based on interface call request parameters, interface call protocol information and interface return status codes of the test script; comparing the actual interface call behaviors of the test script with predetermined standard interface call behaviors to detect whether there are parameter type mismatch, insufficient permission or timeout problems in the interface call, and obtaining interface error detection results of the test script.

[0045] Specifically, according to the specifications and constraints defined by the interface document, the actual request parameters passed in the interface call process of the test script are obtained to detect whether there is a parameter type mismatch error; the protocol used in the interface call, such as HTTP and HTTPS, is monitored in real time to ensure that it meets the requirements of the interface document; the return status code after the interface call is obtained to determine whether the interface call is successful and to detect whether there are insufficient permission and timeout problems.

[0046] (4) A process of detecting interface errors of the test script based on feature data in the execution process of the test script, including the following steps: Step 241, obtaining software interface element monitoring results from software interface screenshots of the test script; specifically, using image recognition methods to perform image recognition processing on the software interface screenshots of the test script to obtain the name, ID, coordinates and attribute information of the software interface elements, and obtaining the software interface element monitoring results. It is worth noting that when the element attribute cannot be accurately positioned in the process of using image recognition methods to perform image recognition processing on the software interface screenshots of the test script, image feature extraction and matching algorithms are used to realize repositioning of the elements through image matching.

[0047] Step 242, using element analysis techniques to compare the change differences of element attributes when the software interface elements change based on the software interface element monitoring results to determine whether there is element positioning failure, and obtaining interface error detection results of the test script.

[0048] Step 3, selecting the optimal repair strategy from the pre-constructed repair strategy library based on the problem detection results of the test script, and generating repair instructions based on the optimal repair strategy. Specifically, the steps are as follows: Step 301, classifying and priority evaluating the problem detection results of the test script according to the preset problem result classification rules and priority evaluation rules, and obtaining classification and priority evaluation results of the problem detection results of the test script.

[0049] Step 302, according to the classification and priority evaluation result of the problem detection result of the test script, several candidate repair strategies are screened from the pre-built repair strategy library.

[0050] Step 303, based on the current software environment and the historical repair record of the test software, a preset decision algorithm is used to evaluate the several candidate repair strategies, and an optimal repair strategy is obtained; wherein the preset decision algorithm uses a decision tree algorithm.

[0051] Step 304, based on the optimal repair strategy, a repair instruction is generated, and the process jumps to step 4.

[0052] Step 4, based on the repair instruction, an automatic repair operation is performed on the test script to obtain a repaired test script. The automatic repair operation includes code modification, parameter adjustment and element positioning update.

[0053] Step 5, according to the preset verification rule, the repaired script is verified to verify the correctness of the repaired test script in syntax and logic. If the verification is passed, the repaired script is returned to step 1; if the verification is not passed, the optimal repair strategy is selected from the pre-built repair strategy library based on the verification error problem, and a repair instruction is generated based on the optimal repair strategy, and the automatic repair operation is performed again until the test script execution is passed.

[0054] The repair method of the automatic test script can automatically detect and repair problems in the test script in real time, greatly shorten the test interruption and waiting time caused by script problems, significantly improve the test execution efficiency, and compared with the traditional manual processing method, the test efficiency can be improved by more than 60%, thereby accelerating the iteration of the software.

[0055] In this embodiment, by accurately positioning and repairing the error problems in the test script, the omissions that may occur in manual repair are avoided, the accuracy and reliability of the test script are ensured, and the credibility of the test result is improved, thereby providing stronger guarantee for software quality. The method described in this embodiment can quickly adapt to complex scenarios of software demand changes and code updates, automatically adjust and repair the test script, and enable the automatic test system to stably run under different software versions and environments, thereby enhancing the universality and adaptability of the test system, and being especially suitable for scenarios where the test script is large and the software under test changes frequently.

[0056] Embodiment 2 As shown in the accompanying Figure 2 The embodiment 2 provides a repair system of an automatic test script, which includes a feature data acquisition module, a problem detection module, a repair decision module and a repair execution module.

[0057] The feature data acquisition module is configured to acquire feature data in a test script execution process; wherein the feature data in the test script execution process comprises code text data of the test script, business process state information, business description text data, interface call request parameters, interface call protocol information, interface return status code, and software interface screenshots.

[0058] The problem detection module is configured to detect preset error problems of the test script based on the feature data in the test script execution process, and obtain a problem detection result of the test script; wherein the preset error problems of the test script comprise syntax errors, logic errors, interface errors, and interface errors of the test script.

[0059] The repair decision module is configured to select an optimal repair strategy from a pre-constructed repair strategy library based on the problem detection result of the test script, and generate a repair instruction based on the optimal repair strategy.

[0060] The repair execution module is configured to perform an automatic repair operation on the test script based on the repair instruction; wherein the automatic repair operation comprises a code modification operation, a parameter adjustment operation, and an element positioning update operation.

[0061] Optionally, the repair system of the automatic test script further comprises a repair verification module; the repair verification module is configured to verify the repaired script according to a preset verification rule, to verify the correctness of the repaired test script in terms of syntax and logic.

[0062] Optionally, the repair system of the automatic test script further comprises a learning optimization module; the learning optimization module is configured to record the whole process data of each problem detection, decision, and repair, including problem type, detection method, candidate strategy, selection strategy, and repair result; utilize a machine learning algorithm, such as a reinforcement learning algorithm, to take the repair result as a reward signal, to train and optimize the problem detection module and the repair decision module, and to continuously improve the detection accuracy and the repair success rate of the system for problems, thereby improving the self-repairing capability of the system.

[0063] Embodiment 3 As shown in the accompanying drawings, Figure 3 Embodiment 3 provides an electronic device, which comprises a memory configured to store a computer program, and a processor configured to implement the steps of the repair method of the automatic test script when executing the computer program, or the processor is configured to implement the functions of the modules in the repair system of the automatic test script when executing the computer program.

[0064] The computer program can be divided into one or more modules / units, which are stored in the memory and executed by the processor to complete the present application. The one or more modules / units can be a series of computer program instruction segments capable of completing preset functions, which are used to describe the execution process of the computer program in the electronic device.

[0065] The electronic device can be a desktop computer, a notebook computer, a palm computer, a cloud server, and the like. The electronic device can include, but is not limited to, a processor and a memory. Those skilled in the art can understand that the above are examples of the electronic device and do not constitute a limitation on the electronic device, and the electronic device can include more components than the above, or combine certain components, or different components, for example, the electronic device further includes a communication interface, an input / output device, a network access device, and a bus.

[0066] The processor can be a central processing unit, and can also be other general-purpose processors, digital signal processors, application-specific integrated circuits, ready programmable gate arrays, or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, and the like. The general-purpose processor can be a microprocessor or the processor can be any conventional processor, and the like. The processor is the control center of the electronic device, and connects all parts of the electronic device through various communication interfaces and lines.

[0067] The memory can be used to store the computer program and / or modules, and the processor realizes various functions of the electronic device by running or executing the computer program and / or modules stored in the memory, and calling data stored in the memory.

[0068] The memory can mainly include a program storage area and a data storage area. The program storage area can store an operating system, at least one application program required for a function (such as a sound playing function, an image playing function, and the like), and the like; and the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, and the like), and the like. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, for example, a hard disk, a memory, a plug-in hard disk, a smart memory card, a secure digital card, a flash memory card, at least one disk storage device, a flash memory device, or other volatile solid-state memory devices.

[0069] Embodiment 4 The embodiment 4 also provides a computer readable storage medium, which stores a computer program. The computer program is executed by a processor to realize the steps of the automatic test script repairing method.

[0070] The module / unit of the automatic test script repair system integration, if realized in the form of a software function unit and sold or used as an independent product, can be stored in a computer-readable storage medium.

[0071] Based on such understanding, all or part of the processes in the automatic test script repair method described above can also be completed by instructing relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the automatic test script repair method described above when executed by a processor. The computer program includes computer program code, which can be in the form of source code, object code, an executable file, or a preset intermediate form.

[0072] The computer-readable storage medium can include any entity or device capable of carrying the computer program code, a recording medium, a U disk, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, a read-only memory, a random access memory, an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc.

[0073] Embodiment 5 Embodiment 5 provides a computer product, which includes a computer program stored in a computer-readable storage medium. A processor of an electronic device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the electronic device can execute the automatic test script repair method described in embodiment 1, which will not be described here.

[0074] It should be noted that a person skilled in the art can understand that all or part of the processes in the above-described embodiments can be completed by instructing relevant hardware through a computer program. The program can be stored in a computer-readable storage medium, and the program can include the processes of the above-described embodiments when executed.

[0075] The automatic test script repair method provided by the application can provide rich basis for accurate detection by comprehensively recording feature data in the test script execution process; based on the feature data in the test script execution process, and by using multiple technologies such as regular expressions, syntax tree analysis, finite state machines, natural language processing and image recognition, the problem can be accurately located in multiple dimensions such as syntax, logic, interface and interface; combined with intelligent algorithms such as decision trees, the optimal repair strategy is selected according to the problem type and software environment, and then the repair and pre-verification are automatically completed to ensure the correctness of the script; in addition, the detection and decision method is continuously optimized by using machine learning algorithm; the above technical means work together to effectively reduce the labor cost, improve the test efficiency and quality, and enhance the system adaptability, realize the efficient self-repair and intelligent optimization of the automatic test, wherein the workload of the test personnel in the script problem investigation and repair can be significantly reduced, the labor cost of the enterprise can be effectively reduced, the problems in the test script can be automatically detected in real time, and the problems can be quickly repaired, the test interruption and waiting time caused by the script problems can be greatly shortened, and the test execution efficiency can be significantly improved, the omissions that may occur in manual repair can be avoided, the accuracy and reliability of the test script can be ensured, and the credibility of the test result can be improved, the software demand change, code update and the like can be quickly adapted, the test script can be automatically adjusted and repaired, the automatic test system can stably run under different software versions and environments, and the universality and adaptability of the test system are enhanced.

[0076] The above embodiment is only one of the implementation manners of the technical scheme of the application, and the scope of the application claimed by the application is not limited to the embodiment, but also includes any changes, substitutions and other implementation manners easily thought of by those skilled in the art within the technical scope disclosed by the application.

Claims

1. A method for repairing automated test scripts, characterized in that, include: Obtain characteristic data during the execution of the test script; the characteristic data during the execution of the test script includes the test script's code text data, business process status information, business description text data, interface call request parameters, interface call protocol information, interface return status codes, and software interface screenshots. Based on the feature data during the execution of the test script, the pre-set error issues of the test script are detected, and the problem detection results of the test script are obtained; among them, the pre-set error issues of the test script include syntax errors, logic errors, interface errors and UI errors. Based on the problem detection results of the test script, the optimal repair strategy is selected from the pre-built repair strategy library, and repair instructions are generated based on the optimal repair strategy; Based on the repair instructions, automated repair operations are performed on the test scripts; these automated repair operations include code modification, parameter adjustment, and element location and update.

2. The method for repairing an automated test script according to claim 1, characterized in that, The process of detecting syntax errors in test scripts based on feature data during test script execution is as follows: Based on the code text data of the test script, the syntax errors of the test script are detected using pre-built regular expressions and syntax tree parsing methods, and the syntax error detection results of the test script are obtained.

3. The method for repairing an automated test script according to claim 1, characterized in that, The process of detecting logical errors in test scripts based on feature data during test script execution is as follows: Based on the business process status information of the test script, construct the state transition diagram of the test script; The state transition diagram of the test script is compared with the pre-built standard business process state diagram to obtain logical error detection information of the test script; the pre-built standard business process state diagram is constructed based on the automated test business rule knowledge base and finite state machine model. Natural language processing technology is used to extract semantics from the business description data of the test script to obtain the actual business semantic text of the test script; The actual business semantic text of the test script is compared with the pre-determined standard automated test business semantics to obtain business semantic error detection information of the test script.

4. The method for repairing an automated test script according to claim 1, characterized in that, The process of detecting interface errors in test scripts based on feature data during test script execution is as follows: Based on the interface call request parameters, interface call protocol information, and interface return status code of the test script, the actual interface call behavior of the test script is generated. The actual interface call behavior of the test script is compared with the predetermined standard interface call behavior to obtain the interface error detection results of the test script.

5. The method for repairing an automated test script according to claim 1, characterized in that, The process of detecting UI errors in test scripts based on feature data during test script execution is as follows: Obtain the monitoring results of software interface elements from the screenshots of the test script's software interface; Based on the monitoring results of the software interface elements, compare the differences in the changes of element attributes when the software interface elements change, determine whether element positioning failure has occurred, and obtain the interface error detection results of the test script.

6. The method for repairing an automated test script according to claim 1, characterized in that, The process of selecting the optimal repair strategy from a pre-built repair strategy library based on the problem detection results of the test script, and generating repair instructions based on the optimal repair strategy, is as follows: Classify and prioritize the problem detection results of the test scripts; Based on the classification and priority evaluation results of the problem detection results of the test script, several candidate remediation strategies are selected from the pre-built remediation strategy library. Based on the current software environment and the historical repair records of the test software, a preset decision algorithm is used to evaluate several candidate repair strategies and obtain the optimal repair strategy. Based on the optimal repair strategy, repair instructions are generated.

7. A system for repairing automated test scripts, characterized in that, include: The feature data acquisition module is used to acquire feature data during the execution of the test script. The feature data during the execution of the test script includes the test script's code text data, business process status information, business description text data, interface call request parameters, interface call protocol information, interface return status codes, and software interface screenshots. The problem detection module is used to detect pre-defined errors in the test script based on feature data during the execution process, and to obtain the problem detection results of the test script. The pre-defined errors in the test script include syntax errors, logic errors, interface errors, and UI errors. The repair decision module is used to select the optimal repair strategy from a pre-built repair strategy library based on the problem detection results of the test script, and generate repair instructions based on the optimal repair strategy. The repair execution module is used to perform automated repair operations on test scripts based on repair instructions; these automated repair operations include code modification, parameter adjustment, and element location and update.

8. An electronic device, characterized in that, include: A processor is used to execute computer programs; A computer-readable storage medium storing a computer program, which, when executed by the processor, performs a repair method based on an automated test script as described in any one of claims 1-6.

9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the repair method of the automated test script as described in any one of claims 1-6.

10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the repair method of the automated test script as described in any one of claims 1-6.

Citation Information

Cited By

  • Intelligent test script repairing method based on multi-modal perception and causal inference

    CN121919106A