An automated test script generation method, system, device and storage medium

CN122884866APending Publication Date: 2026-10-09BEIJING CHJ AUTOMOTIVE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611389993.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-08
Publication Date
2026-10-09

AI Technical Summary

Technical Problem

然而,现有自动化测试技术通常仅将上述数据用于行为分析、问题定位或统计分析,尚未形成能够直接支撑自动化测试脚本生成的统一数据组织方式

Benefits of technology

[0022]本公开实施例提供的技术方案与现有技术相比具有如下优点:

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122884866A_ABST
    Figure CN122884866A_ABST
Patent Text Reader

Abstract

The present disclosure relates to the technical field of script generation, and particularly relates to an automatic test script generation method, system, device and storage medium, the method comprising: obtaining a user real action sequence, and performing action deduplication according to inherent attributes of each action to obtain a target action sequence; establishing a mapping relationship between each state variable in a state set and a pre-configured state setting fragment, and storing the mapping relationship to a database; obtaining a first action state set of the target action sequence in the database, configuring a corresponding state setting fragment for each state variable in the first action state set according to the mapping relationship, and obtaining an environment initialization script; searching for a candidate script fragment according to the inherent attribute of each action, and matching each action with a corresponding state set to obtain a target script fragment; and splicing the target script fragment with the environment initialization script to generate an automatic test script. The automatic test script generated according to the user real behavior data can truly reflect a user operation process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of script generation technology, and in particular to an automated test script generation method, system, device and storage medium. Background Technology

[0002] With the increasing complexity of smart terminals, in-vehicle systems, and various software applications, and the accelerating pace of software version iterations, automated testing has become a crucial means to ensure software quality and improve testing efficiency. Currently, automated testing typically relies on testers writing corresponding test scripts using automated testing frameworks based on test requirements or test cases, and then executing these scripts to verify functionality. Because different business scenarios involve significant differences in pages, operational processes, and operational states, testers need to repeatedly write, maintain, and adjust test scripts for different test scenarios, resulting in a large workload for test script development and high maintenance costs.

[0003] Meanwhile, a large amount of user operation logs or behavioral data are generated during software operation. This data can objectively reflect the user's actual operation process and usage habits. However, existing automated testing technologies typically only use this data for behavioral analysis, problem localization, or statistical analysis, and have not yet formed a unified data organization method that can directly support the generation of automated test scripts. For complex business scenarios involving continuous operations, testers still need to manually analyze the operation process based on the log content and rewrite the test scripts in combination with the specific business logic. This is not only inefficient, but also prone to discrepancies between the test scripts and the actual user operation process due to human misunderstanding.

[0004] Therefore, existing technologies cannot solve the problem of how to fully utilize real user behavior data to automatically generate automated test scripts that can truly reflect user operation processes. Summary of the Invention

[0005] To address the aforementioned technical issues, this disclosure provides an automated test script generation method, system, device, and storage medium.

[0006] This disclosure provides a method for generating automated test scripts, including: Obtain the user's actual action sequence, and perform action deduplication on the user's actual action sequence according to the inherent attributes of each action to obtain the target action sequence; Obtain the state set of the target action sequence, establish a mapping relationship between each state variable in the state set and a pre-configured state setting segment, and store the target action sequence, the state set, and the mapping relationship in a database; Obtain the first action state set of the target action sequence in the database, traverse each state variable in the first action state set, configure corresponding state setting fragments for each state variable in the first action state set according to the mapping relationship, combine the configured state setting fragments to obtain the environment initialization script; According to the action order of the target action sequence, candidate script fragments are searched based on the inherent attributes of each action, and the state set corresponding to each action is matched with each candidate script fragment to obtain the target script fragment; The environment initialization script and the target script fragment are concatenated according to the target action sequence to generate an automated test script.

[0007] Further, the step of deduplicating the user's actual action sequence based on the inherent attributes of each action to obtain the target action sequence includes: Extract the inherent attributes of each action in the user's real action sequence, and compare whether the inherent attributes of each action are consistent; When all the inherent attributes of the actions are the same, the actions with the same inherent attributes are identified as duplicate actions and deleted. When any inherent attribute is inconsistent, actions with inconsistent inherent attributes are identified as different actions and retained in the target action sequence.

[0008] Further, the step of configuring corresponding state setting fragments for each state variable in the first action state set according to the mapping relationship, and combining the configured state setting fragments to obtain the environment initialization script includes: Iterate through each state variable in the first action state set, and obtain the state setting fragment corresponding to each state variable according to the mapping relationship; Based on the state values ​​corresponding to each state variable as input parameters, configure the corresponding state setting fragments; The environment initialization script is obtained by combining and configuring each state setting fragment according to the order of each state variable in the first action state set.

[0009] Further, the step of searching for candidate script fragments according to the action order of the target action sequence and based on the inherent attributes of each action includes: According to the action sequence of the target action sequence, read the inherent attributes of each action in turn; Based on the inherent attributes of each action, script fragments with the same inherent attributes are retrieved from the script fragment library to obtain candidate script fragments for the corresponding actions.

[0010] Further, the step of matching the state set corresponding to each action with each candidate script fragment to obtain the target script fragment includes: Get the dependency status of each candidate script fragment; Compare the set of states corresponding to the action with the dependency states corresponding to each candidate script fragment; Count the number of states in each candidate script segment that match the state set; The script fragments are sorted from largest to smallest according to the number of consistent states, and the first candidate script fragment in the sorting result is determined as the target script fragment.

[0011] Further, comparing the set of states corresponding to the action with the dependency states corresponding to each candidate script fragment includes: When the dependent state is an enumerated value state, determine whether the state variable and the state value are consistent. When the dependent state is a range value state, determine whether the state values ​​in the state set are within the value range corresponding to the dependent state; If any dependent state is mutually exclusive with the corresponding state in the state set, then the corresponding candidate script fragment is removed.

[0012] Further, the step of concatenating the environment initialization script and the target script fragment according to the target action sequence to generate an automated test script includes: Set the environment initialization script as a pre-script part; Import each target script fragment in the order of the target action sequence, call each target script fragment in sequence, and pass in the action parameters and status parameters of the corresponding action; The environment initialization script and the target script fragments are combined to generate the automated test script.

