Test script generation method and test method based on large language model

By using a test script generation method based on a large language model, recording user operations and identifying behavioral instances using a pre-trained model, the high technical threshold and fragile scripts of UI automation testing are solved, achieving automated testing with low threshold, high maintainability and high reliability.

CN121597583APending Publication Date: 2026-03-03SHANGHAI BAOSIGHT SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511816714.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-04
Publication Date
2026-03-03

AI Technical Summary

Technical Problem

Existing UI automation testing technologies have high barriers to entry, fragile scripts, and high maintenance costs. They are difficult to adapt to changes in the interface and cannot guarantee the robustness and maintainability of the tests while lowering the barrier to entry.

Method used

A test script generation method based on a large language model is adopted. By recording user operations and using a pre-trained large language model to identify and abstract high-level behavior instances, test scripts are generated. Supervision, rollback and monitoring mechanisms are introduced to ensure the reliability and stability of the test.

Benefits of technology

It greatly lowers the technical threshold for test script creation, enabling non-technical personnel to easily create automated tests. The generated scripts can adapt to interface changes, improving the maintainability and robustness of the tests, as well as enhancing their reliability and debugging efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121597583A_ABST
    Figure CN121597583A_ABST
Patent Text Reader

Abstract

The invention provides a test script generation method and a test method based on a large language model.The test script generation method comprises the steps that in response to a recording instruction of a user, an operation event of the user on a graphical user interface is monitored and recorded, and a user operation document is generated; inputting the user operation document into a pre-trained large language model, identifying an operation set corresponding to continuous operation events in the user operation document by the large language model, and mapping the operation set into at least one behavior instance; and outputting the at least one behavior instance as an executable test script. According to the method, a test script is generated by abstracting a'behavior instance 'through recording operation and intelligent identification by using a large model, so that the technical threshold is greatly reduced, and non-technical personnel can easily create an automatic test; the script is based on a behavior intention instead of an interface element, when an interface changes, self-adaption can be achieved only by retraining the model, and maintainability and robustness are remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of software testing technology, and in particular to a method for generating test scripts and a testing method based on a large language model. Background Technology

[0002] User interface (UI) automated testing is a crucial step in ensuring software quality during the software development process. Its core objective is to simulate real user operations to verify the correctness and stability of software functionality.

[0003] Currently, mainstream UI automation testing methods mainly fall into two categories: First, code-based testing, where testers use application programming interfaces (APIs) provided by testing frameworks (such as Selenium) to write code to identify interface elements and simulate user actions. While this method offers high flexibility, it requires advanced technical skills, involves significant script writing and maintenance, and incurs high labor costs. Second, record-and-playback testing, where tools record user actions (such as click coordinates and keyboard input) and generate replayable scripts. While this method lowers the technical barrier, the generated scripts are very fragile and heavily dependent on the interface layout at the time of recording (such as control positions). Even minor changes to the interface (such as button repositioning) can render the recorded scripts invalid, resulting in poor maintainability.

[0004] In summary, existing technologies have the following significant drawbacks: either they have high technical barriers and high development and maintenance costs, or the scripts are fragile, have poor fault tolerance, and are difficult to adapt to changes in the interface, making it impossible to ensure the robustness and maintainability of testing while lowering the barrier to entry. Summary of the Invention

[0005] In view of the above-mentioned shortcomings of the prior art, the present invention provides a test script generation method and a testing method based on a large language model to solve the technical problems of high threshold, fragile scripts and high maintenance costs of existing UI automation testing technology.

[0006] To achieve the above and other related objectives, this invention provides a test script generation method based on a large language model, comprising: responding to a user's recording instruction, listening to and recording user operation events on a graphical user interface, and generating a user operation document; inputting the user operation document into a pre-trained large language model, wherein the large language model identifies the set of operations corresponding to consecutive operation events in the user operation document and maps them to at least one behavior instance, wherein: the large language model is trained using paired sample data containing operation sets and predefined behavior templates, the predefined behavior templates are abstractions of a set of operations defined to complete a common user intent, and the behavior instances are instantiated objects of the mapped predefined behavior templates and contain specific parameters from the user operation document; and outputting the at least one behavior instance as an executable test script.

[0007] In one embodiment of the present invention, the operation events include mouse events and keyboard events, and the user operation document is a serialized record containing timestamps, event types, and screen coordinates or key values.

