Test script processing method and device, electronic equipment and storage medium

The actual configuration command set is obtained by pre-executing the test script and compared with the standard configuration command set. The test script is corrected according to the configuration code base, which solves the problem of low detection and correction of the test script configuration command in the existing technology, and realizes efficient automated script writing and debugging, reducing the use of test resources.

CN119883875APending Publication Date: 2025-04-25MAIPU COMM TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311370669.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-20
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

In the existing technology, in automated testing, the configuration command detection and correction of test scripts is inefficient, and it requires occupancy of equipment resources. It is time-consuming and labor-intensive to check and modify humans, resulting in increased costs and low testing efficiency.

Method used

By pre-executing the code snippet in the test script, obtaining the actual configuration command set, comparing it with the standard configuration command set in the standard use case configuration file, correcting the test script based on the comparison results and the configuration code base to generate the target test script.

Benefits of technology

It realizes that the actual configuration commands and test scripts are differentially checked and corrected without occupying equipment resources, reducing manpower inspection and modification, improving the efficiency of automated script writing and debugging, and reducing the use of test resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119883875A_ABST
    Figure CN119883875A_ABST
Patent Text Reader

Abstract

The invention provides a test script processing method and device, electronic equipment and a storage medium, and the method comprises the steps that code segments in a test script are pre-executed, a plurality of actual configuration commands are acquired, the test script comprises at least one code segment, and when the code segments are pre-executed, the configuration commands are not sent to test equipment; generating an actual configuration command set according to the plurality of actual configuration commands; comparing the actual configuration command set with a standard configuration command set in the standard case configuration file to obtain a comparison result; and correcting the test script according to the comparison result and a configuration code library to obtain a target test script. According to the method, the difference between the actual configuration command and the test script can be checked and corrected under the condition that equipment resources are not occupied, manual troubleshooting and modification caused by script configuration errors are reduced, the automatic script writing and debugging efficiency is improved, and occupation of test resources is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of automated testing, and in particular to a test script processing method, device, electronic device and storage medium. Background Art

[0002] In the field of software testing, automated testing is usually used to improve test efficiency and reduce the manpower required for repeated testing. Automated testing requires the implementation of automated scripts based on test cases, and the execution of scripts to configure the test equipment or instruments, thereby verifying the functions and performance of the equipment under test. The initially generated script, whether manually written or initially generated by a tool, may contain configuration command omissions or configuration command errors, and cannot be directly used for automated test execution. Therefore, it is very important to detect and correct the configuration commands.

[0003] In the prior art, it is necessary to occupy equipment resources to debug the script, and manually check and correct the problems in the configuration commands based on the execution results. However, for a large number of configuration commands, manual troubleshooting and modification is very time-consuming and labor-intensive, and multiple debugging, inspection, and correction are required to achieve the configuration effect required by the use case, which not only occupies test resources but also consumes manpower and time, resulting in increased costs and low test efficiency. Summary of the invention

[0004] The purpose of this application is to provide a test script processing method, device, electronic device and storage medium to improve the efficiency of test script detection in order to address the deficiencies in the above-mentioned prior art.

[0005] To achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows:

[0006] In a first aspect, an embodiment of the present application provides a method for processing a test script, the method comprising:

[0007] Pre-executing a code segment in a test script and obtaining a plurality of actual configuration commands, wherein the test script includes at least one code segment, wherein when the code segment is pre-executed, no configuration command is sent to the test device;

[0008] generating an actual configuration command set according to the multiple actual configuration commands;

[0009] Comparing the actual configuration command set with the standard configuration command set in the standard use case configuration file to obtain a comparison result, wherein the standard configuration command set includes a plurality of standard configuration commands;

[0010] According to the comparison result and the configuration code library, the test script is corrected to obtain a target test script, wherein the configuration code library is used to store each standardized parameter configuration command set and a code segment corresponding to each standardized parameter configuration command set.

[0011] Optionally, comparing the actual configuration command set in the script configuration file with the standard configuration command set in the standard use case configuration file to obtain a comparison result includes:

[0012] Compare each actual configuration command in the actual configuration command set with each standard configuration command in each standard configuration command set in the standard use case configuration file to determine whether the actual configuration command set is consistent with the standard configuration command set;

[0013] If they are inconsistent, the actual configuration command set and the standard configuration command set are used as difference configuration command sets, and the standard configuration command set in the standard use case configuration file and the code segment in the test script corresponding to the execution of the actual configuration command set are respectively marked for difference to obtain a marked standard configuration command set and a marked code segment;

[0014] The marked standard configuration command set and the marked code segment are used as the comparison result.

[0015] Optionally, comparing each actual configuration command in the actual configuration command set with each standard configuration command in each standard configuration command set in the standard use case configuration file to determine whether the actual configuration command set is consistent with the standard configuration command set includes:

[0016] Comparing the actual configuration commands in the actual configuration command set with the standard configuration commands in the standard configuration command set in sequence according to the order of the actual configuration commands;

[0017] If the actual configuration command is inconsistent with the standard configuration command, reordering the actual configuration commands in the actual configuration command set to obtain a plurality of actual configuration command sets with different orders;