[0013] This disclosure also provides an automated test script generation system, including: The acquisition module is used to acquire the user's real action sequence and perform action deduplication on the user's real action sequence according to the inherent attributes of each action to obtain the target action sequence. The storage module is used to acquire the state set of the target action sequence, establish a mapping relationship between each state variable in the state set and a pre-configured state setting segment, and store the target action sequence, the state set and the mapping relationship in the database; The configuration module is used to obtain the first action state set of the target action sequence in the database, traverse each state variable in the first action state set, configure corresponding state setting fragments for each state variable in the first action state set according to the mapping relationship, and combine the configured state setting fragments to obtain the environment initialization script. The matching module is used to search for candidate script fragments according to the action order of the target action sequence and the inherent attributes of each action, and to match the state set corresponding to each action with each candidate script fragment to obtain the target script fragment; The generation module is used to concatenate the environment initialization script and the target script fragment according to the target action sequence to generate an automated test script.

[0014] Furthermore, the acquisition module is specifically used for: Extract the inherent attributes of each action in the user's real action sequence, and compare whether the inherent attributes of each action are consistent; When all the inherent attributes of the actions are the same, the actions with the same inherent attributes are identified as duplicate actions and deleted. When any inherent attribute is inconsistent, actions with inconsistent inherent attributes are identified as different actions and retained in the target action sequence.

[0015] Furthermore, the configuration module is specifically used for: Iterate through each state variable in the first action state set, and obtain the state setting fragment corresponding to each state variable according to the mapping relationship; Based on the state values ​​corresponding to each state variable as input parameters, configure the corresponding state setting fragments; The environment initialization script is obtained by combining and configuring each state setting fragment according to the order of each state variable in the first action state set.

[0016] Furthermore, the matching module is specifically used for: According to the action sequence of the target action sequence, read the inherent attributes of each action in turn; Based on the inherent attributes of each action, script fragments with the same inherent attributes are retrieved from the script fragment library to obtain candidate script fragments for the corresponding actions.

[0017] Furthermore, the matching module includes: The first matching submodule is used to obtain the dependency status of each candidate script fragment; The second matching submodule is used to compare the set of states corresponding to the action with the dependency states corresponding to each candidate script fragment. The third matching submodule is used to count the number of states in each candidate script fragment that are consistent with the state set; The fourth matching submodule is used to sort the scripts in descending order of the number of consistent states, and to determine the first candidate script fragment in the sorting results as the target script fragment.

[0018] Furthermore, the second matching submodule is specifically used for: When the dependent state is an enumerated value state, determine whether the state variable and the state value are consistent. When the dependent state is a range value state, determine whether the state values ​​in the state set are within the value range corresponding to the dependent state; If any dependent state is mutually exclusive with the corresponding state in the state set, then the corresponding candidate script fragment is removed.

[0019] Furthermore, the generation module is specifically used for: Set the environment initialization script as a pre-script part; Import each target script fragment in the order of the target action sequence, call each target script fragment in sequence, and pass in the action parameters and status parameters of the corresponding action; The environment initialization script and the target script fragments are combined to generate the automated test script.

[0020] This disclosure also provides a computer device, including a memory and a processor, wherein the memory stores computer-readable instructions, and the processor executes the computer-readable instructions to implement the steps of the automated test script generation method described above.

[0021] This disclosure also provides a computer-readable storage medium storing computer-readable instructions, which, when executed by a processor, implement the steps of the automated test script generation method described above.

[0022] The technical solution provided in this disclosure has the following advantages compared with the prior art: By acquiring the user's actual action sequence and deduplicating actions based on their inherent attributes, a target action sequence is obtained. The state set of the target action sequence is acquired, and a mapping relationship is established between each state variable in the state set and a pre-configured state setting fragment. The target action sequence, state set, and mapping relationship are stored in a database. The first action state set of the target action sequence is retrieved from the database. Each state variable in the first action state set is traversed, and a corresponding state setting fragment is configured for each state variable according to the mapping relationship. The configured state setting fragments are combined to obtain the environment initialization script. Following the action order of the target action sequence, candidate script fragments are searched based on the inherent attributes of each action. The state set corresponding to each action is matched with each candidate script fragment to obtain the target script fragment. The environment initialization script and the target script fragment are concatenated according to the target action sequence to generate an automated test script. This achieves the automatic generation of automated test scripts that accurately reflect the user's operation flow based on real user behavior data. Attached Figure Description

[0023] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.

[0024] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0025] Figure 1 A schematic diagram of the automated test script generation method provided in this embodiment of the disclosure; Figure 2 This is a flowchart illustrating the data storage and script splicing collaboration process provided in the embodiments of this disclosure. Figure 3 This is a schematic diagram of an automated test script generation system provided in an embodiment of this disclosure. Detailed Implementation

[0026] To better understand the above-mentioned objectives, features, and advantages of this disclosure, the solutions disclosed herein will be further described below. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other.

[0027] Numerous specific details are set forth in the following description in order to provide a full understanding of this disclosure, but this disclosure may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only some, and not all, of the embodiments of this disclosure.

[0028] Figure 1 This is a schematic diagram of the automated test script generation method provided in the embodiments of this disclosure; as shown Figure 1 As shown, an automated test script generation method includes: S1, obtain the user's actual action sequence, and perform action deduplication on the user's actual action sequence according to the inherent attributes of each action to obtain the target action sequence; In this embodiment, the user's actual action sequence refers to a series of continuous operation records generated by the user during actual use of the software system (such as in-vehicle systems, mobile terminal applications, smart device applications, etc.). The action sequence usually comes from system event logs, behavior collection platforms, or operation event recording systems. Each action is recorded in chronological order and can truly reflect the user's operation trajectory when completing a certain business process. Each action not only includes the time information of the operation, but also inherent attributes that can uniquely identify the business characteristics of the action. Inherent attributes refer to attribute information that does not change with the operating environment and can uniquely describe the business meaning of the action itself, such as application source (app_source), front page (front_page), source (source), action type (action_type), wake-up location (wake_up_location), screen ID (screen_id), operation target (operate_target), input content (input), voice recognition content (voice_dc), and task management action information (taskmaster_actionInfo), etc. Among them, the application source indicates the application module to which the action belongs, the front-end page indicates the interface where the action occurs, the action type indicates the specific operation type such as click, swipe, input, voice wake-up, etc., the operation target indicates the control object on which the action is applied, and the input content or voice recognition content indicates the data content input by the user.

[0029] Subsequently, deduplication is performed based on the inherent attributes of each action. Since the deduplication process relies solely on the inherent attributes of the action itself, without considering the state information at the time of the action, data redundancy caused by the same action appearing repeatedly in different environmental states can be avoided. After this processing, the target action sequence is obtained. Each action in the target action sequence is unique and can serve as the basis for subsequent script searching and script generation. This effectively reduces redundant data caused by duplicate actions, improves the efficiency of subsequent script fragment searches, and reduces the number of database retrievals. Furthermore, it allows business personnel to maintain only the corresponding test script fragments for unique actions, eliminating the need to repeatedly develop scripts with the same functionality for duplicate actions, thereby reducing script maintenance costs.

