A method, medium, and program product for automatically modifying test scripts.

By using log analysis and modification methods for automated test scripts, and leveraging historical successful execution log information, test scripts can be automatically modified and verified. This solves the problems of high repetitive workload and high manpower costs in automated testing, and achieves efficient and accurate test script modification.

CN122086743APending Publication Date: 2026-05-26MAIPU COMM TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
MAIPU COMM TECH CO LTD
Filing Date
2024-11-25
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

Automated testing involves a lot of repetitive log analysis, script modification, and script verification, resulting in high labor costs, and manual modifications may introduce errors.

Method used

By using automated log analysis and script modification methods, test scripts can be automatically modified and verified using historical successful execution log information, reducing manual intervention and improving efficiency and accuracy.

Benefits of technology

It greatly improves the efficiency of log analysis and script modification, saves manpower costs, reduces the risk of introducing errors, and significantly improves the accuracy of test script modification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122086743A_ABST
    Figure CN122086743A_ABST
Patent Text Reader

Abstract

This application discloses a method, medium, and program product for automatically modifying test scripts, relating to the field of automated testing technology. By automating log analysis, script modification, and script verification for automated testing, it saves the human resource costs associated with these tasks. The method includes: identifying the executed test script and generating an error log; retrieving the test script from the code repository and downloading it to a verification directory; polling historical log information in the log database based on the script name corresponding to the error log to obtain the execution success log corresponding to the script name; retrieving the test script corresponding to the execution success log from the code repository; modifying the test script in the verification directory based on the test script corresponding to the execution success log; and verifying the modified test script in the verification directory; after successful verification, submitting the modified test script in the verification directory to the code repository.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of automated testing technology, and more specifically, to a method, medium, and program product for automatically modifying test scripts. Background Technology

[0002] With the development of automated testing technology, automated testing has been widely applied in industries such as telecommunications and the internet. As network equipment is upgraded, the applicable software versions are constantly being upgraded, the number of software version verification tests is increasing, and the number of scripts executed by automated tests is also growing. Modifying and verifying test scripts requires a significant investment of manpower for log analysis, script modification, and script verification. Furthermore, the branched versioning management of test scripts in automated testing leads to a large amount of repetitive log analysis, script modification, and script verification work after the same test scripts on different branches are executed.

[0003] The large-scale application of automated testing technology will inevitably generate a large amount of log analysis and script maintenance workload. In order to improve the efficiency of log analysis and processing and shorten the modification or update cycle of test scripts, it is particularly important to efficiently perform automated testing tasks such as log analysis, script modification, and script verification. Summary of the Invention

[0004] To achieve the above objectives, embodiments of this application provide a method, medium, and program product for automatically modifying test scripts, which solves the problem of a large amount of repetitive work and high manpower costs in log analysis, script modification, and script verification in automated testing. By automating log analysis, script modification, and script verification, the efficiency of log analysis and processing in automated testing is improved, as is the efficiency of test script modification and verification.

[0005] In a first aspect, embodiments of this application provide a method for automatically modifying test scripts, the method comprising:

[0006] The system identifies and generates error logs for executed test scripts, retrieves the test scripts from the code repository, and downloads them to the verification directory.

[0007] Based on the script name corresponding to the error log, poll the historical log information in the log database to obtain the execution success log corresponding to the script name;

[0008] Obtain the test script corresponding to the execution success log from the code repository, modify the test script in the verification directory according to the test script corresponding to the execution success log, and verify the modified test script in the verification directory;

[0009] After successful verification, submit the modified test scripts in the verification directory to the code repository.

[0010] In one possible implementation, the step of polling historical log information in the log database based on the script name corresponding to the error log to obtain the execution success log corresponding to the script name specifically includes:

[0011] Based on the script name corresponding to the error log, poll the log database and search for the historical execution success information corresponding to the script name in order of log generation time from newest to oldest, and obtain the latest execution success log.

[0012] In one possible implementation, the error log includes at least one error log record, and the step of obtaining the test script corresponding to the execution success log from the code repository and modifying the test script in the verification directory according to the test script corresponding to the execution success log specifically includes:

[0013] The error log records in the error log are identified sequentially, and the location of the script code segment corresponding to the error log record is found in the test script corresponding to the error log record.