[0018] Each actual configuration command in the multiple actual configuration command sets with different sortings is compared with each standard configuration command in the standard configuration command set in sequence according to the sorting, to determine whether the actual configuration command set is consistent with the standard configuration command set.

[0019] Optionally, the correcting the test script according to the comparison result and the configuration code library to obtain a target test script includes:

[0020] According to the marked standard configuration command set and the configuration code library, the marked code segment is corrected to obtain a target test script.

[0021] Optionally, the step of correcting the marked code segment according to the marked standard configuration command set and the configuration code library to obtain a target test script includes:

[0022] If the marked standard configuration command set is the first difference configuration command set in pre-executing the test script, the test script continues to be pre-executed until the second difference configuration command set appears or the pre-execution of the test script is completed, then the marked code segment is corrected according to the first standard configuration command set and the configuration code library to obtain a corrected test script;

[0023] Iteratively pre-execute and correct the corrected test script until there is no difference configuration command set in the corrected test script, and then use the corrected test script without the difference configuration command set as the target test script.

[0024] Optionally, the correcting the marked code segment according to the first standard configuration command set and the configuration code library includes:

[0025] Searching the configuration code library for a target standardized parameter configuration command set that matches the first standard configuration command set and a code segment corresponding to the target standardized parameter configuration command set;

[0026] The marked code segment is replaced with the code segment corresponding to the target standardized parameter configuration command set.

[0027] Optionally, searching the configuration code library for a target standardized parameter configuration command set that matches the first standard configuration command set and a code segment corresponding to the target standardized parameter configuration command set includes:

[0028] Traversing each standard configuration command in the marked standard configuration command set, and taking the standardized parameter configuration command set containing the most standard configuration commands as the target standardized parameter configuration command set;

[0029] If the target standardized parameter configuration command set does not include all the standard configuration commands in the marked standard configuration commands, continue to search for the standard configuration commands not included in the configuration code library, add the code segment of the configuration command set that only includes the standard configuration commands not included to the code segment in the target standardized parameter configuration command set, and obtain the code segment corresponding to the added target standardized parameter configuration command set.

[0030] In a second aspect, an embodiment of the present application further provides a test script processing device, the device comprising:

[0031] An execution module, configured to pre-execute a code segment in a test script and obtain a plurality of actual configuration commands, wherein the test script includes at least one code segment, wherein when the code segment is pre-executed, no configuration command is sent to the test device;

[0032] A generating module, used for generating an actual configuration command set according to the multiple actual configuration commands;

[0033] A comparison module, used to compare the actual configuration command set with a standard configuration command set in a standard use case configuration file to obtain a comparison result, wherein the standard configuration command set includes a plurality of standard configuration commands;

[0034] A correction module is used to correct the test script according to the comparison result and the configuration code library to obtain a target test script, wherein the configuration code library is used to store each standardized parameter configuration command set and the code segment corresponding to each standardized parameter configuration command set.

[0035] Optionally, the comparison module is specifically used for:

[0036] Compare each actual configuration command in the actual configuration command set with each standard configuration command in each standard configuration command set in the standard use case configuration file to determine whether the actual configuration command set is consistent with the standard configuration command set;

[0037] If they are inconsistent, the actual configuration command set and the standard configuration command set are used as difference configuration command sets, and the standard configuration command set in the standard use case configuration file and the code segment in the test script corresponding to the execution of the actual configuration command set are respectively marked for difference to obtain a marked standard configuration command set and a marked code segment;

[0038] The marked standard configuration command set and the marked code segment are used as the comparison result.

[0039] Optionally, the comparison module is specifically used for:

[0040] Comparing the actual configuration commands in the actual configuration command set with the standard configuration commands in the standard configuration command set in sequence according to the order of the actual configuration commands;

[0041] If the actual configuration command is inconsistent with the standard configuration command, reordering the actual configuration commands in the actual configuration command set to obtain a plurality of actual configuration command sets with different orders;

[0042] Each actual configuration command in the multiple actual configuration command sets with different sortings is compared with each standard configuration command in the standard configuration command set in sequence according to the sorting, to determine whether the actual configuration command set is consistent with the standard configuration command set.

[0043] Optionally, the correction module is specifically used for:

[0044] According to the marked standard configuration command set and the configuration code library, the marked code segment is corrected to obtain a target test script.

[0045] Optionally, the correction module is specifically used for:

[0046] If the marked standard configuration command set is the first difference configuration command set in pre-executing the test script, the test script continues to be pre-executed until the second difference configuration command set appears or the pre-execution of the test script is completed, then the marked code segment is corrected according to the first standard configuration command set and the configuration code library to obtain a corrected test script;

[0047] Iteratively pre-execute and correct the corrected test script until there is no difference configuration command set in the corrected test script, and then use the corrected test script without the difference configuration command set as the target test script.

[0048] Optionally, the correction module is specifically used for:

[0049] Searching the configuration code library for a target standardized parameter configuration command set that matches the first standard configuration command set and a code segment corresponding to the target standardized parameter configuration command set;

[0050] The marked code segment is replaced with the code segment corresponding to the target standardized parameter configuration command set.

[0051] Optionally, the correction module is specifically used for:

[0052] Traversing each standard configuration command in the marked standard configuration command set, and taking the standardized parameter configuration command set containing the most standard configuration commands as the target standardized parameter configuration command set;

[0053] If the target standardized parameter configuration command set does not include all the standard configuration commands in the marked standard configuration commands, continue to search for the standard configuration commands not included in the configuration code library, add the code segment of the configuration command set that only includes the standard configuration commands not included to the code segment in the target standardized parameter configuration command set, and obtain the code segment corresponding to the added target standardized parameter configuration command set.

[0054] In the third aspect, an embodiment of the present application also provides an electronic device, comprising: a processor, a storage medium and a bus, wherein the storage medium stores program instructions executable by the processor, and when the application is running, the processor communicates with the storage medium through the bus, and the processor executes the program instructions to execute the steps of the test script processing method described in the first aspect above.

[0055] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and the computer program is read and executes the steps of the test script processing method described in the first aspect above.

[0056] The beneficial effects of this application are:

[0057] The present application provides a test script processing method, device, electronic device and storage medium. By obtaining the actual configuration command set generated during pre-execution when pre-executing the code segment in the test script, and comparing the actual configuration command set with the standard configuration command set, the test script is corrected according to the comparison result and the configuration code library. This can realize difference checking and correction between the actual configuration commands and the test script without occupying device resources, reduce the manpower investigation and modification caused by script configuration errors, improve the efficiency of automated script writing and debugging, and reduce the occupation of test resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0059] Figure 1 A flowchart of a method for processing a test script provided in an embodiment of the present application;

[0060] Figure 2 A schematic diagram of a configuration code library provided in an embodiment of the present application;

[0061] Figure 3 A flowchart of another test script processing method provided in an embodiment of the present application;

[0062] Figure 4 A flowchart of another test script processing method provided in an embodiment of the present application;

[0063] Figure 5 A flowchart of another test script processing method provided in an embodiment of the present application;

[0064] Figure 6 A schematic diagram of a device for a test script processing method provided in an embodiment of the present application;

[0065] Figure 7 A structural block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0066] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can be implemented out of sequence, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart under the guidance of the content of the present application, or remove one or more operations from the flowchart.

[0067] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0068] It should be noted that the term "comprising" will be used in the embodiments of the present application to indicate the existence of the features declared thereafter, but does not exclude the addition of other features.

[0069] In the prior art 1, an automated simulation execution method is disclosed, which involves checking the execution results of the script command and the data structure of the function, mainly obtaining the call results of the command or function based on the previous execution records, to perform error checking on the command execution results and function calls of the current script under test. It does not involve checking whether the configuration commands in the script meet the requirements of the use case, nor does it exist for error checking correction. And the simulation execution involved in this solution refers to the process of connecting the test equipment and issuing the script command. It is necessary to occupy equipment resources to debug the script.

[0070] In the prior art 2, a command line inspection method and device are disclosed, and a network device command input inspection is provided to solve some conflicts and dependency inspection problems when the configuration and effectiveness of the device are separated. The scheme involves user command input, the command is converted into a complete configuration command under the view, the network device obtains the configuration command to be checked with a specified relationship type with the complete configuration command, and then replaces the elements and optional parameter marks in the command to be checked with the elements input by the user, so that it can be obtained whether there is a text configuration file that matches the replaced configuration command to be checked. The scheme is intended to check whether the command entered by the user is a command that can be issued by the device. The scheme involves marking and replacement, which are operations that will be used in this scheme, but the scheme involves regular replacement of command elements and optional elements, so as to compare with the existing text configuration files of the network device, and draw a conclusion on whether it is a configurable command for the device, which requires device operation, and its marking and replacement do not involve correcting the configuration. The scheme also requires occupying device resources to debug the script.

[0071] Therefore, based on the above-mentioned shortcomings in the prior art, the present application provides a method for processing a test script. The present application pre-executes the test script, that is, extracts the configuration commands in the function call process in the test script code (the function call will be executed, but the configuration command will not be sent to the device). There is no need to check the configuration command execution results and function call results, which makes it simpler to implement.

[0072] Optionally, the test script processing method provided in the embodiment of the present application is applied to an electronic device, which may be a terminal device with computing and display capabilities, such as a mobile phone, a tablet computer, a laptop computer, a PDA, a desktop computer, or a server. Specifically, it can be applied to an application in a terminal device, such as an APP (application, mobile phone software) of a mobile phone, an application system on a computer, etc.

[0073] The specific implementation process of processing the test script provided in the embodiment of the present application is explained in detail below.

[0074] Figure 1 The flowchart of a method for processing a test script provided in an embodiment of the present application is shown in FIG. 1 , wherein the execution subject of the method is the aforementioned electronic device. Figure 1 As shown, the method includes:

[0075] S101, pre-execute a code segment in a test script and obtain a plurality of actual configuration commands.

[0076] The test script may include at least one code segment, and when the code segment is pre-executed, no configuration command is sent to the test device.

[0077] Optionally, the code segments in the test script can be pre-executed by pre-executing function calls. Each function call can pre-execute a code segment. When the code segment is pre-executed, multiple actual configuration commands can be generated and the generated multiple actual configuration commands can be obtained. The pre-execution means that the function call will be executed, but the generated actual configuration commands will not be sent to the real test device. Only the configuration commands in the code segment are obtained during the execution process.