[0008] In one embodiment of the present invention, the predefined behavior template further includes a supervision mechanism bound to the operation set, the supervision mechanism being used to verify whether the execution result of its sub-operations meets expectations when the behavior instance is executed.

[0009] In one embodiment of the present invention, the predefined behavior template further includes a rollback mechanism, which is used to roll back the graphical user interface to the state before the behavior instance was executed when the supervision mechanism fails to pass the verification.

[0010] In one embodiment of the present invention, the method further includes: during the process of listening to and recording the operation event, in response to the user's monitoring instruction, pausing the recording and receiving the user's assertion settings for the target control on the graphical user interface, wherein the assertion settings are recognized by the large language model and bound as the monitoring mechanism to the corresponding behavior instance, and incorporated into the test script.

[0011] In one embodiment of the present invention, after outputting an executable test script, the method further includes: receiving user iteration requirements for the test script, wherein the iteration requirements include at least one of iteration count, parameter variation range, and parameter variation rules; and optimizing the test script composed of the behavior instances based on the iteration requirements to generate a parameterized iterative test script.

[0012] To achieve the above and other related objectives, the present invention also provides a testing method based on a large language model, comprising: generating an executable test script using the above-described test script generation method; automatically executing behavioral instances in the test script in sequence to simulate user operations; and verifying the execution results of the test script to obtain test results.

[0013] In one embodiment of the present invention, the predefined behavior template further includes a supervision mechanism bound to the operation set. The supervision mechanism is used to verify whether the execution result of its sub-operations meets expectations when the behavior instance is executed. In the step of automatically executing the behavior instances in the test script in sequence to simulate user operations, when each behavior instance is executed, the supervision mechanism bound to that behavior instance is triggered to verify whether the execution result of its sub-operations meets expectations.

[0014] In one embodiment of the present invention, the predefined behavior template further includes a rollback mechanism, which is used to roll back the graphical user interface to the state before the behavior instance is executed when the supervision mechanism fails the verification; after the step of triggering the supervision mechanism bound to the behavior instance, the method further includes: triggering the rollback mechanism when the verification fails, rolling back to the state before the behavior instance is executed and retrying.

[0015] In one embodiment of the present invention, during the process of listening to and recording the operation event, in response to the user's monitoring instruction, the recording is paused and the user's assertion settings for the target control on the graphical user interface are received. The assertion settings are recognized by the large language model and bound to the corresponding behavior instance as the monitoring mechanism, and incorporated into the test script. The testing method further includes: during the execution of the test script, executing the monitoring mechanism bound to the behavior instance; when the monitoring mechanism detects an anomaly, pausing the testing process and preserving the test environment.

[0016] The beneficial effects of this invention are as follows: This invention proposes a test script generation method and testing method based on a large-scale language model. This method generates test scripts by recording user operations and using a pre-trained large-scale language model to intelligently identify and abstract high-level "behavioral instances," greatly reducing the technical threshold for test script creation. Even non-technical personnel can easily create automated tests. Furthermore, the scripts generated by this method are based on behavioral intent rather than specific interface elements. When the user interface changes, the script can adapt to the new interface simply by retraining the model, significantly improving the maintainability and robustness of the test scripts. In addition, by introducing supervision, rollback, and monitoring mechanisms, the atomicity and stability of test execution are ensured, and the state is automatically preserved in case of anomalies, greatly improving the reliability and debugging efficiency of automated testing. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. The accompanying drawings are incorporated in and constitute a part of this specification, illustrating embodiments consistent with this application, and are used together with the description to explain the principles of this application. Obviously, the drawings described below are merely some embodiments of the present invention, and those skilled in the art can obtain other drawings based on these drawings without creative effort.

[0018] Figure 1 A flowchart of a test script generation method provided in an embodiment of the present invention; Figure 2 A flowchart illustrating the generation of an iterative test script according to an embodiment of the present invention; Figure 3 This is a first flowchart of a testing method provided in an embodiment of the present invention; Figure 4 This is a second flowchart of a testing method provided in an embodiment of the present invention. Detailed Implementation