[0014] Retrieve the test script corresponding to the execution success log from the code repository based on the script name;

[0015] Obtain the successfully executed script code segment in the test script corresponding to the successful execution log, which is located at the same position as the script code segment corresponding to the error log record. Compare whether the script code segment corresponding to the error log record and the script code segment corresponding to the successful execution log are the same. If they are not the same, copy the successfully executed script code segment to the test script in the verification directory to replace the script code segment corresponding to the error log record.

[0016] In one possible implementation, the step of verifying the modified test scripts in the verification directory specifically includes:

[0017] The modified test scripts in the verification directory are subjected to virtual verification. If the virtual verification fails, the library functions called by the test scripts corresponding to the error logs are obtained from the code repository and downloaded to the verification directory.

[0018] Copy the code segment corresponding to the library function called by the script code segment corresponding to the successful execution log to the library function in the verification directory, replace the code segment corresponding to the library function called by the script code segment corresponding to the error log record, and perform virtual verification again. If the virtual verification passes, then perform simulated verification.

[0019] In one possible implementation, prior to the step of performing virtual verification on the modified test scripts in the verification directory, the method further includes:

[0020] A virtual execution database is periodically generated using a large number of historical log data files. The virtual execution database includes commands and echo information.

[0021] In one possible implementation, the step of performing virtual verification on the modified test scripts in the verification directory specifically includes:

[0022] Execute the modified test script in the verification directory and obtain the commands issued after the test script calls the library functions;

[0023] The system searches for the echo information corresponding to the command in the virtual execution database, compares the return key name of the library function in the echo information with the return key name of the library function in the verification directory. If the return key name of the library function in the echo information contains all the return key names of the library functions in the verification directory, the virtual verification passes. If the return key name of the library function in the echo information does not contain all the return key names of the library functions in the verification directory, the virtual verification fails.

[0024] In one possible implementation, the step of performing simulation verification specifically includes:

[0025] Create a simulated execution device based on the software version of the device under test corresponding to the error log;

[0026] The modified test script in the verification directory is executed in the simulation execution device. If an error log is recorded again, the simulation verification fails; if no error log is recorded, the simulation verification passes.

[0027] In one possible implementation, the step of submitting the modified test script in the verification directory to the code repository after the verification is passed specifically includes:

[0028] After all the script code segments and / or library function code segments corresponding to all error log records in the error log have been modified and verified, the test scripts and library functions in the verification directory are compared with the test scripts and library functions corresponding to the error logs in the code repository, a patch file is generated, and the patch file is submitted to the code repository.

[0029] Secondly, embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the test script automatic modification method as described in the first aspect above.

[0030] Thirdly, embodiments of this application provide a program product that, when executed by a processor, implements the test script automatic modification method described in the first aspect above.

[0031] This application provides a method, medium, and program product for automatically modifying test scripts. By automating log analysis, script modification, and script verification for automated testing, it significantly improves the efficiency of log analysis and maintenance, enhances the efficiency of test script modification and verification, and saves the manpower costs associated with these processes. Furthermore, automating test script modification and verification avoids the risk of introducing unnecessary errors due to manually modified test scripts uploaded to the code repository without verification, thus significantly improving the accuracy of script modifications. Attached Figure Description

[0032] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only a part of the embodiments of this application. For those skilled in the art, other drawings can be obtained based on the following drawings without creative effort.

[0033] Figure 1 This is a flowchart illustrating a method for automatically modifying test scripts, as provided in an embodiment of this application. Detailed Implementation

[0034] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0035] The business scenarios described in the embodiments of this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided in the embodiments of this application. As those skilled in the art will know, with the emergence of new business scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.

[0036] The above method will be described in detail below with reference to specific embodiments.

[0037] With the development of automated testing technology, automated testing has been widely applied in industries such as telecommunications and the internet. As network equipment is upgraded, the applicable software versions are constantly being upgraded, the number of software version verification tests is increasing, and the number of scripts executed by automated tests is also growing. Modifying and verifying test scripts requires a significant investment of manpower for log analysis, script modification, and script verification. Furthermore, the branched versioning management of test scripts in automated testing leads to a large amount of repetitive log analysis, script modification, and script verification work after the same test scripts on different branches are executed.