[0078] S102: Generate an actual configuration command set according to multiple actual configuration commands.

[0079] Optionally, multiple actual configuration commands generated by the code segment can be obtained during the pre-execution of the function call, and an actual configuration command set can be generated according to the generated multiple actual configuration commands, and the generated actual configuration command set can be saved after each pre-execution of a function call. Specifically, the actual configuration command set can be saved in units of each function call, so that the actual configuration command set can be saved in one configuration view, as shown below:

[0080] Configuration View Figure 1 : Configuration command 1, configuration command 2…configuration command n;

[0081] Configuration View Figure 2 : Configuration command 1, configuration command 2…configuration command n.

[0082] Among them, the configuration view Figure 1 What can be stored in the pre-execution function call 1 are multiple actual configuration commands. Figure 2 What can be stored in is multiple actual configuration commands obtained by pre-executing function call 2, and so on, saving the actual configuration command sets generated by different code segments in the test script, and also saving the generated actual configuration command sets to the script configuration command file for subsequent application.

[0083] S103: Compare the actual configuration command set with the standard configuration command set in the standard use case configuration file to obtain a comparison result.

[0084] The standard configuration command set may include multiple standard configuration commands.

[0085] Optionally, for a test case, a complete device configuration command needs to be provided, and the complete device configuration command of the test case can be stored in the standard case configuration file. The specific storage form is the configuration view form in S102 above. A test case can include multiple code segments, and each standard configuration command in each code segment can be stored in the form of the above configuration view, and multiple standard configuration command sets can be obtained for the test case.

[0086] S104: Correct the test script according to the comparison result and the configuration code library to obtain a target test script.

[0087] The configuration code library can store various standardized parameter configuration command sets and code segments corresponding to each standardized parameter configuration command set. The standardized parameter configuration command sets refer to the configuration parameters in each configuration command in each standard configuration command set that are parameterized. The structural diagram of the configuration code library is shown in the attached figure. Figure 2 As shown. The correspondence between the configuration commands and script code segments executed by historical scripts can be collected and saved regularly, or the corresponding code segments can be manually input for new configuration commands. Each standardized parameter configuration command in each standardized parameter configuration command set in the configuration code library can be represented by a unified parameter value. For example, the parameter value of each configuration parameter in each standard configuration command in the standard configuration command set can be standardized and represented by {X1, X2…X n}. For example:

[0088] Configuration command set 1:

[0089] Interface X1

[0090] IP address X2 X3

[0091] The corresponding code snippet:

[0092] intCfg(intf=X1, ipv4=X2, mask=X3)

[0093] Among them, X1, X2, and X3 refer to the parameter values ​​of the configuration parameters of the standard configuration command.

[0094] In this embodiment, by obtaining the actual configuration command set generated during pre-execution when pre-executing the code segment in the test script, and comparing the actual configuration command set with the standard configuration command set, the test script is corrected according to the comparison results and the configuration code library. It is possible to check and correct the differences between the actual configuration commands and the test script without occupying device resources, which can reduce the manpower investigation and modification caused by script configuration errors, improve the efficiency of automated script writing and debugging, and reduce the occupation of test resources.

[0095] Figure 3 A flowchart of another test script processing method provided in an embodiment of the present application is shown as follows: Figure 3 As shown, in the above S103, the actual configuration command set is compared with the standard configuration command set in the standard use case configuration file to obtain a comparison result, which may include:

[0096] S201: Compare each actual configuration command in the actual configuration command set with each standard configuration command in the standard configuration command set in the standard use case configuration file to determine whether the actual configuration command set is consistent with the standard configuration command set.

[0097] If they are inconsistent, execute S202; if they are consistent, execute S203.

[0098] Optionally, the actual configuration commands in the actual configuration command set can be compared with the standard configuration commands in the standard configuration command sets to see if they are consistent. If they are consistent, it means that the actual configuration command set is consistent with the standard configuration command set, and the following step S203 can be executed; if they are inconsistent, it means that the actual configuration command set is inconsistent with the standard configuration command set, that is, there is a difference between the actual configuration command set and the standard configuration command set, then the actual configuration command set and the standard configuration command set can be used as difference configuration command sets, and the following step S202 can be executed.

[0099] S202: Differentially mark the standard configuration command set in the standard case configuration file and the code segment in the test script corresponding to the actual configuration command set to obtain a marked standard configuration command set and a marked code segment.

[0100] Specifically, the standard configuration command set that is inconsistent with the actual configuration command set can be differentially marked in the standard use case configuration file, and the code segment corresponding to the pre-execution of the actual configuration command set can be differentially marked in the test script, so as to obtain the marked standard configuration command set and the marked code segment.

[0101] S203. Continue to execute the test script until the test script is completed.

[0102] Optionally, if the actual configuration command set is consistent with the standard configuration command set, it means that there is no problem with the actual configuration command. At this time, other code segments of the test script can be continued to be executed through function calls until the test script is completed.