[0019] The following specific embodiments illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. It should be noted that, unless otherwise specified, the following embodiments and features can be combined with each other. In addition to the specific methods, equipment, and materials used in the embodiments, based on the knowledge of the prior art and the description of the present invention by those skilled in the art, any prior art methods, equipment, and materials similar to or equivalent to the methods, equipment, and materials in the embodiments of the present invention can be used to implement the present invention.

[0020] It should be understood that the terminology used in the embodiments of this invention is for describing specific implementations and not for limiting the scope of protection of this invention. Unless otherwise defined, all technical and scientific terms used in this invention have the same meaning as commonly understood by one of ordinary skill in the art.

[0021] In the following description, numerous details are explored to provide a more thorough explanation of embodiments of the invention. However, it will be apparent to those skilled in the art that embodiments of the invention may be practiced without these specific details. In some embodiments, well-known structures and devices are shown in block diagram form rather than in detail to avoid obscuring embodiments of the invention.

[0022] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functions, and operations that may be implemented in the methods and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0023] Please see Figure 1 , Figure 1 A test script generation method based on a large language model is provided in one embodiment of the present invention, including steps S101 to S103.

[0024] Step S101: In response to the user's recording command, listen to and record the user's operation events on the graphical user interface, generating a user operation document. This is done to capture the user's actual operation process on the interface seamlessly and completely, providing the most original, unprocessed data foundation for subsequent intelligent recognition, thereby ensuring that the test can realistically simulate user behavior. This process records low-level "operation information," such as mouse movement, clicks, and keyboard key presses, along with timestamps. This information is independent of specific interface elements, making the recording process non-intrusive to the user and possessing better versatility.

[0025] In one specific embodiment of the present invention, the operation events include mouse events and keyboard events, and the user operation document is a serialized record containing timestamps, event types, and screen coordinates or key values. Below is an example of a user operation document: Recording start sign 2025-05-30 15:16:04,666 mouse click left at (100,200) 2025-05-30 15:16:05,431 keyboard press "A" 2025-05-30 15:16:05,530 keyboard release "A" Monitoring start sign Monitor whether "A" is recognized as a valid input. End of monitoring sign 2025-05-30 15:16:06,341 mouse click left at (150,300) 2025-05-30 15:16:16,278 mouse click left at (400,500) Monitoring start sign Monitor whether the output at this time meets expectations. End of monitoring sign "Recording End Mark"; The example above records a complete operation: the user clicks at position (100,200), then enters the letter "A", sets a monitoring point to check if the input is correct, and finally clicks two buttons at positions (150,300) and (400,500), and sets another monitoring point to check if the output is correct.

[0026] Step S102: Input the user operation document into a pre-trained large language model. The large language model identifies the set of operations corresponding to continuous operation events in the user operation document and maps them to at least one behavior instance. The large language model is trained by paired sample data containing operation sets and predefined behavior templates. The predefined behavior template is an abstraction of a set of operations defined to complete a common user intent. The behavior instance is an instantiated object of the mapped predefined behavior template and contains specific parameters from the user operation document.

[0027] In this step, the large language model identifies and groups user operation documents based on the logic and relevance of the operations, forming multiple operation sets. That is, a user operation document can be identified as at least one operation set. Since the large language model is trained on sample data such as {operation set, predefined behavior template}, each operation set can be mapped to a behavior instance. The training of the large language model relies on domain experts conducting a comprehensive analysis of the software under test, listing all possible behaviors (such as downloading, online, offline, inputting content, clicking buttons, etc.); then, a corresponding standard operation sequence is designed for each behavior. Because the buttons and operation logic in the interface are finite, the final range of behaviors to be trained is controllable. The training samples are paired data consisting of "user operation fragments (operation sets)" and "corresponding standard behavior templates (predefined behavior modules)".

[0028] In this step, the predefined behavior template is an abstraction of a set of operations defined to fulfill a common user intent. For example, for the "click-input" operation set in the example above, an Input behavior template can be predefined, which abstracts the user intent of "entering text at the specified location". More complex behaviors, such as Download, encapsulate a series of operations such as clicking the download button, waiting for compilation, clicking the OK button, and waiting for the download to finish.

[0029] In this step, the behavior instance is a concrete representation of the template. For example, after the model identifies the set of operations in the example, it generates a behavior instance Input(100, 200,"A", id), where the coordinates and the input value "A" are specific parameters from the user's operation document. In addition, the behavior instance can also include a unique id to identify each behavior instance. The id is a unique representation of the behavior instance; different behaviors correspond to different operations, and different ids of the same behavior have different monitoring mechanisms. In another example, the download operation can be abstracted into a behavior Download(id), because the download button and the confirm button are fixed, so no additional parameters are needed.