[0038] The large-scale application of automated testing technology will inevitably generate a large amount of log analysis and script maintenance workload. In order to improve the efficiency of log analysis and processing and shorten the modification or update cycle of test scripts, it is particularly important to efficiently perform automated testing tasks such as log analysis, script modification, and script verification.

[0039] This application provides a method, medium, and program product for automatically modifying test scripts, which solves the problem that traditional test script modification requires manual comparison of historical logs, manual analysis of error logs, and manual modification, script verification, and submission to the code repository, resulting in high manpower costs.

[0040] To achieve the above objectives, embodiments of this application provide a method, medium, and program product for automatically modifying test scripts. By automating log analysis and script comparison, it can quickly and accurately automate the modification of test scripts, and submit them to the code repository after verification. The automatic test script modification method provided in this application does not require identifying whether test scripts have changed between software versions; it can directly trigger the modification and verification of test scripts based on error logs.

[0041] In this embodiment of the application, the test log is a file used to record the execution results of the test script after it is executed on the device under test. The test log includes information such as execution time, the version name of the executed test script, the script name corresponding to the log, and the log generation time, so that subsequent automated test log analysis, script modification, and script verification can be performed based on the test log.

[0042] In this embodiment, during the version verification testing phase or version upgrade process, automated testing executes multiple rounds of automated tests based on the same or different software versions to verify the reliability of the test scripts corresponding to the software versions. Therefore, for the same device under test, the test scripts and library functions are basically the same across different software versions, except for the newly added parts. Thus, for the log analysis process, test scripts corresponding to previously successfully executed historical logs can be used to automatically handle the modification and verification of test scripts that generate error logs.

[0043] In this embodiment, when executing automated testing tasks, one automated testing task executes a test script version corresponding to one software version. Multiple rounds of automated testing may be executed on a single test script version for the same software version on a device under test. The same test script for each software version will be executed on different types of devices under test. Therefore, when analyzing historical log information, searching for historical log information of the same device under test can more accurately achieve the purpose of automatically modifying the test script through historical log analysis.

[0044] For example, this application embodiment provides a table showing the correspondence between the software version of the device under test, the test script version, and the scripts, as shown in Table 1 below. Software version V1 corresponds to test script version 1, and test script version 1 corresponds to m test scripts, where m is an integer greater than or equal to 1. Software version V2 corresponds to test script version 2, and test script version 2 corresponds to one or more test scripts, ..., software version Vn corresponds to test script version n, and test script version n corresponds to one or more test scripts.

[0045] Table 1: Correspondence between software version of the device under test, test script version, and script

[0046]

[0047] In one possible implementation, after executing a test script corresponding to a certain test script version on the device under test that has embedded the version of the software under test, an error log is generated. The error log may contain one or more error log entries.

[0048] In one possible implementation, if an execution error occurs during the execution of the test script on the device under test, the automated test stops and returns an error log. At this time, the error log contains only one error log record.

[0049] In one possible implementation, if the test log is generated only after the test script has been executed on the device under test, the test log may include one or more error log records. Obviously, the test log may also directly contain execution success logs. Since the embodiments of this application focus on the case where there are error logs, in the actual processing, the error log records in the error log can be processed sequentially, and the processing flow for each error log record is the same.

[0050] like Figure 1 As shown in the embodiment of this application, an automatic test script modification method is provided, including:

[0051] Step 101: Identify the executed test script, generate an error log, retrieve the test script from the code repository, and download it to the verification directory. The verification directory is located on the automated test execution server, which stores the test script versions corresponding to each software version.

[0052] In this embodiment, the test log records information such as script name and test script version name. One test log corresponds to one test script, one test script contains one or more script code segments, one test log contains one or more log records, and one test script contains multiple test steps, each test step corresponding to a script code segment. There is a one-to-one correspondence between a log record and a test step. For example, if a test log has log record 1, log record 2, log record 3, ..., log record n, then the corresponding test script also has test step 1, test step 2, test step 3, ..., test step n, where n is a natural number greater than or equal to 1.

[0053] In this embodiment, the log database stores historical log information of automated tests performed. Each historical log entry includes at least one or more of the following: test script version name, script name, and log generation time. Test scripts with the same script name are essentially consistent across different test script versions. The code repository stores test scripts for each test script version. The verification directory stores test scripts pulled from the code repository; this directory is used for temporarily modifying test scripts, facilitating subsequent modification and verification.