[0103] Figure 4 A flowchart of another method for processing a test script provided in an embodiment of the present application is shown as follows: Figure 4 As shown, in the above S201, comparing each actual configuration command in the actual configuration command set with each standard configuration command in each standard configuration command set in the standard use case configuration file to determine whether the actual configuration command set is consistent with the standard configuration command set may include:

[0104] S301: Compare each actual configuration command in the actual configuration command set with each standard configuration command in the standard configuration command set in sequence according to the order of each actual configuration command.

[0105] Optionally, if the actual configuration commands in the actual configuration command set are sorted in order, they are saved according to the order in which they are generated, and the standard configuration commands in the standard configuration command set are saved according to the standard order. During the initial comparison, the actual configuration command set is compared with the standard configuration commands in the standard configuration command set in order according to the order in which they are generated and saved.

[0106] If they are inconsistent, it means that the order of each actual configuration command in the actual configuration command set and each standard configuration command may be different, and then the following S302 is executed; if they are consistent, then the following S304 is executed.

[0107] For example, there are 3 actual configuration command sets A saved this time, specifically, the actual configuration command set may be, configuration view: actual configuration command 1, actual configuration command 2, actual configuration command 3; the standard configuration command set is: standard configuration command 1, standard configuration command 2, standard configuration command 3. Then, the actual configuration command 1 may be compared with the standard configuration command 1, the actual configuration command 2 with the standard configuration command 2, and the actual configuration command 3 with the standard configuration command 3, respectively, to determine whether each actual configuration command is consistent with each standard configuration command.

[0108] S302: Reorder the actual configuration commands in the actual configuration command set to obtain a plurality of actual configuration command sets in different orders.

[0109] Exemplarily, continuing to take the above-mentioned actual configuration command set A as an example, after reordering, 5 actual configuration command sets with different orders can be obtained, for example, they can be [actual configuration command 1, actual configuration command 3, actual configuration command 2], [actual configuration command 2, actual configuration command 1, actual configuration command 3], [actual configuration command 3, actual configuration command 1, actual configuration command 2], [actual configuration command 2, actual configuration command 3, actual configuration command 1], [actual configuration command 3, actual configuration command 2, actual configuration command 1].

[0110] S303: Compare the actual configuration commands in the multiple actual configuration command sets with the standard configuration command sets in sequence according to their order, and determine whether the actual configuration command sets are consistent with the standard configuration command sets.

[0111] Optionally, if there is an actual configuration command set among multiple actual configuration command sets in different orders that is consistent with the standard configuration command set, it means that the actual configuration command set is consistent with the standard configuration command set; if the multiple actual configuration command sets in different orders are all different from the standard configuration command set, it means that the actual configuration command set is inconsistent with the standard configuration command set, then according to the embodiment in the above S202, the standard configuration command set in the standard use case configuration file and the code segments in the test script corresponding to the execution of the actual configuration command set can be respectively marked as differences.

[0112] Exemplarily, continuing with the example of the five actual configuration command sets reordered in the above S302, the five actual configuration command sets reordered are compared with each standard configuration command of the standard configuration command set in sequence according to the order. The specific comparison process is similar to the initial comparison process in the above S301, and it can be determined whether the actual configuration command set is consistent with the standard configuration command set.

[0113] S304: Continue to execute the test script until the test script is completed.

[0114] Optionally, in S104, correcting the test script according to the comparison result and the configuration code library to obtain the target test script may include:

[0115] Optionally, the marked code segment can be corrected according to the marked standard configuration command set and the configuration code library to obtain the target test script. Specifically, the marked code segment can be corrected according to the marked standard configuration command set and the standardized parameter configuration command set stored in the configuration code library and the code segment corresponding to the standardized parameter configuration command set.

[0116] Among them, it can be obtained from the above S202 that the marked code segment refers to the code segment corresponding to the actual configuration command set that is different from the standard configuration command set, that is, an error occurs in the actual configuration command generated when the marked code segment is pre-executed, so the code segment needs to be corrected.

[0117] Optionally, the above-mentioned correcting the marked code segment according to the marked standard configuration command set and the configuration code library to obtain the target test script may include:

[0118] Optionally, if the marked standard configuration command set is the first difference configuration command set in pre-execution of the test script, the test script continues to be pre-executed until the second difference configuration command set appears or the pre-execution of the test script is completed. Then, based on the first standard configuration command set and the configuration code library, the marked code segment corresponding to the actual configuration command set that is inconsistent with the marked standard configuration command set is corrected to obtain a corrected test script.

[0119] Optionally, since the actual configuration command set generated by pre-executing each code segment of the test script is obtained while pre-executing each code segment, and the generated actual configuration command set is continuously checked and processed, when the marked standard configuration command set and the marked code segment are compared according to the method of the above embodiment and the marked standard configuration command set is the first difference configuration command set, at this time, the marked code segment is not directly corrected, but when the second difference configuration command set appears when continuing to pre-execute other code segments of the test script or when the pre-execution of the test script is completed, the correction is performed according to the first marked code segment. Among them, the pre-execution of the test script is completed means that only the first marked standard configuration command set and the marked code segment appear in the test script.