[0030] Taking the behavior instance Input as an example, it may include the following operation information: “Input(x,y,"A",id): mouse_click_left()(x,y),t1,Supervise(self),Monitor1(),Monitor2(),… keyboard_input("A"),t2,Supervise(self),Monitor1(),Monitor2(),…"; In the above behavioral examples, Supervisor(self) is the supervision mechanism for each operation, which will trigger a rollback when it fails. The same operation may be different in different behaviors, and each operation has only one supervision mechanism; Monitor() is the monitoring mechanism, which is set by the user, and there can be multiple monitors behind each operation.

[0031] In this step, based on the logic and relevance of the operations, these operations are intelligently grouped into multiple operation sets. Each operation set is precisely identified as a specific behavior (i.e., a predefined behavior template) and a behavior instance is generated. These behaviors are essentially API interfaces provided to testers for simulating user operations and possess good atomicity and flexibility. With the help of these precisely identified behaviors, the system can more accurately simulate the execution of these behaviors, thereby significantly improving the accuracy of the recording.

[0032] When the model encounters an unrecognized operation, it will directly generate the corresponding behavior according to the recorded execution method to ensure that all operations are recorded. These behaviors include: mouse operations: Mouse_Undefined(ClickType(left click / right click / scroll wheel / move, etc.),X,Y,id), indicating that the mouse performs a specified click type at position (X,Y); keyboard operations: Keyboard_Undefined(Inputs,id), indicating that a key on the keyboard is pressed.

[0033] Step S103: Output at least one behavior instance as an executable test script. This step serializes abstract, atomic behavior instances into a structured instruction set that can be read and executed by the automation engine, thus completing the final transformation from user operation to automated test script. If there are multiple behavior instances, they can be combined in execution order to obtain the final test script.

[0034] Below is an example of a test script: “Start(0),T1 Input(x,y,1,1),T2 Download(2),T3 Input(x,y,2,3),T2 Download(4),T3”; In this example, each test script begins with a default start() action that does nothing, and the T following each line indicates the waiting time.

[0035] In one specific embodiment of the present invention, the predefined behavior template also includes a supervision mechanism bound to the operation set. This supervision mechanism verifies whether the execution results of its sub-operations meet expectations when a behavior instance is executed. For example, for the Input behavior, the supervision mechanism can check whether the input box is correctly activated after the "mouse click" sub-operation; and check whether the entered text is correct after the "keyboard input" sub-operation. By verifying each sub-operation in real time, the execution process of each behavior instance is ensured to be accurate, providing a foundation for atomic execution and greatly improving the reliability of the test.

[0036] In one specific embodiment of the present invention, the predefined behavior template also includes a rollback mechanism. This rollback mechanism is used to revert the graphical user interface to the state before the behavior instance was executed when the monitoring mechanism fails to verify the behavior. For example, when an incorrect character "B" is detected, the rollback mechanism is triggered, automatically pressing the Backspace key repeatedly to delete the incorrect input and moving the mouse back to its initial position. The rollback mechanism ensures the atomicity of the behavior; that is, a behavior either succeeds completely or fails completely without affecting subsequent tests, making the automated testing process more robust and capable of self-correction in the face of unexpected interference.

[0037] In a specific embodiment of the present invention, the test script generation method further includes: during the process of listening to and recording operation events, responding to the user's monitoring command, pausing recording and receiving the user's assertion settings for the target control on the graphical user interface, wherein the assertion settings are recognized by a large language model and bound to the corresponding behavior instance as a monitoring mechanism, and incorporated into the test script. The monitoring mechanism can be set up as follows: the user triggers a monitoring command during recording, selects the "status indicator" control on the interface, and sets the assertion: "The color of this control should be green." By directly embedding the result verification points into the test script, real-time and automated verification of key business states is achieved during test execution, complementing the supervision mechanism and constructing a comprehensive verification system from the operation process to the business result.