[0054] Step 102: Based on the script name corresponding to the error log, poll the historical log information in the log database to obtain the execution success log corresponding to that script name. The script name corresponding to the execution success log is the same as the script name corresponding to the error log; that is, the execution success log and the error log are two logs representing test scripts with the same script name executed in different test script versions.

[0055] In the embodiments of this application, test scripts with the same script name used to execute different test script versions should normally be the same. However, due to adaptation operations between different test script versions and the device under test, or other reasons, test scripts with the same script name in different test script versions may have some different script code segments. Therefore, using the script name to find the successfully executed test script and modify the test script that fails to execute not only has a high success rate in modifying the script, but also high efficiency in modification.

[0056] In this step, based on the script name corresponding to the error log, the historical log information in the log database is polled to obtain the execution success log corresponding to that script name, specifically including:

[0057] Based on the script name corresponding to the error log, poll the log database in rounds and search for the historical successfully executed log information corresponding to the script name in order from newest to oldest according to the log generation time, and obtain the latest successfully executed log.

[0058] In one possible implementation, multiple rounds of automated testing may have been performed on the same test script version. Therefore, a test script version may have multiple successful execution log messages. In this step, only the latest successful execution log message generated by the log generation time is searched for the same test script version.

[0059] This application provides an automatic test script modification method. Upon detecting an error log generated by an executed test script, the method iterates through logs of successful execution of the test script in other test script versions. It automatically compares the successfully executed test scripts in other versions with the test script corresponding to the error log to modify and verify the error log. This not only automates test script modification but also reduces the manual analysis costs in automated test log analysis and processing across multiple software versions, thereby improving the efficiency of automated test log analysis and processing.

[0060] Step 103: Obtain the test script corresponding to the execution success log from the code repository, modify the test script in the verification directory according to the test script corresponding to the execution success log, and verify the modified test script in the verification directory.

[0061] In this embodiment of the application, the error log includes at least one error log record.

[0062] In this step, the test script corresponding to the successful execution log is retrieved from the code repository. The test script in the verification directory is then modified based on this script. Specifically, this includes:

[0063] Identify the error log entries in the error log sequentially, and locate the corresponding script code segment within the test script corresponding to the error log entry.

[0064] Retrieve the test script corresponding to the successful execution log from the code repository based on the script name.

[0065] Retrieve the successfully executed script code segment from the test script corresponding to the successful execution log, located at the same position as the script code segment corresponding to the error log record. Compare the script code segment corresponding to the error log record and the successfully executed script code segment. If they are different, copy the successfully executed script code segment to the test script in the verification directory, replacing the script code segment corresponding to the error log record. If the script code segment corresponding to the error log record and the successfully executed script code segment are the same, return to step 102 and, based on the script name corresponding to the error log, re-polulate the historical log information in the log database to obtain other successful logs corresponding to that script name.

[0066] In this step, the modified test scripts in the verification directory are verified, specifically including:

[0067] Perform virtual verification on the modified test scripts in the verification directory. If the virtual verification fails, retrieve the library functions called by the test scripts corresponding to the error logs from the code repository and download them to the verification directory.

[0068] Copy the library function called by the script code segment corresponding to the successful execution log to the library function in the verification directory, replacing the library function called by the script code segment corresponding to the error log. Perform virtual verification again. If the virtual verification passes this time, execute simulated verification. If the virtual verification fails this time, return to step 102, search for the successful execution log again, and repeat steps 102-103.

[0069] In this step, the modified test script in the verification directory is virtually verified. If the virtual verification passes, the simulated verification is executed.

[0070] In one possible implementation, before performing virtual verification on the modified test scripts in the verification directory, an automatic test script modification method according to an embodiment of this application further includes:

[0071] A virtual execution database is periodically generated using a large amount of historical log data files. This database includes commands and output messages. It stores the mapping between commands and output messages. For example, the commands in the virtual execution database could be configuration commands, table entry viewing commands, etc., and the output messages could be configuration output messages, table entry viewing output messages, etc.