[0030] Specifically, S1, based on the inherent attributes of each action, the user's real action sequence is deduplicated to obtain the target action sequence, including: extracting the inherent attributes of each action in the user's real action sequence and comparing whether the inherent attributes of each action are consistent; when the inherent attributes of each action are consistent, actions with consistent inherent attributes are identified as duplicate actions and deleted; when any inherent attribute is inconsistent, actions with inconsistent inherent attributes are identified as different actions and retained in the target action sequence.

[0031] Specifically, for two actions, their inherent attributes are compared. If all inherent attributes are identical, the two actions are considered to be the same action in terms of business semantics. Even if they occur at different times or correspond to different operating states, it will not change the business behavior itself. Therefore, the two actions are identified as duplicate actions, and only one record is retained, while the remaining duplicate records are deleted. If any inherent attribute is different, it means that the two actions belong to different business operations and should be retained in the target action sequence respectively. For example, both are clicking the air conditioner switch button. If the application source, front-end page, action type, and operation target are completely identical, they can be identified as duplicate actions. However, if one action occurs on the air conditioner control page and the other occurs on the quick control page, they should be identified as different actions due to the different front-end pages and will not be deduplicated. Action deduplication is judged only based on the inherent attributes of the action itself, and not on the state information corresponding to the action when it occurs. That is, even if the same action corresponds to different vehicle gears, network states, or air conditioner temperatures, it is still considered the same action, which can ensure the uniqueness of the action object. Different operating states will be processed as environmental constraints in the subsequent script matching stage.

[0032] Each action in the target action sequence corresponds to a unique business behavior, eliminating data redundancy caused by repeated collection, reporting, or user operations. Action deduplication significantly reduces the number of duplicate action records in the database, improves the efficiency of subsequent script fragment searches, and reduces the number of database retrievals and computational resource consumption. On the other hand, since each business action only needs to maintain one set of corresponding script fragments, business developers do not need to repeatedly develop and maintain test scripts with the same functionality for a large number of repetitive actions, thereby reducing the development and maintenance costs of automated test scripts.

[0033] S2, obtain the state set of the target action sequence, establish the mapping relationship between each state variable in the state set and the pre-configured state setting fragment, and store the target action sequence, state set and mapping relationship in the database; In this embodiment, the state set refers to the set of state information of the system's operating environment when the action is executed. It describes the actual state of various environmental parameters when the action occurs, such as vehicle gear position, vehicle speed, air conditioning on / off status, air conditioning temperature, navigation status, network connection status, Bluetooth connection status, multimedia playback status, system language, user login status, etc. Each state consists of a state variable and a state value. The state variable represents a certain environmental attribute, such as gear position, air conditioning on / off status, temperature, etc.; the state value represents the actual value corresponding to the state variable, such as P gear, on, 24 degrees Celsius, etc.

[0034] Subsequently, a mapping relationship is established between each state variable in the state set and a pre-configured state setting fragment. State setting fragments are standardized script modules pre-developed by business personnel. Each script module is responsible for setting the environment for the corresponding state variable. For example, the gear setting script adjusts the vehicle's gear to a specified gear, and the air conditioning setting script turns the air conditioning on or off and sets the corresponding temperature. The mapping relationship establishes a one-to-one correspondence between state variables and their corresponding state setting fragments, enabling the system to quickly locate the appropriate setting script based on the state variable.

[0035] The target action sequence, state set, and mapping relationship are uniformly stored in a database, preferably a relational database, to support rapid subsequent queries based on action, state, or mapping relationship. By establishing a unified data organization structure, not only can data association between action information, environment state information, and state setting fragments be achieved, but business personnel can also avoid repeatedly maintaining state configuration rules in different testing scenarios, improving the consistency of state configuration. Furthermore, since state variables and state setting fragments are managed using a unified mapping method, when adding state variables or modifying environment setting logic, only the mapping relationship needs to be adjusted to complete the expansion, without modifying the entire script generation process.

[0036] S3, obtain the first action state set of the target action sequence in the database, traverse each state variable in the first action state set, configure the corresponding state setting fragment for each state variable in the first action state set according to the mapping relationship, combine the configured state setting fragments to obtain the environment initialization script; In this embodiment, before generating the automated test script, it is necessary to first restore the runtime environment corresponding to when the user executes the actual action sequence. Therefore, the state set corresponding to the first action of the target action sequence is read from the database. The reason for choosing the state set corresponding to the first action is that this state set can completely reflect the software runtime environment before the user starts executing the entire action sequence, and can serve as the initial environment for the execution of subsequent actions.

[0037] Then, iterate through each state variable in the first action state set and find the corresponding state setting fragment according to the mapping relationship. For example, when the state variable is vehicle gear, retrieve the gear setting script according to the mapping relationship; when the state variable is air conditioning temperature, retrieve the temperature setting script according to the mapping relationship.

[0038] The state value corresponding to the state variable is used as a parameter to apply to the corresponding state setting fragment, enabling the state setting fragment to generate the corresponding state setting operation. For example, the gear setting script generates an initialization operation to set the gear to P based on the state value P, and the air conditioning setting script generates an initialization operation to set the air conditioning temperature to 24 degrees Celsius based on the state value 24.

[0039] All state setting fragments are combined in a uniform order to form a complete environment initialization script. This script, located before the automated test script, automatically restores the software's runtime environment to match real user operations before testing begins, ensuring subsequent test actions are executed under conditions consistent with real user conditions. By constructing an environment initialization script, deviations in test results due to inconsistencies between the test and real environments can be avoided. It also eliminates the need for testers to manually configure numerous environment parameters, thus improving the efficiency of automated test execution.

[0040] Specifically, S3 configures the corresponding state setting fragments for each state variable in the first action state set according to the mapping relationship, and combines the configured state setting fragments to obtain the environment initialization script, including: traversing each state variable in the first action state set and obtaining the state setting fragments corresponding to each state variable according to the mapping relationship; configuring the corresponding state setting fragments based on the state values ​​corresponding to each state variable as input parameters; and combining the configured state setting fragments according to the order of each state variable in the first action state set to obtain the environment initialization script.

[0041] Specifically, after establishing and storing the target action sequence, state set, and mapping relationship in the database, the system first reads the state set corresponding to the first action in the target action sequence. Then, it iterates through each state variable in the first action's state set and retrieves the corresponding state setting fragment based on the mapping relationship. Since a mapping relationship has been established between state variables and state setting fragments, the system does not require manual searching of the corresponding script; it can automatically locate the corresponding state setting fragment based solely on the currently iterated state variable, thus improving the automation level of the environment recovery process.