[0038] Please see Figure 2 In a specific embodiment of the present invention, after the output is an executable test script, the test script generation method further includes: S201, receiving the user's iteration requirements for the test script, wherein the iteration requirements include at least one of the following: number of iterations, parameter change range, and parameter change rules; S202, based on the iteration requirements, optimizing the test script composed of behavior instances to generate a parameterized iterative test script.

[0039] For example, a user recorded entering port numbers 0 and 1. In each test scenario, the behavior was identical, the only difference being the input values. After identifying the repetitive pattern, the system optimized the script based on the user-defined iteration requirements (65536 iterations): "$For i in 65535##$ is the iteration symbol, where i represents the current round number and 65536 represents the total number of rounds." Start(0),T1 Input(x,y,i,1),T2 Download(2),T3”; This approach transforms single or multiple recordings into large-scale data-driven testing, significantly freeing up manpower, solving efficiency bottlenecks in repetitive testing scenarios, and doubling testing efficiency.

[0040] This invention replaces the traditional API-based test script generation method with recording user actions, significantly lowering the technical barrier for testers. It takes a user-centric approach, rather than solely focusing on the software, thus better aligning with user scenarios and making the tests more closely reflect real user behavior patterns.

[0041] Utilizing large-scale models for precise user action identification enables accurate recognition of user intent during recording and provides mechanisms (supervision, rollback, and monitoring) to ensure precise, iterative, and atomic execution of these actions during test script execution. It not only identifies the core intent of user actions but also automatically corrects minor deviations in action logs, ensuring more accurate execution of user actions during simulation. For example, even if the user doesn't click the exact center of a button during recording, the large-scale model can still identify the user's true intent and accurately click the center position during simulation, improving test accuracy and reliability. More importantly, the large-scale model ensures the integrity and atomicity of simulated behavior. Test scripts identified by the large-scale model integrate all operations within a behavior and execute them atomically, ensuring the integrity of the entire behavior. This means that once a behavior begins execution, all related operations will be executed completely, without partial execution, thus improving test stability and consistency. Test scripts identified by the large-scale model exhibit significant advantages in maintainability. It takes a user behavior-centric approach, rather than simply simulating user interactions with interface elements, making the intent of each action clearer and more explicit. This intent-driven script structure is not only easy to understand but also greatly simplifies the modification and updating work for testers. Furthermore, when the user interface changes, testers do not need to perform tedious line-by-line modifications to the test script. Instead, they only need to retrain the large model, allowing the test script to automatically adapt to the new interface and ensure the test runs correctly. This not only significantly improves the maintenance efficiency of test scripts but also greatly reduces maintenance costs, making testing more efficient and sustainable.

[0042] Please see Figure 3 , Figure 3 A testing method based on a large language model, provided in an embodiment of the present invention, includes the following steps: S301, generating an executable test script using the above-described test script generation method; S302, automatically executing the behavior instances in the test script in sequence to simulate user operations; S303, verifying the execution result of the test script to obtain the test result.

[0043] This testing method integrates intelligent script generation with reliable execution verification, forming a complete automated testing loop. It not only solves the challenge of creating scripts "from scratch," but also ensures the testing process progresses "from good to excellent" through stable execution and comprehensive verification, ultimately outputting reliable test results and comprehensively improving the practicality, efficiency, and quality of UI automated testing.

[0044] In a specific embodiment of the present invention, when a supervision mechanism is introduced in step S301, during step S302, the supervision mechanism bound to each behavior instance is triggered to verify whether the execution result of its sub-operations meets expectations. This enables the test execution process to have "real-time quality inspection" capabilities, allowing for the immediate detection of operational deviations, preventing error accumulation, and ensuring the accuracy of each simulated operation, thus laying the foundation for a high success rate throughout the entire test process.

[0045] In a specific embodiment of the present invention, when a rollback mechanism is introduced in step S301, after the step of triggering the supervision mechanism bound to the behavior instance, the method further includes: triggering the rollback mechanism when the verification fails, rolling back to the state before the execution of the behavior instance, and retrying. This endows the test execution with "fault tolerance and self-healing" capabilities. When encountering non-software defect problems such as brief interface response delays or unexpected pop-ups, the system can automatically restore the state and retry, significantly reducing unnecessary failures and greatly enhancing the robustness and stability of the test process.