[0072] In this embodiment, the basic process of virtual verification is as follows: When virtually verifying the test script, a real device is not used; however, the execution flow of the test script is executed virtually in its entirety. This involves executing the test script, obtaining the commands issued after the test script calls library functions, and obtaining the corresponding echo information when a device command appears in the virtual execution database. Based on this process, the execution of the test script on a real device is simulated, enabling rapid and efficient verification of the correctness of the test script syntax and checkpoint structure.

[0073] In this step, the modified test scripts in the verification directory are virtually verified, specifically including:

[0074] Execute the modified test script in the verification directory and obtain the commands issued after the test script calls the library functions;

[0075] The system searches for the corresponding echo information of the command in the virtual execution database and compares the return key name of the library function in the echo information with the return key name of the library function in the verification directory. If the return key name of the library function in the echo information contains all the return key names of the library functions in the verification directory, the virtual verification passes. If the return key name of the library function in the echo information does not contain all the return key names of the library functions in the verification directory, the virtual verification fails.

[0076] This application provides a method for automatically modifying test scripts. By using virtual verification, the modified test scripts can be automatically verified, enabling a large number of test scripts to be verified in a short time, thus improving the efficiency of verifying modified test scripts.

[0077] In this step, simulation verification is performed, specifically including:

[0078] Create a simulated execution device based on the software version of the device under test corresponding to the error log.

[0079] Execute the modified test script in the verification directory on the simulated execution device. If an error log is recorded again, the simulation verification fails; if no error log is recorded, the simulation verification passes.

[0080] In this embodiment, the simulation execution device simulates the execution of a modified test script in the verification directory on the actual device under test to verify the correctness of the test script. If the simulation verification passes, step 104 is executed; if the simulation verification fails, the process returns to step 102, and the execution success log is searched again, i.e., steps 102-103 are repeated. For example, the simulation execution device is a virtual device created on a server, such as a virtual router or virtual switch.

[0081] In one possible implementation, the simulated execution device executes the modified test script in the verification directory, prints the echo information, and compares the return key name and corresponding return key value of the library function in the echo information with the return key name and corresponding return key value of the library function in the verification directory. If the return key name and corresponding return key value of the library function in the echo information are the same as those of the library function in the verification directory, the simulation verification passes; if the return key name and corresponding return key value of the library function in the echo information are different from those of the library function in the verification directory, the simulation verification fails.

[0082] This application provides a method for automatically modifying test scripts. Through simulation verification, the modified test scripts can be verified more accurately, and the verified test scripts can be directly submitted to the code repository. By automating test script modification and verification, the risk of introducing unnecessary errors due to manual modification without verification before uploading to the code repository can be avoided, significantly improving the accuracy of script modifications.

[0083] Step 104: After successful verification, submit the modified test script in the verification directory to the code repository.

[0084] In this step, after successful verification, the modified test scripts in the verification directory are committed to the code repository, specifically including:

[0085] After all the script code segments and / or library function code segments corresponding to all error log records in the error log have been modified and verified, the test scripts and library function code in the verification directory are compared with the test scripts and library function code corresponding to the error logs in the code repository, a patch file is generated, and the patch file is submitted to the code repository.

[0086] This application provides a method for automatically modifying test scripts. By automating log analysis, script modification, and script verification for automated tests, it significantly improves the efficiency of log analysis and maintenance, enhances the efficiency of test script modification and verification, and saves the human resources costs associated with these processes. Furthermore, automating test script modification and verification avoids the risk of introducing unnecessary errors due to manually modified test scripts uploaded to the code repository without verification, thus significantly improving the accuracy of script modifications.

[0087] The following describes in detail the implementation process of an automatic test script modification method provided in this application, using examples:

[0088] Assumptions: After executing test script 1 (version 1) on the device under test, error log 1 is generated, containing only one error log record (error log record 1) and corresponding script code segment 1. After executing test script 2 (version 2) on the device under test, execution success log 2 is generated. Test script 1 and test script 2 have the same script name, and the log data stores the execution success log 2 corresponding to test script 2. Both test script 1 and test script 2 call library functions, as shown in Table 2 below.

[0089] Table 2: Example Library Functions

[0090]

[0091] Based on the above assumptions, the automatic modification verification process for test script 1 corresponding to test script version 1 using the test script automatic modification method provided in the embodiments of this application is as follows:

[0092] The executed test script 1 is identified, error log 1 is generated, and test script 1 is downloaded from the code repository to the verification directory.

[0093] Based on the script name corresponding to error log 1, poll the historical log information in the log database to obtain the latest execution success log 2, which was generated at the latest time.

[0094] Compare script code segment 1 in test script 1 in the verification directory with script code segment 2 at the same location in test script 2. If script code segment 1 and script code segment 2 are different, copy script code segment 2 into test script 1 in the verification directory to replace script code segment 1. If script code segment 1 and script code segment 2 are the same, search for the next successful execution log again.

[0095] After copying script code segment 2 into test script 1 in the verification directory to replace script code segment 1, verify the modified test script 1 in the verification directory.

[0096] The following section uses the library functions in the examples given in Table 2 to elaborate on the verification process, which includes virtual verification and simulated verification. The specific process is as follows:

[0097] Execute the modified test script 1 in the verification directory, and obtain the command "Show interface x state" issued after test script 1 calls the library function IntfGet;

[0098] The virtual execution database searches for the echo information corresponding to the command `Show interface x state`. It compares the return key names of the library functions in the echo information with the return key names of the library functions in the verification directory. If the return key names of the library functions in the echo information are `x.state` and `x.state_time`, and the return key name of the library functions in the verification directory is `x.state`, then the virtual verification passes.

[0099] If the return key names of the library functions in the echo message are x.state and x.state_time, and the return key name of the library functions in the verification directory is xips, meaning that the return key names of the library functions in the echo message do not include all the return key names of the library functions in the verification directory, then the virtual verification fails.

[0100] After the virtual verification fails, the code segment corresponding to the library function IntfGet called by script code segment 1 is checked to confirm whether the reason for the verification failure is a problem with the calling relationship of the library function.

[0101] In this example, assume that script code segment 1 calls the library function `IntfGet` with parameters `Intf` and `state`. Then, retrieve the code segment corresponding to parameters `Intf` and `state` from the library function `IntfGet` corresponding to script code segment 2 and replace the code segment corresponding to parameters `Intf` and `state` in the library function `IntfGet` corresponding to script code segment 1. Perform virtual verification again. If this virtual verification passes, execute the simulated verification. If this virtual verification fails, search for the next successful execution log entry.

[0102] The simulated execution device executes the modified test script 1 in the verification directory and prints the echo information. If the return value of the library function's return key name x.state in the echo information is up and the return value of the return key name x.state_time is 12s, and the return value of the library function's return key name x.state in the verification directory is up, then the simulation verification is successful. If the return value of the library function's return key name x.state in the echo information is down and the return value of the return key name x.state_time is 12s, and the return value of the library function's return key name x.state in the verification directory is up, then the simulation verification is unsuccessful.

[0103] After both virtual and simulated verifications pass, the test script 1 and library functions in the verification directory are compared with the test script 1 and library functions in the code repository to generate a patch file, which is then submitted to the code repository.

[0104] This application also provides an electronic device, which includes a memory, a processor, and a communication module. The memory, processor, and communication module are electrically connected to each other directly or indirectly to achieve data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines.

[0105] The memory is used to store programs or data. The memory can be, but is not limited to, Random Access Memory (RAM), Read Only Memory (ROM), Programmable Read-Only Memory (PROM), Erasable Programmable Read-Only Memory (EPROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), etc.

[0106] The processor is used to read / write data or programs stored in memory and perform corresponding functions. For example, when a computer program stored in memory is executed by the processor, the automatic test script modification method disclosed in the above embodiments can be implemented.

[0107] The communication module is used to establish communication connections between electronic devices and other electronic devices via a network, and to send and receive data via the network.

[0108] It should be understood that the above-described exemplary structure of the electronic device is not exhaustive; the electronic device may also include more or fewer components. Each component may be implemented using hardware, software, or a combination thereof.

[0109] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the test script automatic modification method disclosed in the above embodiments.

[0110] This application also provides a computer program product that, when executed by a processor, implements the test script automatic modification method disclosed in the above embodiments.