[0120] Optionally, when the first marked code segment is corrected, a corrected test script is obtained, and the corrected test script can be iteratively executed. When a new first marked standard configuration command set and a marked code segment appear in the corrected test script, the correction method is consistent with the first difference configuration command set appearing in the above-mentioned method, and a new corrected test script is obtained until there is no difference configuration command set in the new corrected test script, that is, the marked standard configuration command set is no longer generated when the test script is pre-executed, and the new corrected test script without the difference configuration command set is used as the target test script.

[0121] Optionally, when iteratively executing the corrected test script, specifically, execution can be started from the marked code segment of this correction, that is, the corrected marked code segment is re-executed and the code is checked again. When the actual configuration command set generated again by the marked code segment is consistent with the standard configuration command set, the marked code segment and the marked standard configuration command set are canceled.

[0122] In this embodiment, by returning to calibrate the last marked code segment when a difference configuration command set appears next time, the difference point can be pinpointed, and difficulty in calibration caused by too many differences can be avoided, so that the calibration result is more accurate.

[0123] Figure 5 A flowchart of another test script processing method provided in an embodiment of the present application is shown as follows: Figure 5 As shown, the correction of the marked code segment according to the first standard configuration command set and the configuration code library may include:

[0124] S401. Searching a configuration code library for a target standardized parameter configuration command set that matches a first standard configuration command set and a code segment corresponding to the target standardized parameter configuration command set.

[0125] For example, if the standard configuration command set marked in the standard use case configuration file is as follows:

[0126] router ospf 101

[0127] router-id 113.255.255.1

[0128] network 112.0.0.0 0.0.0.255area 0

[0129] network 113.255.255.1 0.0.0.0area 0

[0130] Optionally, since a standardized parameter configuration command set is stored in the configuration code library, it is necessary to parameterize the marked standard configuration command set. Specifically, the configuration parameters in each marked standard configuration command in the marked standard configuration command set are parameterized to obtain a parameterized marked standardized parameter configuration command set, and the original parameters are stored in a preset dictionary. The processed marked standardized parameter configuration command set and parameter dictionary are as follows:

[0131] router ospf Z1

[0132] router-id Z2

[0133] network Z3 area Z4

[0134] The parameter dictionary is as follows:

[0135] {Z1:101,Z2:"113.255.255.1",Z3:"112.0.0.0 0.0.0.255",Z4:0,Z5:

[0136] "113.255.255.1 0.0.0.0,Z6:0"}

[0137] Optionally, a target standardized parameter configuration command set matching the marked parameterized configuration command set is searched in the configuration code base through a regular search method.

[0138] For example, if the matched target standardized parameter configuration command set is as follows:

[0139] router ospf X1

[0140] router-id X2

[0141] network X3 area X4

[0142] Code snippet:

[0143] ospf_cfg(ospf=X1,router_id=X2,network=X3,area=X4)

[0144] S402: Replace the marked code segment with the code segment corresponding to the target standardized parameter configuration command set.

[0145] Continuing with the example in S401 above, the marked code segment can be replaced with the code segment corresponding to the matched target standardized parameter configuration command set in the test script. The replaced test script code is as follows: ospf_cfg(ospf=101, router_id="113.255.255.1", network="112.0.0.0 0.0.0.255", area=0).

[0146] Optionally, each marked code segment in the test script may be corrected separately according to steps S401-S402 to obtain a target test script.

[0147] Optionally, searching the configuration code library for a target standardized parameter configuration command set that matches the first standard configuration command set and a code segment corresponding to the target standardized parameter configuration command set in S401 may include:

[0148] Optionally, each standard configuration command in the marked standard configuration command set is traversed, and a standardized parameter configuration command set containing the most standard configuration commands is used as a target standardized parameter configuration command set.

[0149] Optionally, the standardized parameter configuration commands of each tag in the standardized parameter configuration command set of the tags after the parameterization processing can be traversed in turn to find the standardized parameter configuration command set containing the most standardized parameter configuration commands of the tags from the configuration code library as the target standardized parameter configuration command set. For example, the target standardized parameter configuration command set can be found in the configuration code library through regular search based on router ospf Z1, router-idZ2, network Z3, and area Z4 in the standardized parameter configuration command set of the tags.

[0150] Specifically, a first standardized parameter configuration command set combination including Z1 can be first searched in the configuration code library, wherein the first standardized parameter configuration command set includes at least one standardized parameter configuration command set, and then a second standardized parameter configuration command set combination including Z2 can be searched in the first standardized parameter configuration command set combination, and then a third standardized parameter configuration command set combination including Z3 can be searched in the second standardized parameter configuration command set combination, and finally a fourth standardized parameter configuration command set including Z4 can be searched in the third standardized parameter configuration command set. If the fourth standardized parameter configuration command set includes four standardized parameter configuration commands, namely Z1, Z2, Z3 and Z4, the fourth standardized parameter configuration command set is used as the target standardized parameter configuration command set.

[0151] Optionally, if the target standardized parameter configuration command set does not include all the standard configuration commands in the marked standard configuration commands, continue to search the configuration code library for the standard configuration commands that are not included, add the code segment of the configuration command set that only includes the standard configuration commands that are not included to the code segment in the target standardized parameter configuration command set, and obtain the code segment corresponding to the added target standardized parameter configuration command set, and use the code segment corresponding to the added target standardized parameter configuration command set as the target test script.