[0046] In a specific embodiment of the present invention, when a monitoring mechanism is introduced in step S301, the testing method further includes: during the execution of the test script, executing a monitoring mechanism bound to the behavior instance; when the monitoring mechanism identifies an anomaly, pausing the testing process and preserving the test environment. This achieves "real-time business verification and intelligent breakpoints." Once a business logic anomaly is detected, the system does not simply report an error and exit, but pauses and fully preserves the software state and test context at the time the problem occurred, providing the most direct on-site evidence for testers to subsequently locate and debug the problem, greatly shortening the problem investigation time.

[0047] Please see Figure 4 This demonstrates a more complete testing methodology, comprising three core phases: test case generation (corresponding to steps S101-S103), test script execution (corresponding to step S302), and test result verification (corresponding to step S303). The entire system uses a pre-trained Large Language Model (LLM) as its intelligent core, coordinating the work of each module. In this flowchart, test case generation includes two modes: a recording mode corresponding to steps S101-S103, and a programming mode corresponding to the traditional method. Both are retained to further enhance the flexibility of test case generation.

[0048] It should be noted that the steps of the various methods described above are only for clarity. In practice, they can be combined into one step or some steps can be split into multiple steps. As long as they contain the same logical relationship, they are all within the scope of protection of this application. Adding insignificant modifications or introducing insignificant designs to the algorithm or process, but without changing the core design of the algorithm and process, are also within the scope of protection of this patent.

[0049] Suppose a tester needs to test a function: by modifying the local port number (ranging from 0 to 65535) in the TCP communication block configuration, check which port numbers are invalid (unable to connect successfully). The specific operation steps include: (1) moving the mouse to the location of the local port number. (2) entering the local port number (traversing from 0 to 65535). (3) clicking the download button. (4) waiting for the download interface to load, then clicking the new download button again and waiting for the download to complete. (5) checking whether the communication connection is established (in the communication block running interface, monitor the values ​​of error (true when the connection fails) and status (normally switching between 7005 and 7009)). This testing process is not only tedious, but also very difficult to manually operate by traversing from 0 to 65535.

[0050] The testing method described in this invention significantly reduces the difficulty of the test case. During the test case generation phase, the user first records a test scenario where the port number is changed to 0, then records a test scenario where the port number is changed to 1, and generates a user operation document. The system recognizes the user operation document and generates an operation script.

[0051] During the test script iteration process, the system identifies repetitive behaviors in the operation script and attempts to merge them. At this point, it determines the input content based on the number of iterations in each round (this rule is automatically identified and generated by the system, but can also be modified by the user). The system then iterates the test script according to the total number of iterations input by the user.

[0052] In the Download(2) iteration, in addition to the two button clicks, two monitoring mechanisms are executed after the second button click: (1) monitoring whether the error value is equal to false; (2) monitoring whether the status is in the set {7005, 7009}.

[0053] The system will then automatically execute the iterative test script and monitor the connection status in real time after each round. If an abnormal state is detected (such as a connection not being established), the system will automatically pause the test and record the anomaly information to facilitate subsequent troubleshooting by the tester.

[0054] Besides the method of recording multiple test scenarios for automatic system recognition, test script iteration can also be configured manually. When analyzing test scripts, the system not only checks for duplicates but also identifies and lists parameters (often input values) that may change. Users can then modify this configuration (e.g., specifying the value as -1 to -3000 and the manner of change), and the system will iterate the test script accordingly. This method can be used to test situations that might be overlooked in manual testing. For example, we often assume port numbers are within the range of 0 to 65535, ignoring tests in other ranges. Configuring a test script iterator effectively avoids this problem, especially regarding random changes. By analyzing the test script and automatically iterating through the modified values, the system can provide excellent coverage of the test scenarios.

[0055] By employing a testing method based on large language models, the testing difficulty for testers is significantly reduced. Firstly, this method drastically lowers the technical barrier for testers. It features a recording function that automatically records the tester's steps and converts them into test scripts, eliminating the need for testers to manually write complex code. Furthermore, the behavioral interfaces provided by this method simulate the tester's actual actions, allowing testers to more intuitively understand the meaning of these interfaces. Testers can easily write test scripts by simply calling these interfaces, setting relevant parameters, and arranging them in the required order, thus efficiently completing automated testing tasks. Secondly, during the execution of the test scripts, this method supports intelligent iterative execution. This feature effectively solves the problem of testers needing to perform a large number of repetitive tests in certain scenarios, greatly freeing up labor and improving testing efficiency. In addition, the supervision and monitoring mechanism eliminates the need for testers to monitor the test status in real time; the system automatically monitors the test status and pauses the test while preserving the environment when anomalies occur. Finally, the test scripts are recorded in text format, ensuring the complete preservation of each test process, facilitating subsequent regression testing and providing strong support for continuous software quality assurance.