[0042] After obtaining the corresponding state setting fragment, the fragment is further configured based on the state values ​​corresponding to each state variable. The state values ​​of the state variables are passed as input parameters to the corresponding state setting fragments, enabling them to generate environment restoration operations consistent with the actual operating environment. For example, when the state variable is the vehicle gear position and the state value is P (Park), the gear position setting fragment receives the state value P as an input parameter and generates an operation to set the vehicle gear to P; when the state variable is the air conditioning temperature and the state value is 24 degrees Celsius, the temperature setting fragment receives the value 24 as an input parameter and generates an operation to set the air conditioning temperature to 24 degrees Celsius. The same state setting fragment can restore different environmental states using different state values.

[0043] After configuring all state variable state setting fragments, the configured state setting fragments are sequentially combined according to the order of each state variable in the first action state set to form the environment initialization script. This script can automatically generate the environment initialization script based on the state information at the start of a user's actual action, allowing the test environment to be restored to the real user operation environment without manual configuration. The decoupling design of state variables and state setting fragments means that adding a new state variable only requires adding the corresponding state setting fragment and updating the mapping relationship, without modifying the overall script generation logic, resulting in good scalability and maintainability. Furthermore, the environment initialization script is automatically generated by combining multiple standardized state setting fragments, fully reusing existing test resources, improving script generation efficiency, and reducing the development and maintenance costs of the automated testing platform.

[0044] S4. According to the action order of the target action sequence, search for candidate script fragments based on the inherent attributes of each action, and match the state set corresponding to each action with each candidate script fragment to obtain the target script fragment; In this embodiment, test script fragments corresponding to each action are searched sequentially according to the target action sequence. Script fragments are standardized test functions pre-written by business personnel, and each script fragment is responsible for automating the test operation of a specific business action.

[0045] Based on the inherent attributes corresponding to each action in the target action sequence, candidate script fragments with the same inherent attributes are retrieved from the script fragment library. Since action deduplication has been performed, each action can correspond to at least one candidate script fragment. Subsequently, to further improve script matching accuracy, the state set corresponding to each action is matched with the dependency states associated with each candidate script fragment. Dependency states refer to the environmental state conditions required for the script fragment to execute correctly, such as requiring the vehicle to be in P gear, navigation to be turned on, or a normal network connection.

[0046] During the matching process, for enumerated states, it's necessary to determine if the state variables and values ​​are completely identical; for continuous range states, it's determined if the state value falls within the state range required by the script fragment. Simultaneously, if a candidate script fragment contains states that conflict with or are mutually exclusive with the current state set, that candidate script fragment is directly excluded. Candidate script fragments are sorted based on the number of successfully matched states, and the script fragment with the highest matching degree is selected as the target script fragment. By combining action attribute matching and state matching, not only can the correct business action be guaranteed for the script fragment, but the script fragment can also be guaranteed to be applicable to the real environment in which the current action is executed, thereby significantly improving script matching accuracy and reducing erroneous script calls.

[0047] Specifically, S4, according to the action order of the target action sequence, search for candidate script fragments based on the inherent attributes of each action, including: reading the inherent attributes of each action in sequence according to the action order of the target action sequence; and searching for script fragments with the same inherent attributes in the script fragment library based on the inherent attributes of each action to obtain candidate script fragments for the corresponding actions.

[0048] Specifically, after generating the environment initialization script, the test script fragments corresponding to each action are determined sequentially based on the target action sequence. The target action sequence is a unique set of actions after deduplication, preserving not only the actual order of user operations but also eliminating redundant data from repeated actions. The inherent attributes of each action are read one by one according to the action order in the target action sequence. The action order refers to the temporal sequence in which the user executes each action during actual use. Executing the script in this order maximizes the replication of the real user's workflow and avoids distortion of test results due to changes in the action execution order.

[0049] Subsequently, based on the inherent attributes of each action, script fragments with the same inherent attributes are retrieved from the script fragment library. The script fragment library is a pre-established script resource library used to centrally store various automated test script fragments developed by business personnel. Each script fragment typically corresponds to a specific business action, such as clicking a button, opening a page, entering text, or executing a voice command. It can be organized using functions, methods, or independent script modules, and its inherent attribute information is saved for subsequent retrieval. During the retrieval process, the inherent attributes corresponding to the current action are used as search criteria and compared with the script attributes stored in the script fragment library. When the inherent attributes of a script fragment match those of the current action, the script fragment is considered capable of completing the business operation corresponding to the current action and is selected as a candidate script fragment for that action. For example, when the application source, front-end page, action type, and operation target of the current action all correspond to "clicking the air conditioner switch button on the air conditioner control page", the system will search for all script fragments with the same attribute identifier and use the search results as candidate script fragments. If the current action is voice wake-up navigation, the system will search for script fragments corresponding to the voice navigation service and will not match similar operations in other pages or other business modules, thereby ensuring that the candidate script fragments are consistent with the actual business actions.

[0050] Candidate script fragments are not necessarily unique. Because the same business action may have different implementations in different runtime states—for example, the same click action might correspond to multiple test scripts for a stationary vehicle, a moving vehicle, a connected network, or a disconnected network—the script fragment library may contain multiple script fragments with consistent inherent attributes but different applicable environments. The first stage of filtering is performed solely based on inherent attributes, quickly narrowing the search scope from the script fragment library and excluding all script fragments irrelevant to the current action's business semantics, retaining only candidate script fragments with consistent business actions. Inherent attribute matching primarily addresses the issue of action consistency.

[0051] The automatic retrieval of candidate script fragments is achieved by leveraging the inherent attributes of each action in the target action sequence. This eliminates the need for manual searching of corresponding scripts one by one based on business logic, significantly improving script retrieval efficiency. Furthermore, since each business action retains only a unique record after deduplication, it avoids wasting computational resources caused by repeated searches. Simultaneously, using inherent attributes as the first-stage retrieval criteria ensures that candidate script fragments maintain semantic consistency with actual user actions in terms of business logic.

[0052] In some possible implementations, S4 involves matching the state set corresponding to each action with each candidate script fragment to obtain the target script fragment, including: obtaining the dependency states corresponding to each candidate script fragment; comparing the state set corresponding to the action with the dependency states corresponding to each candidate script fragment; counting the number of states in each candidate script fragment that match the state set; sorting the candidate script fragments from largest to smallest according to the number of matching states, and determining the first candidate script fragment in the sorting result as the target script fragment.

[0053] In this embodiment, candidate script fragments are retrieved based on the inherent attributes of each action. However, since the same business action may correspond to multiple script fragments in different operating environments, it is not possible to accurately determine the most suitable script fragment for the current action execution environment by relying solely on inherent attributes. Therefore, a second-stage screening of candidate script fragments is performed by further combining the set of states corresponding to the action execution.