[0111] In the embodiments provided in this application, it should be understood that the disclosed methods can also be implemented in other ways. The embodiments described above are merely illustrative; for example, the flowcharts in the accompanying drawings illustrate the possible functions and operations of the methods and computer program products according to embodiments of this application. In this regard, each block in the flowchart may represent a module, segment, or portion of code containing one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than that shown in the accompanying drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved.

[0112] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0113] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or combinations that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for automatically modifying test scripts, characterized in that, The method includes: The system identifies and generates error logs for executed test scripts, retrieves the test scripts from the code repository, and downloads them to the verification directory. Based on the script name corresponding to the error log, poll the historical log information in the log database to obtain the execution success log corresponding to the script name; Obtain the test script corresponding to the execution success log from the code repository, modify the test script in the verification directory according to the test script corresponding to the execution success log, and verify the modified test script in the verification directory; After successful verification, submit the modified test scripts in the verification directory to the code repository.

2. The test script automatic modification method according to claim 1, characterized in that, The step of polling historical log information in the log database based on the script name corresponding to the error log to obtain the execution success log corresponding to the script name specifically includes: Based on the script name corresponding to the error log, poll the log database and search for the historical execution success information corresponding to the script name in order of log generation time from newest to oldest, and obtain the latest execution success log.

3. The test script automatic modification method according to claim 2, characterized in that, The error log includes at least one error log record. The step of obtaining the test script corresponding to the execution success log from the code repository and modifying the test script in the verification directory based on the test script corresponding to the execution success log specifically includes: The error log records in the error log are identified sequentially, and the location of the script code segment corresponding to the error log record is found in the test script corresponding to the error log record. Retrieve the test script corresponding to the execution success log from the code repository based on the script name; Obtain the successfully executed script code segment in the test script corresponding to the successful execution log, which is located at the same position as the script code segment corresponding to the error log record. Compare whether the script code segment corresponding to the error log record and the script code segment corresponding to the successful execution log are the same. If they are not the same, copy the successfully executed script code segment to the test script in the verification directory to replace the script code segment corresponding to the error log record.

4. The test script automatic modification method according to claim 3, characterized in that, The step of verifying the modified test scripts in the verification directory specifically includes: The modified test scripts in the verification directory are subjected to virtual verification. If the virtual verification fails, the library functions called by the test scripts corresponding to the error logs are obtained from the code repository and downloaded to the verification directory. Copy the code segment corresponding to the library function called by the script code segment corresponding to the successful execution log to the library function in the verification directory, replace the code segment corresponding to the library function called by the script code segment corresponding to the error log record, and perform virtual verification again. If the virtual verification passes, then perform simulated verification.

5. The test script automatic modification method according to claim 4, characterized in that, Before the step of performing virtual verification on the modified test scripts in the verification directory, the method further includes: A virtual execution database is periodically generated using a large number of historical log data files. The virtual execution database includes commands and echo information.

6. The test script automatic modification method according to claim 5, characterized in that, The step of performing virtual verification on the modified test scripts in the verification directory specifically includes: Execute the modified test script in the verification directory and obtain the commands issued after the test script calls the library functions; The system searches for the echo information corresponding to the command in the virtual execution database, compares the return key name of the library function in the echo information with the return key name of the library function in the verification directory. If the return key name of the library function in the echo information contains all the return key names of the library functions in the verification directory, the virtual verification passes. If the return key name of the library function in the echo information does not contain all the return key names of the library functions in the verification directory, the virtual verification fails.

7. The test script automatic modification method according to claim 6, characterized in that, The steps for performing the simulation verification specifically include: Create a simulated execution device based on the software version of the device under test corresponding to the error log; The modified test script in the verification directory is executed in the simulation execution device. If an error log is recorded again, the simulation verification fails; if no error log is recorded, the simulation verification passes.

8. The test script automatic modification method according to claim 7, characterized in that, The step of submitting the modified test scripts in the verification directory to the code repository after the verification is passed specifically includes: After all the script code segments and / or library function code segments corresponding to all error log records in the error log have been modified and verified, the test scripts and library functions in the verification directory are compared with the test scripts and library functions corresponding to the error logs in the code repository, a patch file is generated, and the patch file is submitted to the code repository.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the test script automatic modification method as described in any one of claims 1-8.

10. A computer program product, characterized in that, When the computer program product is executed by the processor, it implements the test script automatic modification method as described in any one of claims 1-8.