[0152] Specifically, if the target standardized parameter configuration command set does not include all the standardized parameter configuration commands in the marked standardized parameter configuration commands, then continue to search for the standardized parameter configuration commands not included in the configuration code library, add the code segment of the standardized parameter configuration command set that only includes the not included standardized parameter configuration commands to the code segment of the target standardized parameter configuration command set, and obtain the code segment corresponding to the added target standardized parameter configuration command set, and then use the code segment corresponding to the added target standardized parameter configuration command set as the target test script.

[0153] Optionally, if the marked standard configuration command set is not found in the configuration code library, a code segment corresponding to the marked standard configuration command set may be manually entered into the configuration code library.

[0154] Figure 6 A schematic diagram of a device for processing a test script provided in an embodiment of the present application, such as Figure 6 As shown, the device comprises:

[0155] An execution module 501, configured to pre-execute a code segment in a test script and obtain a plurality of actual configuration commands, wherein the test script includes at least one code segment, wherein when the code segment is pre-executed, no configuration command is sent to the test device;

[0156] A generating module 502, configured to generate an actual configuration command set according to the plurality of actual configuration commands;

[0157] A comparison module 503 is used to compare the actual configuration command set with the standard configuration command set in the standard use case configuration file to obtain a comparison result, wherein the standard configuration command set includes a plurality of standard configuration commands;

[0158] The correction module 504 is used to correct the test script according to the comparison result and the configuration code library to obtain a target test script, wherein the configuration code library is used to store each standardized parameter configuration command set and the code segment corresponding to each standardized parameter configuration command set.

[0159] Optionally, the comparison module 503 is specifically used for:

[0160] Compare each actual configuration command in the actual configuration command set with each standard configuration command in each standard configuration command set in the standard use case configuration file to determine whether the actual configuration command set is consistent with the standard configuration command set;

[0161] If they are inconsistent, the actual configuration command set and the standard configuration command set are used as difference configuration command sets, and the standard configuration command set in the standard use case configuration file and the code segment in the test script corresponding to the execution of the actual configuration command set are respectively marked for difference to obtain a marked standard configuration command set and a marked code segment;

[0162] The marked standard configuration command set and the marked code segment are used as the comparison result.

[0163] Optionally, the comparison module 503 is specifically used for:

[0164] Comparing the actual configuration commands in the actual configuration command set with the standard configuration commands in the standard configuration command set in sequence according to the order of the actual configuration commands;

[0165] If the actual configuration command is inconsistent with the standard configuration command, reordering the actual configuration commands in the actual configuration command set to obtain a plurality of actual configuration command sets with different orders;

[0166] Each actual configuration command in the multiple actual configuration command sets with different sortings is compared with each standard configuration command in the standard configuration command set in sequence according to the sorting, to determine whether the actual configuration command set is consistent with the standard configuration command set.

[0167] Optionally, the correction module 504 is specifically used for:

[0168] According to the marked standard configuration command set and the configuration code library, the marked code segment is corrected to obtain a target test script.

[0169] Optionally, the correction module 504 is specifically used for:

[0170] If the marked standard configuration command set is the first difference configuration command set in pre-executing the test script, the test script continues to be pre-executed until the second difference configuration command set appears or the pre-execution of the test script is completed, then the marked code segment is corrected according to the first standard configuration command set and the configuration code library to obtain a corrected test script;

[0171] Iteratively pre-execute and correct the corrected test script until there is no difference configuration command set in the corrected test script, and then use the corrected test script without the difference configuration command set as the target test script.

[0172] Optionally, the correction module 504 is specifically used for:

[0173] Searching the configuration code library for a target standardized parameter configuration command set that matches the first standard configuration command set and a code segment corresponding to the target standardized parameter configuration command set;

[0174] The marked code segment is replaced with the code segment corresponding to the target standardized parameter configuration command set.

[0175] Optionally, the correction module 504 is specifically used for:

[0176] Traversing each standard configuration command in the marked standard configuration command set, and taking the standardized parameter configuration command set containing the most standard configuration commands as the target standardized parameter configuration command set;

[0177] If the target standardized parameter configuration command set does not include all the standard configuration commands in the marked standard configuration commands, continue to search for the standard configuration commands not included in the configuration code library, add the code segment of the configuration command set that only includes the standard configuration commands not included to the code segment in the target standardized parameter configuration command set, and obtain the code segment corresponding to the added target standardized parameter configuration command set.

[0178] Figure 7 FIG. 6 is a structural block diagram of an electronic device 600 provided in an embodiment of the present application. Figure 5 As shown, the electronic device may include: a processor 601 and a memory 602 .

[0179] Optionally, a bus 603 may also be included, wherein the memory 602 is used to store machine-readable instructions executable by the processor 601 (for example, Figure 6 The execution module, the generation module, the comparison module, the execution instructions corresponding to the correction module in the device, etc.), when the electronic device 600 is running, the processor 601 communicates with the memory 602 through the bus 603, and the method steps in the above method embodiment are executed by the processor 601.

[0180] An embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the method steps in the above-mentioned test script processing method embodiment are executed.

[0181] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the method embodiment, and will not be repeated in this application. In the several embodiments provided in this application, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation. For example, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.