[0054] Obtain the dependency state corresponding to each candidate script fragment. The dependency state can contain one or more state variables, each of which corresponds to a preset state value or state range. By describing the applicable runtime environment of the script fragment, the correspondence between the script fragment and different test scenarios is realized.

[0055] The current action's state set is compared with the dependency states of each candidate script fragment. By comparing each state variable item by item, the consistency between the current action's runtime environment and the candidate script fragment's applicable environment can be accurately reflected, thus avoiding the problem of inconsistent script execution environments caused by relying solely on action type matching.

[0056] After comparing all state variables, the number of states in each candidate script fragment that match the current state set is counted. The number of matching states refers to the number of state variables in the candidate script fragment's dependent states that satisfy the consistency condition after comparison with the current action state set, reflecting the degree of matching between the candidate script fragment and the current runtime environment. For example, if a candidate script fragment depends on three state variables, and all three are consistent with the current state set, then the number of matching states is three; if another candidate script fragment depends on four state variables, and only two are consistent with the current state set, then the number of matching states is two. Since a higher number of matching states indicates a better fit between the candidate script fragment and the current action execution environment, the number of matching states can be used as a matching evaluation metric for candidate script fragments. Subsequently, all candidate script fragments are sorted from highest to lowest number of matching states, placing the candidate script fragment with the highest environment matching degree at the top. Finally, the first candidate script fragment in the sorting result is determined as the target script fragment corresponding to the current action, and this target script fragment is used for subsequent automated test script assembly.

[0057] A secondary script fragment selection mechanism based on state sets was constructed, ensuring that script fragment selection depends not only on the business attributes of the action itself but also on the actual runtime environment during action execution. Compared to matching solely based on action attributes, this effectively distinguishes different test implementations of the same business action under different system states, preventing incorrect scripts from being invoked due to runtime environment differences. Furthermore, using the number of consistent states as the sorting criterion eliminates the need for manually specifying priority rules; instead, it automatically selects the optimal script fragment based on the degree of matching between the real environment and the script's dependent environment, enhancing intelligent matching capabilities. As the script fragment library expands and more test scripts suitable for different state environments are added, the same matching and sorting mechanism can automatically complete the selection of target script fragments without modifying the existing script generation process, demonstrating excellent scalability and compatibility. This two-stage search strategy combining action attribute matching and state matching not only improves script reusability and reduces redundant development but also makes the final generated automated test scripts more closely resemble the real user's operating environment.

[0058] Specifically, the process involves comparing the set of states corresponding to an action with the dependent states corresponding to each candidate script fragment. This includes: when the dependent state is an enumerated value state, determining whether the state variable and the state value are consistent; when the dependent state is a range value state, determining whether the state value in the set is within the range of the value corresponding to the dependent state; and if any dependent state is mutually exclusive with the corresponding state in the set, then the corresponding candidate script fragment is eliminated.

[0059] Specifically, when the dependent state is an enumerated value state, it is determined whether both the state variable and its value are consistent. An enumerated value state refers to a state variable that can only be selected from a finite number of preset states. Its state value usually has a clear business meaning; for example, a vehicle's gear position can be P, R, N, or D; Bluetooth connection status can be connected or not connected; navigation status can be on or off; media playback status can be play, paused, or stopped, etc. For such states, only when the state variable names and values ​​are identical can the current action state set be considered to have successfully matched the candidate script fragment's dependent state. For example, if a candidate script fragment requires the vehicle to be in P gear, and the current action state set also has P gear, then the state is considered to have matched successfully; if the current vehicle is in D gear, it means the current operating environment does not meet the execution conditions of the script fragment, and the state should be considered to have failed to match. By using a completely consistent comparison method, incorrect scripts can be avoided due to clear business differences between different enumerated states, improving the accuracy of state matching.

[0060] When the dependent state is a range-valued state, it is determined whether the state values ​​in the state set fall within the range corresponding to the dependent state. A range-valued state refers to a state variable whose corresponding state value is a continuous numerical value or data that can be divided into numerical intervals, such as air conditioning set temperature, vehicle speed, battery state of charge, volume level, and ambient brightness. For such states, candidate script fragments are usually not limited to a fixed value, but rather specify a range of values ​​that are allowed to be executed. For example, a script fragment might be suitable for execution when the vehicle speed is between 0 and 5 km / h, or suitable for execution when the air conditioning temperature is between 22°C and 26°C. When the state value in the current action state set falls within the range required by the candidate script fragment, the state is considered to have matched successfully; if the state value exceeds the corresponding range, the state is considered to have failed to match. Compared to fixed-value comparison methods, the range-based judgment method can better adapt to the characteristics of continuous state variables, improve the flexibility of state matching, and avoid the problem of scripts failing to match due to small numerical differences.

[0061] To prevent candidate script fragments that clearly do not meet execution conditions from continuing to participate in the sorting process, a mutual exclusion state determination mechanism is implemented. A mutual exclusion state refers to two states that cannot simultaneously be true in business logic. For example, a candidate script fragment requires the vehicle to be stationary, while the current action state set shows the vehicle in motion; or a candidate script fragment requires Bluetooth to be disconnected, while the current state set shows Bluetooth is connected. These situations are both mutual exclusion states. For candidate script fragments with mutual exclusion states, even if all other state variables meet the requirements, there is no guarantee that the script will execute correctly. Therefore, they do not need to continue participating in the subsequent consistent state count and sorting process and are directly deleted from the candidate script fragment set. This reduces the amount of data for subsequent sorting, improves the efficiency of target script fragment selection, and effectively prevents scripts with clearly inconsistent environmental conditions from being mistakenly selected.

[0062] Three comparison strategies—enumerated value matching, range value judgment, and mutually exclusive state elimination—are employed for different types of state variables, ensuring that the state matching process takes into account the characteristics of different data types. This allows the system to adapt to a large number of different types of state variables in complex application scenarios such as in-vehicle systems, mobile terminals, and smart devices, and it can accurately filter candidate script fragments that match the current operating environment.

[0063] S5 concatenates the environment initialization script and the target script fragment according to the target action sequence to generate an automated test script.

[0064] In this embodiment, the environment initialization script is executed as a pre-execution part of the entire automated test script, so that the software running environment when the real user operates is restored before the automated test begins.