[0056] The above embodiments are merely illustrative of the principles and effects of the present invention and are not intended to limit the invention. Any person skilled in the art can modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by those skilled in the art without departing from the spirit and technical concept disclosed in the present invention should still be covered by the claims of the present invention.

Claims

1. A method for generating test scripts based on a large language model, characterized in that, include: In response to the user's recording command, it listens for and records the user's operation events on the graphical user interface and generates user operation documents; The user action document is input into a pre-trained large-scale language model, which identifies the set of actions corresponding to consecutive action events in the user action document and maps them to at least one behavior instance, wherein: The large language model is trained using paired sample data containing a set of operations and predefined behavior templates. The predefined behavior template is an abstraction of a set of operations defined to accomplish a common user intent. The behavior instance is an instantiated object of the mapped predefined behavior template and contains specific parameters from the user operation document; Output the at least one instance of the behavior as an executable test script.

2. The test script generation method based on a large language model according to claim 1, characterized in that, The operation events include mouse events and keyboard events, and the user operation document is a serialized record containing timestamps, event types, and screen coordinates or key values.

3. The test script generation method based on a large language model according to claim 1, characterized in that, The predefined behavior template also includes a supervision mechanism bound to the operation set. The supervision mechanism is used to verify whether the execution result of its sub-operations meets expectations when the behavior instance is executed.

4. The test script generation method based on a large language model according to claim 3, characterized in that, The predefined behavior template also includes a rollback mechanism, which is used to revert the graphical user interface to the state before the behavior instance was executed when the supervision mechanism fails to pass the verification.

5. The test script generation method based on a large language model according to claim 1, characterized in that, The method further includes: During the process of listening to and recording the operation events, in response to the user's monitoring instructions, the recording is paused and the user's assertion settings for the target control on the graphical user interface are received. The assertion settings are recognized by the large language model and bound to the corresponding behavior instance as the monitoring mechanism, and incorporated into the test script.

6. The test script generation method based on a large language model according to claim 1, characterized in that, After outputting an executable test script, the method further includes: Receive user requests for iteration of test scripts, wherein the iteration requests include at least one of the following: number of iterations, range of parameter changes, and rules for parameter changes; Based on the aforementioned iterative requirements, the test script composed of the aforementioned behavior instances is optimized to generate a parameterized iterative test script.

7. A testing method based on a large language model, characterized in that, include: An executable test script is generated using the method described in any one of claims 1, 2, or 6. The test script automatically executes instances of actions in sequence to simulate user actions; The execution result of the test script is verified to obtain the test result.

8. The testing method based on a large language model according to claim 7, characterized in that, The predefined behavior template also includes a supervision mechanism bound to the operation set. The supervision mechanism is used to verify whether the execution result of its sub-operations meets expectations when the behavior instance is executed. In the step of automatically executing the behavior instances in the test script in sequence to simulate user operations, when executing each behavior instance, a supervision mechanism bound to that behavior instance is triggered to verify whether the execution result of its sub-operations meets expectations.

9. The testing method based on a large language model according to claim 8, characterized in that, The predefined behavior template also includes a rollback mechanism, which is used to revert the graphical user interface to the state before the behavior instance was executed when the supervision mechanism fails to pass the verification. After the step of triggering the supervision mechanism bound to the behavior instance, the method further includes: triggering a rollback mechanism when the verification fails, rolling back to the state before the behavior instance was executed and retrying.

10. The testing method based on a large language model according to claim 7, characterized in that, During the process of listening to and recording the operation events, in response to the user's monitoring instructions, the recording is paused and the user's assertion settings for the target control on the graphical user interface are received. The assertion settings are recognized by the large language model and bound to the corresponding behavior instance as the monitoring mechanism, and incorporated into the test script. The testing method also includes: during the execution of the test script, executing a monitoring mechanism bound to the behavior instance; when the monitoring mechanism detects an anomaly, pausing the testing process and preserving the test environment.