[0182] In addition, each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), disk or optical disk and other media that can store program code.

[0183] The above are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be covered by the protection scope of the present application.

Claims

1. A method for processing a test script, characterized in that: The method comprises: Pre-executing a code segment in a test script and obtaining a plurality of actual configuration commands, wherein the test script includes at least one code segment, wherein when the code segment is pre-executed, no configuration command is sent to the test device; generating an actual configuration command set according to the multiple actual configuration commands; Comparing the actual configuration command set with the standard configuration command set in the standard use case configuration file to obtain a comparison result, wherein the standard configuration command set includes a plurality of standard configuration commands; According to the comparison result and the configuration code library, the test script is corrected to obtain a target test script, wherein the configuration code library is used to store each standardized parameter configuration command set and a code segment corresponding to each standardized parameter configuration command set.

2. The test script processing method according to claim 1, characterized in that: The comparing the actual configuration command set in the script configuration file with the standard configuration command set in the standard use case configuration file to obtain a comparison result includes: Compare each actual configuration command in the actual configuration command set with each standard configuration command in each standard configuration command set in the standard use case configuration file to determine whether the actual configuration command set is consistent with the standard configuration command set; If they are inconsistent, the actual configuration command set and the standard configuration command set are used as difference configuration command sets, and the standard configuration command set in the standard use case configuration file and the code segment in the test script corresponding to the execution of the actual configuration command set are respectively marked for difference to obtain a marked standard configuration command set and a marked code segment; The marked standard configuration command set and the marked code segment are used as the comparison result.

3. The test script processing method according to claim 2, characterized in that: The comparing each actual configuration command in the actual configuration command set with each standard configuration command in each standard configuration command set in the standard use case configuration file to determine whether the actual configuration command set is consistent with the standard configuration command set includes: Comparing the actual configuration commands in the actual configuration command set with the standard configuration commands in the standard configuration command set in sequence according to the order of the actual configuration commands; If the actual configuration command is inconsistent with the standard configuration command, reordering the actual configuration commands in the actual configuration command set to obtain a plurality of actual configuration command sets with different orders; Each actual configuration command in the multiple actual configuration command sets with different sortings is compared with each standard configuration command in the standard configuration command set in sequence according to the sorting, to determine whether the actual configuration command set is consistent with the standard configuration command set.

4. The test script processing method according to claim 2, characterized in that: The step of correcting the test script according to the comparison result and the configuration code library to obtain a target test script includes: According to the marked standard configuration command set and the configuration code library, the marked code segment is corrected to obtain a target test script.

5. The test script processing method according to claim 4, characterized in that: The method of correcting the marked code segment according to the marked standard configuration command set and the configuration code library to obtain a target test script includes: If the marked standard configuration command set is the first difference configuration command set in pre-executing the test script, the test script continues to be pre-executed until the second difference configuration command set appears or the pre-execution of the test script is completed, then the marked code segment is corrected according to the first standard configuration command set and the configuration code library to obtain a corrected test script; Iteratively pre-execute and correct the corrected test script until there is no difference configuration command set in the corrected test script, and then use the corrected test script without the difference configuration command set as the target test script.

6. The test script processing method according to claim 5, characterized in that: The correcting the marked code segment according to the first standard configuration command set and the configuration code library includes: Searching the configuration code library for a target standardized parameter configuration command set that matches the first standard configuration command set and a code segment corresponding to the target standardized parameter configuration command set; The marked code segment is replaced with the code segment corresponding to the target standardized parameter configuration command set.

7. The test script processing method according to claim 6, characterized in that: Searching the configuration code library for a target standardized parameter configuration command set that matches the first standard configuration command set and a code segment corresponding to the target standardized parameter configuration command set, including: Traversing each standard configuration command in the marked standard configuration command set, and taking the standardized parameter configuration command set containing the most standard configuration commands as the target standardized parameter configuration command set; If the target standardized parameter configuration command set does not include all the standard configuration commands in the marked standard configuration commands, continue to search for the standard configuration commands not included in the configuration code library, add the code segment of the configuration command set that only includes the standard configuration commands not included to the code segment in the target standardized parameter configuration command set, and obtain the code segment corresponding to the added target standardized parameter configuration command set.

8. A test script processing device, characterized in that: include: An execution module, configured to pre-execute a code segment in a test script and obtain a plurality of actual configuration commands, wherein the test script includes at least one code segment, wherein when the code segment is pre-executed, no configuration command is sent to the test device; A generating module, used for generating an actual configuration command set according to the multiple actual configuration commands; A comparison module, used to compare the actual configuration command set with a standard configuration command set in a standard use case configuration file to obtain a comparison result, wherein the standard configuration command set includes a plurality of standard configuration commands; A correction module is used to correct the test script according to the comparison result and the configuration code library to obtain a target test script, wherein the configuration code library is used to store each standardized parameter configuration command set and the code segment corresponding to each standardized parameter configuration command set.

9. An electronic device, characterized in that: It comprises a memory and a processor, wherein the memory stores a computer program executable by the processor, and the processor implements the steps of the test script processing method described in any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the test script processing method according to any one of claims 1 to 7 are executed.