[0065] Subsequently, following the order of actions in the target action sequence, each target script fragment is imported into the automated test script, ensuring that the execution order of each script fragment matches the actual user operation order. For script fragments requiring input parameters, the corresponding input parameters and status parameters can be synchronously passed to the relevant script functions, enabling the script to automate execution based on real business data. The final generated automated test script typically includes a script import section, an environment initialization section, and an action execution section. The script import section loads each test script module, the environment initialization section restores the test environment, and the action execution section completes various test operations according to the order of real user behavior. Since the entire script is automatically generated by piecing together standardized script fragments, there is no need to manually rewrite the complete test script, significantly reducing test development costs. Simultaneously, the generated script can highly replicate the real user operation process and runtime environment, improving test scenario coverage and problem reproducibility, making automated testing closer to real user scenarios, and further improving software testing efficiency and quality.

[0066] Specifically, S5 concatenates the environment initialization script and target script fragments according to the target action sequence to generate an automated test script, including: setting the environment initialization script as the pre-script part; importing each target script fragment in the order of the target action sequence, calling each target script fragment in sequence, and passing in the corresponding action parameters and status parameters; and combining the environment initialization script and each target script fragment to generate an automated test script.

[0067] Specifically, the target script fragments are imported sequentially according to the order of actions in the target action sequence. Importing refers to loading the script file or function module containing the corresponding script fragment into the current automated test script, making it callable. Maintaining an import and execution order consistent with the target action sequence ensures that the automated testing process mirrors the real user's workflow, preventing changes in the action execution order from affecting the test results.

[0068] After importing the target script fragments, each target script fragment is called sequentially according to the target action sequence, passing in the corresponding action parameters and status parameters. Since the environment initialization script has already restored the test environment, each target script fragment does not need to perform environment configuration operations again; only the automated execution of the corresponding business actions needs to be focused on.

[0069] Automated test scripts typically include a script import section, an environment initialization section, and an action execution section. The generated automated test script can be directly deployed to the automated testing framework for execution, eliminating the need for testers to manually arrange or rewrite the scripts for each test step. By unifying environment restoration, action execution, and script organization into the automated generation process, one-click test script construction based on real user action sequences is achieved. This not only reduces the workload of manually writing and maintaining test scripts and improves script development efficiency, but also ensures that the test process is consistent with real user behavior, improving the ability to reproduce test scenarios and reproduce problems.

[0070] Figure 2 This is a flowchart illustrating the data storage and script splicing collaboration process provided in the embodiments of this disclosure; such as... Figure 2 As shown, in some possible implementations, the overall architecture is divided into two main parts: a data storage module and a script assembly module. The two modules interact through a standardized data interface. Data storage module: Responsible for receiving user action sequence data from upstream, cleaning, deduplicating, and structuring the data, and storing the processed data in a relational database to provide a data foundation for subsequent script assembly; The script splicing module is responsible for initializing the test environment, searching and matching script fragments, handling special rules, and finally splicing and generating the script based on the data provided by the storage module.

[0071] The collaboration process between the two modules is as follows: The data storage module first receives the user's action sequence, performs action deduplication and state enumeration processing, and then stores it in the database; The script splicing module reads the processed action sequence and its status information from the database; Initialize the environment based on the complete state set of the first action; Search for matching script fragments one by one according to the sequence of actions; After handling special rules, all fragments are assembled in sequence into a complete executable test script.

[0072] The data storage module transforms raw user action sequence data into a structured, queryable, and directly usable standard data format for script concatenation. This module comprises the following three processing stages: Action deduplication: When the framework receives a sequence of user actions from the upstream, it performs action deduplication according to the business requirements to eliminate duplicate actions caused by data collection redundancy.

[0073] Deduplication logic: A deduplication strategy based on the inherent attributes of the action is adopted, and the specific rules are as follows: The state at the moment of the action is not considered; only the inherent properties of the action itself are considered. The inherent attributes of an action are defined by multiple fields, including but not limited to: app_source (application source), front_page (front-end page), source (source), action_type (action type), wake_up_location (wake-up location), screen_id (screen identifier), operate_target (operation target), input (input content), voice_dc (voice recognition content), taskmaster_actionInfo (task master action information), etc. If any column in the above fields is different, it is considered a different action; if all columns are the same, it is considered a duplicate action and deduplication is performed. After deduplication, each action uniquely corresponds to one or more script fragments, avoiding duplicate searches; business users can pre-fill fragments for high-frequency states without having to repeatedly write fragments for duplicate actions; ensuring that each record in the actual tracking sequence table represents a unique user action. The deduplicated actions are written into the actual tracking sequence table for unified management, and each record contains all the inherent attribute fields of the action.

[0074] Enumerating state combinations solves the problems of tedious table lookups and inconsistent descriptions when business users bind states. Business systems often contain a large number (e.g., over 200) of embedded states. When binding corresponding states to action script fragments, business users need to perform multiple table lookups to clarify the state variables and their corresponding meanings, which is inefficient. Furthermore, when dealing with states in multiple locations, manually writing state descriptions can easily lead to writing errors due to individual differences.

[0075] The framework automatically iterates through and describes the enumerated state variables based on the complete set of states; it then structures the following information about the state variables into the state definition table: The framework automatically generates descriptions for all valid combinations of states, including the state variable name (name), state value (value), state name description (nameDesc), and state value description (valueDesc). When binding states, business users can directly select the corresponding business description from the state definition table to correctly match the actual state, eliminating the need for manual table lookups and writing of state descriptions, thus fundamentally solving the problem of inconsistent descriptions.

[0076] Store the data in the database and manage the following key tables using the Fusion Cloud MySQL database: Real Tracking Sequence Table: Stores the deduplicated user action sequence. Each record represents a unique user action and contains complete inherent attributes of the action. It supports fast retrieval and querying by action attributes.

[0077] State Definition Table: Stores traversal description information for enumerated state variables, provides standardized state descriptions for business users to select and use, and supports multi-dimensional queries of state variable names, values, and descriptions.

[0078] State setting table: Stores the mapping relationship between the setting fragments of the corresponding state variables. For example, the state variable of vehicle gear position corresponds to the setting fragment gear_position_switch. Calling this setting fragment and passing in the state truth value in the real sequence (such as P gear) can complete the setting of the corresponding state, realizing the automatic mapping from state variables to setting scripts.

[0079] The script assembly module is the core execution module, responsible for transforming user action sequence data from the storage module into executable automated test scripts. The execution flow includes the following four key steps: State setup (environment initialization) restores the user's real environment before executing the test script, ensuring the correctness and effectiveness of the test. When users actually use the vehicle's infotainment system, their operations are performed under specific vehicle and system states. The test environment must restore these pre-existing states to effectively verify the test scenarios.

[0080] The implementation involves obtaining the complete state set of the first action in the user's action sequence (i.e., a complete snapshot of the user's state before executing the sequence); querying the state setting table to obtain the setting fragment corresponding to each state variable; sequentially calling the setting fragments of each state variable and passing in the actual value of the state in the real sequence; after completing the setting of all state variables, the test environment is restored to the real state before the user executes the operation sequence.

[0081] Example: If the first action in the user action sequence is performed in P gear, with the air conditioner on and the temperature at 24 degrees Celsius, the framework first calls the gear setting fragment to set it to P gear, then calls the air conditioner setting fragment to turn on the air conditioner and set the temperature to 24 degrees Celsius. After completing the environment initialization, the test fragments for subsequent actions are executed.

[0082] Searching for script fragments is the core step in script assembly. A two-stage search strategy is employed to precisely locate the most matching script fragment from the fragment library: Phase 1: Search by inherent attributes of the action. Perform a full match search based on the inherent attributes of the action in the actual tracking sequence table (multiple columns such as app_source (application source), front_page (front-end page), source (trigger source), action_type (action type), etc.). Search the fragment library for candidate script fragments that fully match the inherent attributes of the current action. Thanks to the action deduplication mechanism, each action has at least one corresponding script fragment in the fragment library.

[0083] The second stage: perform precise matching based on fragment dependency states. Input: a set of specific states corresponding to each action in the real action sequence, including information such as name (state name), value (state value), nameDesc (name description), and valueDesc (value description).

[0084] The matching and sorting rules rank the candidate fragments obtained in the first stage according to the degree of matching between the states they depend on and the set of real states. The degree of matching is defined as follows: the candidate fragment with the most states that are consistent with the real state is selected first; that is, the more states that a candidate fragment depends on that are consistent with the set of real states, the higher the ranking of the fragment.

[0085] Matching rules details: Enumerated value states must be completely consistent, that is, the state variable name and value must match exactly; range value states are determined by the framework's range judgment capability to determine whether the real state value falls within the range of states that the fragment depends on; a veto mechanism is in place, if any of the dependent states of a candidate fragment are mutually exclusive with any state in the real state set, then the candidate fragment is directly excluded and will not participate in the subsequent sorting.

[0086] By employing a two-stage search strategy, we ensure that the final selected script fragment matches both the action itself and the actual state environment during the action's execution, thereby achieving accurate fragment location.

[0087] Special rule handling: For specific historical business needs, the framework provides special processing capabilities such as parameter concatenation to ensure compatibility with historical business data. Example scenario: In the early voice_info data structure, the query field and the voice_dc field needed to be concatenated into voice_info as the input parameter for voice services; the framework supports configuring special rules to automatically perform parameter conversion and concatenation operations when concatenating segments; in the future, script writing will directly read the data of the column corresponding to the action, and the framework will only be responsible for passing parameters, with special rules reserved for compatibility.

[0088] Fragment splicing: The script fragment specification specifies that the script fragments written by the business side are based on the specified automated testing framework (such as liat); the fragments are stored in the specified working library (such as Automation-TestNew); and are provided to the framework in the form of xx::func, where xx represents the py file containing the script fragment, and func represents the corresponding fragment function.

[0089] The assembly process involves the framework importing the searched script fragment functions in the order of the user's action sequence; calling each fragment function sequentially according to the action sequence; passing in the corresponding parameters (including inherent action attribute parameters and state parameters) during the call; and finally forming a complete executable test script.

[0090] The assembled script structure is as follows: The script header imports all necessary function snippets using an import statement; the environment initialization section calls the state setting snippet to restore the user's real environment; the test execution section calls the test function snippets corresponding to each action in sequence; the script can be executed directly in the automated testing framework without manual intervention.

[0091] Figure 3 This is a schematic diagram of an automated test script generation system provided in an embodiment of this disclosure; as shown below. Figure 3As shown, this disclosure also provides an automated test script generation system, including: an acquisition module 301, used to acquire a user's real action sequence and perform action deduplication on the user's real action sequence according to the inherent attributes of each action to obtain a target action sequence; a storage module 302, used to acquire a state set of the target action sequence, establish a mapping relationship between each state variable in the state set and a pre-configured state setting fragment, and store the target action sequence, state set, and mapping relationship in a database; a configuration module 303, used to acquire the first action state set of the target action sequence in the database, traverse each state variable in the first action state set, configure the corresponding state setting fragment for each state variable in the first action state set according to the mapping relationship, and combine the configured state setting fragments to obtain an environment initialization script; a matching module 304, used to search for candidate script fragments according to the action order of the target action sequence and the inherent attributes of each action, and match the state set corresponding to each action with each candidate script fragment to obtain a target script fragment; and a generation module 305, used to concatenate the environment initialization script and the target script fragment according to the target action sequence to generate an automated test script.

[0092] In some possible implementations, the acquisition module 301 is specifically used to: extract the inherent attributes of each action in the user's real action sequence and compare whether the inherent attributes of each action are consistent; when the inherent attributes of each action are consistent, the actions with consistent inherent attributes are identified as duplicate actions and deleted; when any inherent attribute is inconsistent, the actions with inconsistent inherent attributes are identified as different actions and retained in the target action sequence.

[0093] In some possible implementations, the configuration module 303 is specifically used to: traverse each state variable in the first action state set and obtain the state setting fragment corresponding to each state variable according to the mapping relationship; configure the corresponding state setting fragment based on the state value corresponding to each state variable as an input parameter; and combine the configured state setting fragments according to the order of each state variable in the first action state set to obtain the environment initialization script.

[0094] In some possible implementations, the matching module 304 is specifically used to: read the inherent attributes of each action in sequence according to the action order of the target action sequence; and search for script fragments with the same inherent attributes in the script fragment library based on the inherent attributes of each action to obtain candidate script fragments for the corresponding actions.

[0095] In some possible implementations, the matching module 304 is specifically used for: a first matching submodule, used to obtain the dependency states corresponding to each candidate script fragment; a second matching submodule, used to compare the state set corresponding to the action with the dependency states corresponding to each candidate script fragment; a third matching submodule, used to count the number of states in each candidate script fragment that are consistent with the state set; and a fourth matching submodule, used to sort the candidate script fragments from largest to smallest according to the number of consistent states, and determine the first candidate script fragment in the sorting result as the target script fragment.

[0096] In some possible implementations, the second matching submodule (not shown in the figure) is specifically used to: determine whether the state variable and the state value are consistent when the dependent state is an enumerated value state; determine whether the state value in the state set is within the value range corresponding to the dependent state when the dependent state is a range value state; and remove the corresponding candidate script fragment if any dependent state is mutually exclusive with the corresponding state in the state set.

[0097] In some possible implementations, the generation module 305 is specifically used to: set the environment initialization script as a pre-script part; import each target script fragment in sequence according to the action order of the target action sequence, call each target script fragment in sequence, and pass in the action parameters and status parameters of the corresponding actions; combine the environment initialization script and each target script fragment to generate an automated test script.

[0098] This disclosure also provides a computer device, including a memory and a processor, wherein the memory stores computer-readable instructions, and the processor executes the computer-readable instructions to implement the steps of an automated test script generation method.

[0099] The computer device includes a memory, a processor, and a network interface that are interconnected via a system bus. It should be noted that not all of the shown components are required; more or fewer components may be implemented instead. Those skilled in the art will understand that the computer device described herein is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.

[0100] The computer device can be a desktop computer, laptop, handheld computer, or cloud server, etc. The computer device can interact with the user via a keyboard, mouse, remote control, touchpad, or voice control.

[0101] The memory includes at least one type of readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory may be an internal storage unit of the computer device, such as the hard disk or memory of the computer device. In other embodiments, the memory may also be an external storage device of the computer device, such as a plug-in hard disk, smart media card (SMC), secure digital card (SD), flash card, etc. Of course, the memory may include both internal storage units and external storage devices of the computer device. In this embodiment, the memory is typically used to store the operating system and various application software installed on the computer device, such as program code for real-time data processing methods. Furthermore, the memory can also be used to temporarily store various types of data that have been output or will be output.

[0102] In some embodiments, the processor may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip. The processor is typically used to control the overall operation of the computer device. In this embodiment, the processor is used to run program code stored in the memory or process data, for example, to run the program code of the method.

[0103] The network interface may include a wireless network interface or a wired network interface, which is typically used to establish communication connections between the computer device and other electronic devices.

[0104] This disclosure also provides a computer-readable storage medium storing computer-readable instructions, which, when executed by a processor, implement the steps of an automated test script generation method.

[0105] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0106] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0107] The above description is merely a specific embodiment of this disclosure, enabling those skilled in the art to understand or implement it. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this disclosure. Therefore, this disclosure is not to be limited to the embodiments described herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for generating automated test scripts, characterized in that, include: Obtain the user's actual action sequence, and perform action deduplication on the user's actual action sequence according to the inherent attributes of each action to obtain the target action sequence; Obtain the state set of the target action sequence, establish a mapping relationship between each state variable in the state set and a pre-configured state setting segment, and store the target action sequence, the state set, and the mapping relationship in a database; Obtain the first action state set of the target action sequence in the database, traverse each state variable in the first action state set, configure corresponding state setting fragments for each state variable in the first action state set according to the mapping relationship, combine the configured state setting fragments to obtain the environment initialization script; According to the action order of the target action sequence, candidate script fragments are searched based on the inherent attributes of each action, and the state set corresponding to each action is matched with each candidate script fragment to obtain the target script fragment; The environment initialization script and the target script fragment are concatenated according to the target action sequence to generate an automated test script.

2. The automated test script generation method according to claim 1, characterized in that, The step of deduplicating the user's actual action sequence based on the inherent attributes of each action to obtain the target action sequence includes: Extract the inherent attributes of each action in the user's real action sequence, and compare whether the inherent attributes of each action are consistent; When all the inherent attributes of the actions are the same, the actions with the same inherent attributes are identified as duplicate actions and deleted. When any inherent attribute is inconsistent, actions with inconsistent inherent attributes are identified as different actions and retained in the target action sequence.

3. The automated test script generation method according to claim 1, characterized in that, The step involves configuring corresponding state setting fragments for each state variable in the first action state set according to the mapping relationship, and combining the configured state setting fragments to obtain an environment initialization script, including: Iterate through each state variable in the first action state set, and obtain the state setting fragment corresponding to each state variable according to the mapping relationship; Based on the state values ​​corresponding to each state variable as input parameters, configure the corresponding state setting fragments; The environment initialization script is obtained by combining and configuring each state setting fragment according to the order of each state variable in the first action state set.

4. The automated test script generation method according to claim 1, characterized in that, The step of searching for candidate script fragments according to the action order of the target action sequence and based on the inherent attributes of each action includes: According to the action sequence of the target action sequence, read the inherent attributes of each action in turn; Based on the inherent attributes of each action, script fragments with the same inherent attributes are retrieved from the script fragment library to obtain candidate script fragments for the corresponding actions.

5. The automated test script generation method according to claim 1, characterized in that, The step of matching the state set corresponding to each action with each candidate script fragment to obtain the target script fragment includes: Get the dependency status of each candidate script fragment; Compare the set of states corresponding to the action with the dependency states corresponding to each candidate script fragment; Count the number of states in each candidate script segment that match the state set; The script fragments are sorted from largest to smallest according to the number of consistent states, and the first candidate script fragment in the sorting result is determined as the target script fragment.

6. The automated test script generation method according to claim 5, characterized in that, The step of comparing the state set corresponding to the action with the dependency state corresponding to each candidate script fragment includes: When the dependent state is an enumerated value state, determine whether the state variable and the state value are consistent. When the dependent state is a range value state, determine whether the state values ​​in the state set are within the value range corresponding to the dependent state; If any dependent state is mutually exclusive with the corresponding state in the state set, then the corresponding candidate script fragment is removed.

7. The automated test script generation method according to claim 1, characterized in that, The step of concatenating the environment initialization script and the target script fragment according to the target action sequence to generate an automated test script includes: Set the environment initialization script as a pre-script part; Import each target script fragment in the order of the target action sequence, call each target script fragment in sequence, and pass in the action parameters and status parameters of the corresponding action; The environment initialization script and the target script fragments are combined to generate the automated test script.

8. An automated test script generation system, characterized in that, include: The acquisition module is used to acquire the user's real action sequence and perform action deduplication on the user's real action sequence according to the inherent attributes of each action to obtain the target action sequence. The storage module is used to acquire the state set of the target action sequence, establish a mapping relationship between each state variable in the state set and a pre-configured state setting segment, and store the target action sequence, the state set and the mapping relationship in the database; The configuration module is used to obtain the first action state set of the target action sequence in the database, traverse each state variable in the first action state set, configure corresponding state setting fragments for each state variable in the first action state set according to the mapping relationship, and combine the configured state setting fragments to obtain the environment initialization script. The matching module is used to search for candidate script fragments according to the action order of the target action sequence and the inherent attributes of each action, and to match the state set corresponding to each action with each candidate script fragment to obtain the target script fragment; The generation module is used to concatenate the environment initialization script and the target script fragment according to the target action sequence to generate an automated test script.

9. A computer device, characterized in that, The method includes a memory and a processor, wherein the memory stores computer-readable instructions, and the processor executes the computer-readable instructions to implement the steps of the automated test script generation method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the automated test script generation method as described in any one of claims 1 to 7.