A method and device for automatically generating and executing test scripts
Through the multi-agent system, the problem of existing automated testing tools relying on manual settings is solved, the testing efficiency and accuracy are improved, the software is adapted to the needs of rapid iteration, and efficient automated testing is achieved.
Patent Information
- Application Number
- CN202410783151.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-18
- Publication Date
- 2024-12-17
- Estimated Expiration
- 2044-06-18
AI Technical Summary
Existing automated testing tools rely on a large amount of manual setup and maintenance, resulting in waste of human and material resources and poor testing results, which cannot meet the needs of rapid software delivery.
It adopts a multi-agent system, including central agents, test inference explanation agents, test data conversion agents, and test tool execution agents. Through division of labor and cooperation, test scripts are automatically generated and executed to improve testing efficiency, accuracy and adaptability.
It significantly reduces testing costs, improves testing efficiency, accuracy and adaptability, realizes automated and intelligent testing processes, and adapts to the rapid changes in software iteration.
Smart Images

Figure CN118484400B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software testing, and in particular to a method and device for automatically generating and executing a test script. Background Art
[0002] Software testing is the process of running or measuring a software system using manual or automatic means. Its purpose is to verify whether the software system to be tested meets the specified requirements, or to determine the difference between the expected operating results and the actual operating results.
[0003] As the software development process continues to accelerate and become more complex, the demand for software system testing has increased significantly. Traditional manual testing methods can no longer meet the needs of rapid delivery of software systems. Automated testing has become a necessary means to improve software quality and development efficiency.
[0004] However, the automated testing tools and methods in the prior art often rely on a large amount of manual setup and maintenance, which to a certain extent limits the benefits of automated testing; specifically, during software iteration, this manual setup and maintenance method greatly wastes human and material resource costs, and there is a problem of unsatisfactory testing results.
[0005] In view of this, overcoming the defects of the prior art is an urgent problem to be solved in the field of this technology. Summary of the invention
[0006] The technical problem to be solved by the present invention is to provide a method and device for automatically generating and executing test scripts, the purpose of which is to realize the automatic generation and identification of test scripts through a multi-agent system, and to utilize the division of labor and cooperation among multiple agents to improve the efficiency, accuracy and adaptability of software testing, thereby solving the problem of waste of human and material resource costs and unsatisfactory testing results caused by the existing technology relying on manual setting and maintenance of automated testing tools.
[0007] The present invention adopts the following technical solution:
[0008] In a first aspect, the present invention provides a method for automatically generating and executing test scripts. In the process of testing a new version of the software to be tested, a central agent processes the output information of the test reasoning interpretation agent, the test data conversion agent, and the test tool execution agent to schedule the test reasoning interpretation agent, the test data conversion agent, and the test tool execution agent to complete the automatic generation and execution of the test script;
[0009] The method for automatically generating and executing a test script comprises:
[0010] The test reasoning and interpretation agent converts the test requirement text into an executable test script; the test data conversion agent converts the test scenario description into a structured test case;
[0011] The central agent analyzes the instruction logic of the test script, generates at least one to-be-processed subtask and the dependency relationship between the at least one to-be-processed subtask according to the instruction logic;
[0012] The central agent determines the target execution order of the at least one to-be-processed subtask according to the dependency relationship;
[0013] The test tool execution class agent executes the corresponding test script according to the test case in accordance with the target execution order to obtain the test result, so as to realize the automatic generation and execution of the test script.
[0014] Furthermore, the test reasoning interpretation agent converts the test requirement text into an executable test script including:
[0015] Perform data cleaning and formatting operations on the test requirement text to obtain the requirement instructions;
[0016] Parsing the requirement instruction to generate at least one key entity and a test action; generating a corresponding internal representation according to the at least one key entity and the test action;
[0017] Based on predefined rules, the internal representation is converted into a corresponding test script.
[0018] Further, the parsing of the requirement instruction to generate at least one key entity and a test action; and generating a corresponding internal representation according to the at least one key entity and the test action include:
[0019] Performing part-of-speech tagging on the vocabulary units in the demand instruction to obtain an intermediate instruction carrying the part-of-speech tag;
[0020] Identify at least one requirement entity in the intermediate instruction; when the part-of-speech tag corresponding to the requirement entity is a verb, determine the requirement entity as a test action; when the part-of-speech tag corresponding to the requirement entity is not a verb, determine the requirement entity as a key entity;
[0021] According to a preset format, the test actions and corresponding key entities are structured to obtain corresponding internal representations.
[0022] Further, the central agent determines the target execution order of the at least one to-be-processed subtask according to the dependency relationship, including:
[0023] Initializing a task execution sequence; after generating a to-be-processed subtask according to the instruction logic, adding the generated to-be-processed subtask to the task execution sequence;
[0024] The priority of the subtasks to be processed in the task execution sequence is determined according to the urgency and / or importance of the subtasks to be processed in the task execution sequence; the arrangement order of the subtasks to be processed in the task execution sequence is dynamically adjusted according to the corresponding priority and the dependency relationship, and the target execution order is determined based on the dynamically adjusted arrangement order.
[0025] Further, when the urgency of the subtask to be processed exceeds a first preset value, an urgent test mark is added to the subtask to be processed; when the importance of the subtask to be processed exceeds a second preset value, an important test mark is added to the subtask to be processed;
[0026] Determining the priority of the subtasks to be processed in the task execution sequence according to the urgency and / or importance of the subtasks to be processed in the task execution sequence; dynamically adjusting the arrangement order of the subtasks to be processed in the task execution sequence according to the corresponding priorities and the dependency relationships, and determining the target execution order based on the dynamically adjusted arrangement order includes:
[0027] When the subtask to be processed in the task execution sequence carries an urgent test mark and an important test mark, the corresponding subtask to be processed is determined as a first priority task; when the subtask to be processed in the task execution sequence only carries an urgent test mark, the corresponding subtask to be processed is determined as a second priority task; when the subtask to be processed in the task execution sequence only carries an important test mark, the corresponding subtask to be processed is determined as a third priority task;
[0028] Based on the current system state, preferentially select a to-be-processed subtask from the first priority task, and adjust the position of the selected to-be-processed subtask in the task execution sequence so that it is close to the sequence head of the task execution sequence, and the selected to-be-processed subtask is located after the to-be-processed subtask on which it depends;
[0029] When the current system state does not support the execution of any first priority task, the position of any first priority task cannot be adjusted according to the corresponding dependency relationship, and / or there is no first priority task in the task execution sequence, select a to-be-processed subtask from the second priority task, and adjust the position of the selected to-be-processed subtask in the task execution sequence so that it is close to the sequence head and the selected to-be-processed subtask is located after the to-be-processed subtask on which it depends;
[0030] When the current system state does not support the execution of any second priority task, the position of any second priority task cannot be adjusted according to the corresponding dependency relationship, and / or there is no second priority task in the task execution sequence, select a to-be-processed subtask from the third priority task, adjust the position of the selected to-be-processed subtask in the task execution sequence so that it is close to the sequence head, and make the selected to-be-processed subtask located after the to-be-processed subtask on which it depends, so as to obtain the corresponding target execution order.
[0031] Furthermore, the test data conversion agent converts the test scenario description into a structured test case including:
[0032] Key objects and corresponding test values are extracted from the test scenario description, and the key objects and corresponding test values are organized into test cases according to preset structure conversion rules.
[0033] Furthermore, the test tool execution class agent executes the corresponding test script according to the test case in the target execution order, and obtains the test results including:
[0034] Acquire a test script from the test reasoning interpretation agent; acquire a test case from the test data conversion agent; wherein the test case includes a test object and a corresponding test object value, a test step and a corresponding test step value, an expected result and a corresponding success result value;
[0035] Match the parameter name in the test script with the test object, and use the test object value corresponding to the test object as the input parameter corresponding to the parameter name; determine the test steps and expected results corresponding to the test object, execute the test script based on the input parameters according to the corresponding test step values, and obtain the test result based on the corresponding success result value.
[0036] Furthermore, the central agent analyzes the test results to obtain corresponding error and abnormal conditions; and generates a test report for the task to be processed according to the error and abnormal conditions;
[0037] The method for automatically generating and executing a test script also includes:
[0038] Extract at least one test indicator and corresponding indicator data from historical test data;
[0039] Determine an initial recognition model for the test indicator; use the indicator data to train the initial recognition model, learn a first association relationship from the indicator data, and obtain a target recognition model based on the first association relationship; wherein the first association relationship is an association relationship between a test result and an error or abnormality; use the target recognition model to process the test result to obtain an error or abnormality of the test result;
[0040] According to the test indicators and corresponding indicator data, corresponding error anomaly prediction is obtained;
[0041] Determine a second association relationship; wherein the second association relationship is an association relationship between the error and abnormality of the test result and the optimizable points of the software to be tested; based on the second association relationship, obtain a recommended adjustment mode for the optimizable points;
[0042] The test report is generated based on the test results and the corresponding error and abnormality conditions, error and abnormality predictions and the recommended adjustment mode.
[0043] In a second aspect, the present invention further provides a device for automatically generating and executing a test script, which is used to implement the method for automatically generating and executing a test script in the first aspect, and the device for automatically generating and executing a test script comprises:
[0044] At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the processor to execute the method for automatically generating and executing test scripts described in the first aspect.
[0045] In a third aspect, the present invention further provides a non-volatile computer storage medium storing computer executable instructions, which are executed by one or more processors to complete the method of automatically generating and executing test scripts described in the first aspect.
[0046] In a fourth aspect, a chip is provided, comprising: a processor and an interface, for calling and running a computer program stored in the memory from a memory, and executing the method of automatically generating and executing a test script as in the first aspect.
[0047] In a fifth aspect, a computer program product comprising instructions is provided, which, when executed on a computer or a processor, enables the computer or the processor to execute a method for automatically generating and executing a test script as described in the first to fourth aspects and any one of the aspects.
[0048] In the sixth aspect, a method system for automatically generating and executing test scripts is provided, including an apparatus for automatically generating and executing test scripts as in the second aspect, and using the method for automatically generating and executing test scripts as described in the first aspect to complete the interaction of the apparatus for automatically generating and executing test scripts as in the second aspect.
[0049] Different from the prior art, the present invention has at least the following beneficial effects:
[0050] The present invention, through the division of labor and cooperation among the central agent, the test reasoning and interpretation agent, the test data conversion agent and the test tool execution agent, generates pending tasks when a new version of the software to be tested appears, converts the test requirement text of the pending tasks into an executable test script, converts the test scenario description of the pending tasks into a structured test case, generates at least one pending subtask and its dependency relationship according to the instruction logic of the test script, thereby obtaining the target execution order of the pending tasks, and executes the corresponding test scripts according to the test case in accordance with the target execution order, and finally obtains the test results; wherein, the central agent identifies the new version, quickly generates pending tasks for software iteration, and has high adaptability. Since multiple agents are used to generate test scripts and test cases for the pending tasks and obtain test results, the automation and intelligence of the test process are improved, the test cost is significantly reduced, and the test efficiency, accuracy and adaptability are improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0052] Figure 1 This is a schematic diagram of event and information flow processing provided by an embodiment of the present invention;
[0053] Figure 2 It is a flowchart of a method for automatically generating and executing a test script provided by an embodiment of the present invention;
[0054] Figure 3 is a flow chart of step 10 provided in an embodiment of the present invention;
[0055] Figure 4 is a flowchart of step 102 provided by an embodiment of the present invention;
[0056] Figure 5 is a flow chart of step 30 provided in an embodiment of the present invention;
[0057] Figure 6 is a flowchart of step 302 provided by an embodiment of the present invention;
[0058] Figure 7 is a flow chart of step 40 provided in an embodiment of the present invention;
[0059] Figure 8 It is another flow chart of automatically generating and executing test scripts provided by an embodiment of the present invention;
[0060] Fig. 9 It is a schematic diagram of the architecture of an apparatus for automatically generating and executing test scripts provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0061] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0062] Unless the context requires otherwise, throughout the specification and claims, the term "including" is to be interpreted as open inclusion, that is, "including, but not limited to". In the description of the specification, the terms "one embodiment", "some embodiments", "exemplary embodiments", "examples", "specific examples" or "some examples" and the like are intended to indicate that specific features, structures, materials or characteristics associated with the embodiment or example are included in at least one embodiment or example of the present disclosure. The schematic representation of the above terms does not necessarily refer to the same embodiment or example. In addition, the specific features, structures, materials or characteristics may be included in any one or more embodiments or examples in any appropriate manner, that is, although they may be carried in the embodiments or examples of the above terms due to reasons such as the order and position of appearance, it is not limited to that they can be carried in combination by one embodiment or example.
[0063] In the description of the present invention, it is necessary to understand that the terms "center", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating orientations or positional relationships, are based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present disclosure and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present disclosure.
[0064] In the description of the present invention, the terms "first" and "second" are used only for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present disclosure, unless otherwise specified, the meaning of "multiple" is two or more. In addition, for example, the same type of nouns may be described as two independent individuals by adding "A" and "B" at the end. In this case, the corresponding features defined as "A" and "B" are only used to distinguish the same type of individuals for description purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features.
[0065] When describing some embodiments, the expressions "coupling", "coupling" and "connection" and their derivatives may be used. For example, when describing some embodiments, the term "connection" may be used to indicate that two or more components are in direct physical or electrical contact with each other. For another example, when describing some embodiments, the term "coupling" may be used to indicate that two or more components are in direct physical or electrical contact. However, the terms "connection" or "coupling" may also refer to two or more components that are not in direct contact with each other, but still cooperate or interact with each other, such as "optical path coupling", "wireless connection", etc. The embodiments disclosed herein are not necessarily limited to the contents of the present invention.
[0066] In the description of the present invention, the expression "A and / or B" (where A and B are used to formally represent specific characteristic contents) is involved, and the corresponding expressions include the following three combinations: only A, only B, and a combination of A and B.
[0067] As used herein, "about," "substantially," or "approximately" includes the stated value and an average value that is within an acceptable range of deviation from the particular value as determined by one of ordinary skill in the art taking into account the measurements in question and the errors associated with the measurement of the particular quantity (i.e., the limitations of the measurement system).
[0068] Embodiment 1:
[0069] In order to solve the above problems, the embodiment of the present invention provides a method for automatically generating and executing test scripts, introducing artificial intelligence technologies such as deep learning and large language models, and realizing automated software testing through intelligent agents (Agents), which greatly improves the automation level of software testing. Each agent in the multi-agent system simulates the collaborative mode of a human team, making the testing process more efficient and intelligent.
[0070] In an optional embodiment, a multi-agent system is used to automatically generate and execute test scripts for the system under test. In the multi-agent system, each agent is assigned a specific role and responsibility to ensure the effective allocation and execution of test tasks; the main agent roles of the multi-agent system are the central agent, the test reasoning and interpretation agent, the test data conversion agent, and the test tool execution agent. Figure 1 As shown in the figure, in this multi-agent system, the event proxy layer is composed of multiple test agents, including test reasoning and interpretation agents, test data conversion agents, and test tool execution agents; all sensor information and actuator feedback are uniformly processed through the event proxy layer to ensure the unidirectionality of information flow, and the central agent makes decisions based on the information fed back by the event proxy layer. Based on modular design, the multi-agent system strengthens the independence and pluggability of each test agent to quickly adapt to different test scenarios and tools; it allows flexible combination and replacement between test agents to adapt to different test requirements and environmental changes. In order to achieve seamless communication between agents, the multi-agent system uses standardized protocols and interfaces to ensure that different agents can exchange information and coordinate tasks without obstacles, thereby improving the collaborative efficiency of the entire multi-agent system. Ensure that the multi-agent system is seamlessly integrated with other stages of the software development life cycle, such as the continuous integration / continuous deployment (CI / CD) pipeline, so that software testing becomes a natural part of the development process, accelerating the entire cycle of the software to be tested from development to deployment. Based on the above optimizations, the application of multi-agent systems in software testing will be more efficient, intelligent, and adaptable, providing more powerful and flexible testing support for software development.
[0071] like Figure 2 As shown, specifically, the central agent monitors the code submission events and branch merge events of the software to be tested, and when a new version of the software to be tested is identified, a task to be processed is generated; the task to be processed is executed to test the new version of the software to be tested; wherein, the embodiment of the present invention instantly identifies new test requirements through the central agent. In an optional embodiment, the central agent uses the application programming interface (Application Programming Interface, abbreviated as API) of the version control system to monitor the code submission events and branch merge events of the software to be tested in real time, and then identify the new version of the software to be tested (for example, new functions or repair points), and automatically trigger the test requirements analysis. In the process of testing the new version of the software to be tested, the central agent processes the output information of the test reasoning interpretation agent, the test data conversion agent, and the test tool execution agent to schedule the test reasoning interpretation agent, the test data conversion agent, and the test tool execution agent to automatically generate and execute the test script.
[0072] The following describes the process of the central agent processing the output information of each test agent and scheduling each test agent. The method of automatically generating and executing the test script includes:
[0073] Step 10: The test reasoning and interpretation agent converts the test requirement text into an executable test script; the test data conversion agent converts the test scenario description into a structured test case.
[0074] Among them, the test script is a domain specific language (DSL for short), that is, a development language designed for specific tasks, which is used to describe, model, analyze and solve problems in a specific field; among them, a specific task, for example: a pending task of software testing a system under test.
[0075] In an optional embodiment, a tester may propose a test requirement instruction, and the text of the test requirement instruction may be used as the test requirement text of the corresponding task to be processed. The structured test case may be a test case in JavaScript Object Notation (JSON) format; a legal JSON instance is: "{"a":1,"b":[1,2,3]}".
[0076] For example, the test reasoning and interpretation agent obtains the test requirement instruction proposed by the tester and recognizes it as the test requirement text: "Verify that the user can add items to the shopping cart". The test requirement text is converted into a DSL code snippet: "add_item_to_cart(user_id, product_id)", and output to the central agent.
[0077] The test data conversion agent obtains the test scenario description: "For the T-shirt with product ID 12345, use user Zhang San to perform the operation", converts it into a data structure in JSON format, obtains the corresponding test case: "{"user": "Zhang San","product_id": "12345", "action": "add_to_cart"}", and outputs it to the central agent.
[0078] Step 20: The central agent analyzes the instruction logic of the test script, and generates at least one to-be-processed subtask and the dependency relationship between the at least one to-be-processed subtask according to the instruction logic.
[0079] In an optional embodiment, when a new version of the software to be tested exists, a pending task corresponding to the new version is generated; a test script is generated by a test reasoning and interpretation agent, and one pending task corresponds to at least one test script; a test case is generated by a test data conversion agent, and one pending task corresponds to at least one test case; the central agent analyzes the logic of each test script and breaks it down into at least one pending subtask. Since there is a logical relationship between the codes in each test script (i.e., the instruction logic in the test script), there is also a corresponding dependency relationship between the at least one pending subtask obtained thereby.
[0080] The central agent implements task scheduling for each test agent, and through task scheduling, at least one pending subtask is processed in parallel to improve the processing efficiency of the multi-agent system. For example, the test script generated based on the test requirement text "Verify that the user can add products to the shopping cart" is decomposed into 4 pending subtasks, namely: login verification, product selection, adding to the shopping cart, and shopping cart status verification. The central agent supports dynamic task scheduling based on real-time environmental data using a dynamic task scheduling algorithm; for example, during the test process, if new test scenarios and test cases appear, the central agent can automatically adjust task allocation and execution order to adapt to the changes. The dynamic task scheduling algorithm will be described in detail below.
[0081] Step 30: The central agent determines the target execution order of the at least one to-be-processed subtask according to the dependency relationship.
[0082] The target execution order is the order in which the multi-agent system executes at least one pending subtask. According to the pending subtasks corresponding to the test script, the central agent constructs a task execution path diagram (i.e., the target execution order) to determine the dependencies and execution order between the pending subtasks.
[0083] The following is an explanation of the relationship between pending tasks and pending subtasks: When the central agent detects that there is an update to the software to be tested, it will generate a corresponding pending task for the code of this update to test the updated code. In order to complete the pending task, the tester will put forward at least one test requirement instruction, and then obtain at least one test requirement text for the pending task, and convert it to obtain the corresponding test script; that is, one pending task corresponds to at least one test script. According to the instruction logic of the test script, at least one pending subtask is generated; that is, one test script corresponds to at least one pending subtask. In summary, one pending task corresponds to at least one pending subtask.
[0084] Step 40: The test tool execution class agent executes the corresponding test script according to the test case in accordance with the target execution order to obtain the test result, so as to realize automatic generation and execution of the test script.
[0085] The embodiment of the present invention executes the test through the test tool execution class agent. The test case and the test script are matched according to the preset rules, and the preset rules are selected by the technicians in this field according to the specific usage scenario. In an optional embodiment, the tester can specify the test case that matches the test script. The two can also be matched according to the keywords in the test case and the keywords in the test script; for example, the test tool execution class agent obtains the test script "add_item_to_cart(user_id, product_id)" generated by the test reasoning interpretation class agent, and the test case {"user": "Zhang San", "product_id": "12345", "action": "add_to_cart"}, because both contain the keywords "user_id" and "product_id", so a matching relationship between the two is established.
[0086] Execute this test script to simulate user Zhang San trying to add the T-shirt with ID 12345 to the shopping cart, and record the test results.
[0087] The present invention, through the division of labor and cooperation among the central agent, the test reasoning and interpretation agent, the test data conversion agent and the test tool execution agent, generates pending tasks when a new version of the software to be tested appears, converts the test requirement text of the pending tasks into an executable test script, converts the test scenario description of the pending tasks into a structured test case, generates at least one pending subtask and its dependency relationship according to the instruction logic of the test script, thereby obtaining the target execution order of the pending tasks, and executes the corresponding test scripts according to the test case in accordance with the target execution order, and finally obtains the test results; wherein, the central agent identifies the new version, quickly generates pending tasks for software iteration, and has high adaptability. Since multiple agents are used to generate test scripts and test cases for the pending tasks and obtain test results, the automation and intelligence of the test process are improved, the test cost is significantly reduced, and the test efficiency, accuracy and adaptability are improved.
[0088] To illustrate the process of generating test scripts, Figure 3 As shown, in step 10, the test reasoning interpretation agent converts the test requirement text into an executable test script including:
[0089] Step 101: Perform data cleaning and formatting operations on the test requirement text to obtain requirement instructions.
[0090] The test reasoning interpretation agent is used to convert the test requirement text in natural language into an executable test script; wherein the test script is a DSL code.
[0091] In a specific scenario, a tester proposes a test requirement: "Verify that the user can add items to the shopping cart". In an optional embodiment, a text recognition agent can be added to the event proxy layer of the multi-agent system; in order to obtain the DSL code, the natural language instruction is first received by the text recognition agent, and it is recognized as the corresponding test requirement text "Verify that the user can add items to the shopping cart". Then, the test requirement text is basically cleaned and formatted to remove irrelevant characters to ensure that the obtained requirement instruction is clear and readable.
[0092] Step 102: Parse the requirement instruction to generate at least one key entity and a test action; and generate a corresponding internal representation according to the at least one key entity and the test action.
[0093] For example, a pre-trained natural language processing (NLP) model is used to analyze the demand instruction. The NLP model can be a Transformer model. The tasks that the NLP model needs to complete may involve part-of-speech tagging, entity recognition, syntactic analysis, and semantic understanding to ensure that it can accurately understand the intent of the instruction. The demand instruction is deeply parsed by the NLP model. The model recognizes the key entities "user", "product", and "shopping cart" and the test action "add" through context understanding, and combines the two to obtain an internal representation.
[0094] Step 103: Based on predefined rules, convert the internal representation into a corresponding test script.
[0095] The predefined rules are selected by those skilled in the art according to the specific usage scenario and are not limited here. In an optional embodiment, the preset definition rules may be: generating a method name according to an action, and generating the input parameters of the method according to a key entity. The DSL generator may be used to implement the conversion logic. Based on the identified key entities and test actions, the test logic is constructed through the DSL generator to obtain the DSL code as a test script. The test reasoning interpretation agent outputs the DSL code snippet as the basis for subsequent execution. The generated DSL code is a directly executable test script that meets the standards of the specific test framework used by the software to be tested.
[0096] For example, for the internal representation "{'action': 'add', 'object': 'user', 'product': 'item', 'target': 'cart'}", the generated DSL code snippet is "add_item_to_cart(user_id, product_id)".
[0097] In an optional embodiment, after the DSL code is generated, it can also be verified and optimized. The generated DSL code is made to pass a verification step to ensure that its syntax is correct and its logic is correct; redundant code is removed to improve execution efficiency.
[0098] To illustrate the process of generating internal representation, Figure 4 As shown, step 102 includes:
[0099] Step 1021: perform part-of-speech tagging on the vocabulary units in the demand instruction to obtain an intermediate instruction carrying the part-of-speech tag.
[0100] For example, after the NLP model identifies the vocabulary units "verify", "user", "product", "shopping cart" and "add" in the demand instruction, it performs part-of-speech tagging on each unit to obtain intermediate instructions; in the intermediate instructions, "verify" carries the part-of-speech tag "verb", "user" carries the part-of-speech tag "noun", "product" carries the part-of-speech tag "noun", "shopping cart" carries the part-of-speech tag "noun" and "add" carries the part-of-speech tag "verb".
[0101] Step 1022: Identify at least one requirement entity in the intermediate instruction; when the part-of-speech tag corresponding to the requirement entity is a verb, determine the requirement entity as a test action; when the part-of-speech tag corresponding to the requirement entity is not a verb, determine the requirement entity as a key entity.
[0102] For example, for the above intermediate instructions, "verify" is the type of software testing, which is not a required entity, and the remaining vocabulary units carrying part-of-speech tags are all required entities. Since "user" carries the part-of-speech tag "noun", "goods" carries the part-of-speech tag "noun", and "shopping cart" carries the part-of-speech tag "noun", "user", "goods" and "shopping cart" are determined as key entities, and since "add" carries the part-of-speech tag "verb", it is determined as a test action.
[0103] Step 1023: Structuring the test actions and corresponding key entities according to a preset format to obtain corresponding internal representations.
[0104] Among them, the preset format is a predefined template or rule, which is selected by technical personnel in this field according to the specific usage scenario and is not limited here; in an optional embodiment, the internal representation obtained according to the preset format can be "{'action':'add', 'object':'user', 'product':'commodity', 'target':'shopping cart'}".
[0105] The embodiment of the present invention helps to further clarify the operation logic of the required instruction by generating an internal representation, so as to prepare for conversion into DSL code.
[0106] In an optional embodiment, generating a test script may be achieved in the following manner:
[0107] Step A1. Loading pre-trained NLP model: First, the system will load a pre-trained NLP model, which is usually based on deep learning technology and can understand and parse human natural language instructions.
[0108] Step A2. Receive natural language instructions: The tester or system inputs a test instruction in natural language form, such as "verify that the user can add items to the shopping cart."
[0109] Step A3. Parsing natural language instructions: The NLP parser (NLP_parser) receives this instruction and converts the natural language instruction into a computer-understandable form using lexical analysis, syntactic analysis, and semantic understanding techniques.
[0110] Step A4. Generate DSL code: Next, the parsed instructions are further converted into domain specific language (DSL) code through a DSL converter (DSL_generator). For example, the instruction "verify that the user can add items to the shopping cart" is converted into a series of instruction sequences that can be recognized and executed by the automated testing tool.
[0111] Step A5. Return DSL code: Finally, the generated DSL code is returned to the system as the basis for the next test script execution.
[0112] To illustrate the process of generating test cases, in step 10, the test data conversion agent converts the test scenario description into a structured test case including:
[0113] Key objects and corresponding test values are extracted from the test scenario description, and the key objects and corresponding test values are organized into test cases according to preset structure conversion rules.
[0114] The preset structure conversion rules are selected by those skilled in the art according to specific usage scenarios and are not limited here.
[0115] For example, the test data conversion agent obtains the test scenario description "For a T-shirt with a product ID of 12345, use user Zhang San to perform an operation", and uses a document parser (such as a PDF or Markdown parsing library) to convert the test scenario description into a format; specifically, the key object "user name" and the corresponding test value "Zhang San", the key object "password" and the corresponding test value "12345", the key object "step" and the corresponding test value "add to cart" are learned from the test scenario description; wherein, predefined rules can be added to extract "steps" from the test scenario description; for example, the predefined rule is: for "for a certain product, use a certain user to perform an operation", "add to cart" is used as the corresponding "step". These key objects and corresponding test values are parsed and converted into a data structure in JSON format to obtain a structured test case {"user": "Zhang San", "product_id": "12345", "action": "add_to_cart"}. Finally, the test data conversion agent outputs the test case to the central agent to provide it to the test tool execution agent for use.
[0116] In an optional embodiment, generating a test case may be achieved by:
[0117] Step B1. Create a format converter instance: initialize a data format converter designed to convert unstructured test scenario descriptions and test case descriptions into structured data (ie, test cases).
[0118] Step B2. Receive input data: Obtain test case documents or descriptive materials, which may be in text, table or other unstructured forms.
[0119] Step B3. Convert data format: Call the conversion method of the format converter to convert the input unstructured data into structured data, such as a test script in JSON format. In this process, key elements such as test steps and expected results are identified and organized in a standard format.
[0120] Step B4. Return structured data: After the conversion is completed, the obtained structured data (such as JSON format) is returned so that the test tool execution class agent can use it directly.
[0121] To illustrate the process of generating the target execution order, such as Figure 5 As shown, the step 30 includes:
[0122] Step 301: Initialize the task execution sequence; after generating the to-be-processed subtasks according to the instruction logic, add the generated to-be-processed subtasks to the task execution sequence.
[0123] Step 302: Determine the priority of the subtasks to be processed in the task execution sequence according to the urgency and / or importance of the subtasks to be processed in the task execution sequence; dynamically adjust the arrangement order of the subtasks to be processed in the task execution sequence according to the corresponding priority and the dependency relationship, and determine the target execution order based on the dynamically adjusted arrangement order.
[0124] In an optional embodiment, the processing process of the central agent can be optimized by genetic algorithm or particle swarm algorithm, taking into account the urgency and complexity of the subtasks to be processed and the dependencies between the subtasks to be processed, so as to achieve a balance of priorities. The specific implementation process can refer to patent CN202310856287.7.
[0125] In another optional embodiment, when the urgency of the subtask to be processed exceeds a first preset value, an urgent test mark is added to the subtask to be processed; when the importance of the subtask to be processed exceeds a second preset value, an important test mark is added to the subtask to be processed. The first preset value and the second preset value are selected by those skilled in the art according to specific usage scenarios and are not limited here. The central agent arranges the test execution plan based on the dynamic task scheduling algorithm according to the current system resource status and task priority. Specifically, Figure 6 As shown, step 302 includes:
[0126] Step 3021: When the subtask to be processed in the task execution sequence carries an urgent test mark and an important test mark, the corresponding subtask to be processed is determined as a first priority task; when the subtask to be processed in the task execution sequence only carries an urgent test mark, the corresponding subtask to be processed is determined as a second priority task; when the subtask to be processed in the task execution sequence only carries an important test mark, the corresponding subtask to be processed is determined as a third priority task.
[0127] Step 3022: Based on the current system status, preferentially select a subtask to be processed from the first priority task, and adjust the position of the selected subtask to be processed in the task execution sequence so that it is close to the sequence head of the task execution sequence, and the selected subtask to be processed is located after the subtask to be processed on which it depends.
[0128] Among them, when the task execution sequence is not empty, the task execution sequence includes at least one subtask to be processed, and the sequence head of the task execution sequence refers to the position of the first subtask to be processed in the task execution sequence; in an optional embodiment, when the task execution sequence is a queue, the sequence head is the head of the queue.
[0129] For the pending subtasks whose order has been adjusted, since they often have dependencies with other pending subtasks, when the pending subtasks they depend on are not executed, errors will occur in the execution of the pending subtasks whose order has been adjusted, so their position in the task execution sequence is placed after the pending subtasks they depend on.
[0130] Step 3023: When the current system state does not support the execution of any first priority task, the position of any first priority task cannot be adjusted according to the corresponding dependency relationship, and / or there is no first priority task in the task execution sequence, select a to-be-processed subtask from the second priority tasks, and adjust the position of the selected to-be-processed subtask in the task execution sequence so that it is close to the sequence head and the selected to-be-processed subtask is located after the to-be-processed subtask on which it depends.
[0131] Among them, "the position adjustment of any first-priority task cannot be completed according to the corresponding dependency relationship" means that there is no first-priority task that can simultaneously meet the following two conditions: (1) adjust the selected to-be-processed subtask to the preset front position of the task execution sequence, and (2) make its position in the corresponding preset front position after the to-be-processed subtask it depends on. The same applies to the position adjustment of any second-priority task or any third-priority task cannot be completed according to the corresponding dependency relationship below.
[0132] Step 3024: When the current system state does not support the execution of any second priority task, the position of any second priority task cannot be adjusted according to the corresponding dependency relationship, and / or there is no second priority task in the task execution sequence, select a subtask to be processed from the third priority task, adjust the position of the selected subtask to be processed in the task execution sequence so that it is close to the sequence head, and make the selected subtask to be processed be located after the subtask to be processed on which it depends, so as to obtain the corresponding target execution order.
[0133] In an optional embodiment, the dynamic task scheduling algorithm can be implemented in the following way:
[0134] Step C1. Create a task queue instance: initialize a task queue manager to store the subtasks to be processed and their priorities.
[0135] Step C2. Receiving a new task: When the system receives a new subtask to be processed, it adds it to the task queue and sorts it according to the real-time environment and task priority.
[0136] Step C3. Dynamically adjust the task order: According to the current system resources, test environment status and other real-time data, dynamically adjust the order of pending subtasks in the task queue to ensure that the high priority or currently most suitable pending subtasks are placed in the front.
[0137] Step C4. Execute task: Loop to get the next pending subtask from the task queue and execute it, which includes calling the corresponding test agent to execute the test script, collect data, etc.
[0138] Step C5. Processing task completion: Each time a pending subtask is completed, the status of the task queue is updated until the task queue is empty, indicating that all pending subtasks have been completed.
[0139] In order to illustrate the process of executing the pending subtasks, Figure 7 As shown, the step 40 includes:
[0140] Step 401: obtain a test script from the test reasoning interpretation class agent; obtain a test case from the test data conversion class agent; wherein the test case includes a test object and a corresponding test object value, a test step and a corresponding test step value, an expected result and a corresponding success result value.
[0141] For example, the test reasoning and interpretation agent obtains the DSL code "add_item_to_cart(user_id, product_id)" generated by the test reasoning and interpretation agent. Among them, the test object "user_id" and the corresponding test object value "Zhang San", the test object "product_id" and the corresponding test object value "12345", the test step "add_item_to_cart()" and the corresponding test step value "add_item_to_cart(user_id, product_id)", the expected result "the return value of 'add_item_to_cart(user_id, product_id)'" and the corresponding successful result value "the return value of user Zhang San successfully adding the T-shirt with ID 12345 to the shopping cart".
[0142] Step 402: Match the parameter name in the test script with the test object, and use the test object value corresponding to the test object as the input parameter corresponding to the parameter name; determine the test steps and expected results corresponding to the test object, execute the test script based on the input parameters according to the corresponding test step values, and obtain the test results based on the corresponding success result values.
[0143] For example, a test environment is built to perform the test; specifically, the test environment is set up, real user and product data are simulated, and a test framework (for example, playwright, selenium, etc.) is called to execute the DSL code; the parameter name "user_id" and the parameter name "product_id" in the DSL code "add_item_to_cart(user_id, product_id)" are matched, and the test object value "Zhang San" corresponding to the test object "user_id" is used as the input parameter corresponding to the parameter name "user_id" in the DSL code, and the test object value "12345" corresponding to the test object "product_id" is used as the input parameter corresponding to the parameter name "product_id" in the DSL code; the test step corresponding to the test object "user_id" is determined to be "add_item_to_cart()" and the expected result "the return value of 'add_item_to_cart(user_id, product_id)'" is determined according to the corresponding test step value "add_item_to_cart(user_id, product_id)". product_id)” and execute the test script based on the aforementioned input parameters to simulate “user Zhang San tries to add a T-shirt with ID 12345 to the shopping cart”.
[0144] Record results: record whether the test is successful, such as whether the product is added correctly, whether there are any error prompts, etc.
[0145] In an optional embodiment, executing the to-be-processed subtask may be achieved in the following manner:
[0146] Step D1. Environment confirmation and preparation: The test tool execution agent is responsible for setting up the test environment and checking whether the test environment meets the requirements, such as browser compatibility, database status, etc.
[0147] Step D2. Data preparation: Prepare or simulate necessary test data according to the test scenario requirements, such as preset user accounts, product information, etc.
[0148] Step D3. Execute test and collect data
[0149] Among them, step D31. Script execution: the test tool execution class agent executes the test script according to the DSL code to simulate user operations, such as logging in, browsing products, and clicking the add to cart button.
[0150] Step D32. Real-time monitoring: During the execution process, each agent monitors the test environment status and collects performance indicators and exception information.
[0151] Step D33. Data recording: Test results, system response time, resource consumption and other data are recorded in detail.
[0152] Embodiment 2:
[0153] The embodiment of the present invention is a further preferred solution of embodiment 1. In order to further reduce the cost and error rate of testing through a multi-agent system, the embodiment of the present invention also provides a method of intelligent feedback and decision-making assistance, which analyzes test data in real time through a central agent, uses a machine learning algorithm to deeply mine the test results, collects feedback after executing the test, gives suggestions for optimizing the test process, and finally generates detailed defect reports and test reports to provide in-depth insights for the development team.
[0154] Specifically, the central agent analyzes the test results to obtain corresponding error and abnormal conditions; and generates a test report for the task to be processed according to the error and abnormal conditions. Figure 8 As shown, the method for automatically generating and executing test scripts also includes:
[0155] In step 501, at least one test indicator and corresponding indicator data are extracted from historical test data.
[0156] Among them, the test indicators can be error type frequency, test case success rate, execution time fluctuation, etc.
[0157] In an optional embodiment, data preprocessing can be implemented in the following manner:
[0158] Step F1. Data collection: Collect a large amount of data from the test execution, including but not limited to test logs, performance indicators, error reports, system response time, etc.
[0159] Step F2. Feature Engineering: Extract meaningful features from the raw data, such as error type frequency, test case success rate, execution time fluctuation, etc. These features can reflect the status and trend of software quality.
[0160] Step F3. Data cleaning: remove noise data, process missing values, standardize numerical features, and ensure data quality.
[0161] In step 502, an initial recognition model is determined for the test indicator; the initial recognition model is trained using the indicator data, a first association relationship is learned from the indicator data, and a target recognition model is obtained based on the first association relationship; wherein the first association relationship is an association relationship between a test result and an error or abnormal condition; the test result is processed using the target recognition model to obtain an error or abnormal condition of the test result.
[0162] In an optional embodiment, a recognition model is constructed to perform pattern recognition on test indicators; specifically, through model learning, common error patterns and abnormal behaviors in test results are identified, such as frequent errors in specific functional modules and performance degradation of the system under specific loads.
[0163] In step 503, a corresponding error anomaly prediction is obtained according to the test indicator and the corresponding indicator data.
[0164] In an optional embodiment, a first prediction model is constructed to support potential error prediction, using historical test data to predict errors that may occur in future tests, such as predicting the time point when system performance degrades based on time series analysis.
[0165] In step 504, a second association relationship is determined; wherein the second association relationship is the association relationship between the error anomaly of the test result and the optimizable points of the software under test; based on the second association relationship, a recommended adjustment mode for the optimizable points is obtained.
[0166] The optimizable points may be system variables, test coverage, and code to be optimized.
[0167] In an optional embodiment, the optimization suggestion generation may be implemented in the following manner:
[0168] Step G1. Association analysis: Use association rule learning and other methods to build a second prediction model, and use the second prediction model to find out the second association relationship between the error and the system variable, such as the association between the configuration setting and the error occurrence.
[0169] Step G2. Decision support: Generate optimization suggestions based on model output, such as adjusting system configuration, increasing test coverage, optimizing specific module codes, etc., to prevent potential errors.
[0170] Step G3. Feedback loop: Apply optimization suggestions to the software development and testing process, and continuously collect feedback to iterate the model to improve prediction accuracy and effectiveness of suggestions.
[0171] In step 505, the test report is generated according to the test results and the corresponding error and abnormality conditions, error and abnormality predictions and the recommended adjustment mode.
[0172] In an optional embodiment, result analysis and feedback can be achieved in the following ways:
[0173] Step H1. Intelligent analysis: The central agent uses machine learning algorithms to analyze test data and identify abnormal patterns, such as frequently failing operation sequences.
[0174] Step H2. Potential error prediction: By comparing historical data with real-time data, predict possible problems, such as performance bottlenecks or instability of specific functions.
[0175] Step H3. Test report generation: Integrate the test results to generate a comprehensive test report containing pass / fail status, performance indicators, potential risks and optimization suggestions.
[0176] For example, after a regression test, the first prediction model analysis found that whenever the database query timed out, the user login function would fail. The recognition model learned this pattern through historical data and predicted through the second prediction model that under similar load conditions, if the database response time is extended again, login failure may occur again. Therefore, the central agent will recommend the development team to optimize the database query logic or adjust the database configuration to reduce query latency, thereby preventing possible login problems in future tests.
[0177] Through the close collaboration of multiple agents, the embodiment of the present invention forms a closed loop from requirement proposal to execution, monitoring, and result feedback in the entire testing process, which greatly improves the automation level and flexibility of the test and is particularly suitable for a fast-iterative software development environment.
[0178] Embodiment 3:
[0179] Based on Example 1 of the present invention, the event agent layer of the multi-agent system can also add test human-computer interaction agents, adaptive UI test agents and visual verification agents to further improve the automation level of software testing based on the multi-agent system.
[0180] Add a test human-computer interaction agent to provide a visual interface to display task planning and status, so that testers can monitor and intervene in the test process. Visual tools can help testers better understand the test progress and the working status of each agent. An optional implementation method of the test human-computer interaction agent is as follows:
[0181] Provide a web interface to implement interface display and communicate with the test agent through API. Testers can enter new test instructions, view test reports, adjust test parameters, and trigger specific test case execution. The web interface may include charts, detailed reports, and interactive controls to display the current test progress, including the test cases being executed and the test cases that have been executed.
[0182] Testers can manually trigger the re-run of specific test cases or adjust test parameters (for example, increase delay to simulate network latency) through the web interface, thereby supporting testers to manually intervene in automated testing.
[0183] After the test is completed, the tester can view a detailed test report on the web interface. The test report includes the test pass rate, failure cause analysis, and performance indicators.
[0184] In Web or mobile applications, for complex and changeable user interfaces (UI), UI elements often change frequently. Since developers often need to update UI elements, test scripts for automated testing need to be frequently maintained. In addition, users may interact with the UI in a variety of ways, such as touching, sliding, and clicking. When designing test cases, it is difficult to achieve ideal test case coverage.
[0185] In order to solve the above problems, an embodiment of the present invention provides an adaptive UI test agent, which uses a deep learning model (such as an image recognition model) to identify and track UI elements, and can maintain the stability of the test script even if the element ID or position changes. The adaptive UI test agent can simulate multiple user interactions, such as touch and slide, and generate diversified test cases.
[0186] Since manual testing is difficult to achieve automated visual verification, that is, it is impossible to ensure the visual consistency of the UI, such as color, layout, and font, the embodiment of the present invention provides a visual verification agent that uses computer vision technology to compare the expected visual state of the application with the actual state and detect subtle changes in the UI. The visual features of UI elements are learned and recognized by training models to ensure consistency.
[0187] Based on the above test agents, the multi-agent system of the embodiment of the present invention can not only solve the general problems of automated testing, but also provide more efficient solutions for specific scenarios (such as UI testing), thereby improving the coverage and reliability of automated testing.
[0188] Embodiment 4:
[0189] Based on Example 1, the embodiment of the present invention provides a partial specific implementation example of a method for automatically generating and executing a test script.
[0190] Among them, a specific example of the dynamic task scheduling algorithm is as follows:
[0191] defparse_natural_language_to_dsl(natural_language_instructions):#Use NLP to convert natural language instructions to DSL
[0192] parsed_instruction=NLP_parser(natural_language_instructions)
[0193] dsl_code=DSL_generator(parsed_instruction)
[0194] returndsl_code
[0195] NLP_parser = load_nlp_model() # Load the pre-trained NLP model
[0196] DSL_generator = load_dsl_translator() # Load DSL converter
[0197] Among them, a specific example of the data format conversion algorithm used by the test data conversion agent is as follows:
[0198] defconvert_to_structured_data(input_data):
[0199] #Convert descriptive information into structured data
[0200] structured_data=format_converter(input_data)
[0201] returnstructured_data
[0202] format_converter=create_format_converter()#Create a format converter instance
[0203] Among them, a specific example of the automated test script execution algorithm used by the test tool execution class agent is as follows:
[0204] defexecute_test_script(dsl_code):
[0205] #Execute DSL test script
[0206] test_environment.setup()
[0207] test_results=test_runner.run(dsl_code)
[0208] test_environment.teardown()
[0209] returntest_results
[0210] test_environment=create_test_environment()#Initialize the test environment
[0211] test_runner=create_test_runner()#Create a test executor
[0212] A specific example of the dynamic task scheduling algorithm used by the central agent is as follows:
[0213] #Task queue management and priority scheduling
[0214] defschedule_tasks(task_queue,new_task):
[0215] #Dynamically adjust the task queue and execution order according to the real-time environment task_queue.add_with_priority(new_task)
[0216] whilenottask_queue.is_empty():
[0217] current_task=task_queue.get_next_task()
[0218] execute_task(current_task)
[0219] return
[0220] task_queue=TaskQueue()#Create a task queue
[0221] A specific example of the intelligent result analysis algorithm used by the central agent is as follows:
[0222] #Machine Learning Classification and Pattern Recognition
[0223] defanalyze_test_result(test_results):
[0224] #Use machine learning algorithms to analyze test results
[0225] model=load_ml_model()#Load pre-trained machine learning model
[0226] predictions=model.predict(test_results)
[0227] analysis_report=generate_report(predictions)
[0228] returnanalysis_report
[0229] model=load_ml_model()#Load machine learning model
[0230] Embodiment 5:
[0231] like Fig. 9 , which is a schematic diagram of the architecture of the apparatus for automatically generating and executing test scripts according to an embodiment of the present invention. The apparatus for automatically generating and executing test scripts according to this embodiment includes one or more processors 21 and a memory 22. Fig. 9 A processor 21 is taken as an example.
[0232] The processor 21 and the memory 22 may be connected via a bus or other means. Fig. 9 The example of connecting through bus is taken in the following.
[0233] The memory 22 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs and non-volatile computer executable programs, such as the method for automatically generating and executing test scripts in this embodiment. The processor 21 executes the method for automatically generating and executing test scripts by running the non-volatile software programs and instructions stored in the memory 22.
[0234] The memory 22 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage devices. In some embodiments, the memory 22 may optionally include a memory remotely arranged relative to the processor 21, and these remote memories may be connected to the processor 21 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0235] The program instructions / modules are stored in the memory 22, and when executed by the one or more processors 21, the method of automatically generating and executing the test script in the above embodiment is executed, for example, the method described above is executed. Figure 1 and Figure 3-Figure 8 The steps shown.
[0236] An embodiment of the present invention further provides a non-volatile computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions are executed by one or more processors, such as Fig. 9A processor 21 can enable the above one or more processors to execute the method of automatically generating and executing test scripts in a specific embodiment of the present invention, for example, executing the above described Figure 1 and Figure 3-Figure 8 The steps shown can also be implemented Fig. 9 The various modules and units described above; or the method for automatically generating and executing test scripts in a specific embodiment of the present invention, for example, executing the above described Figure 1 and Figure 3-Figure 8 The steps shown can also be implemented Fig. 9 The various modules and units described.
[0237] It is worth noting that the information interaction, execution process, etc. between the modules and units within the above-mentioned devices and systems are based on the same concept as the processing method embodiment of the present invention. The specific contents can be found in the description of the method embodiment of the present invention and will not be repeated here.
[0238] A person skilled in the art may understand that all or part of the steps in the various methods of the embodiments may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the storage medium may include: a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.
[0239] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for automatically generating and executing test scripts, It is characterized in that In the process of testing the new version of the software to be tested, the central agent processes the output information of the test reasoning interpretation agent, the test data conversion agent and the test tool execution agent to schedule the test reasoning interpretation agent, the test data conversion agent and the test tool execution agent to complete the automatic generation and execution of the test script; The method for automatically generating and executing a test script comprises: The test reasoning and interpretation agent converts the test requirement text into an executable test script; the test data conversion agent converts the test scenario description into a structured test case; The central agent analyzes the instruction logic of the test script, generates at least one to-be-processed subtask and the dependency relationship between the at least one to-be-processed subtask according to the instruction logic; The central agent determines the target execution order of the at least one to-be-processed subtask according to the dependency relationship; The test tool execution class agent executes the corresponding test script according to the test case in accordance with the target execution order to obtain the test result, so as to realize automatic generation and execution of the test script; The test reasoning interpretation agent converts the test requirement text into an executable test script, including: performing data cleaning and formatting operations on the test requirement text to obtain requirement instructions; performing part-of-speech tagging on the vocabulary units in the requirement instructions to obtain intermediate instructions carrying part-of-speech tags; identifying at least one requirement entity in the intermediate instructions; when the part-of-speech tag corresponding to the requirement entity is a verb, determining the requirement entity as a test action; when the part-of-speech tag corresponding to the requirement entity is not a verb, determining the requirement entity as a key entity; performing structured processing on the test action and the corresponding key entity according to a preset format to obtain a corresponding internal representation; based on predefined rules, converting the internal representation into a corresponding test script; The test data conversion agent converts the test scenario description into a structured test case, including: extracting key objects and corresponding test values from the test scenario description, and organizing the key objects and corresponding test values into test cases according to preset structure conversion rules.
2. The method for automatically generating and executing test scripts according to claim 1, It is characterized in that The central agent determines the target execution order of the at least one to-be-processed subtask according to the dependency relationship, including: Initializing a task execution sequence; after generating a to-be-processed subtask according to the instruction logic, adding the generated to-be-processed subtask to the task execution sequence; Determine the priority of the subtasks to be processed in the task execution sequence according to the urgency and / or importance of the subtasks to be processed in the task execution sequence; dynamically adjust the arrangement order of the subtasks to be processed in the task execution sequence according to the corresponding priority and the dependency relationship, and determine the target execution order based on the dynamically adjusted arrangement order.
3. The method for automatically generating and executing test scripts according to claim 2, It is characterized in that When the urgency of the subtask to be processed exceeds a first preset value, an urgent test mark is added to the subtask to be processed; when the importance of the subtask to be processed exceeds a second preset value, an important test mark is added to the subtask to be processed; Determining the priority of the subtasks to be processed in the task execution sequence according to the urgency and / or importance of the subtasks to be processed in the task execution sequence; Dynamically adjusting the arrangement order of the subtasks to be processed in the task execution sequence according to the corresponding priorities and the dependency relationships, and determining the target execution order based on the dynamically adjusted arrangement order includes: When the subtask to be processed in the task execution sequence carries an urgent test mark and an important test mark, the corresponding subtask to be processed is determined as a first priority task; when the subtask to be processed in the task execution sequence only carries an urgent test mark, the corresponding subtask to be processed is determined as a second priority task; when the subtask to be processed in the task execution sequence only carries an important test mark, the corresponding subtask to be processed is determined as a third priority task; Based on the current system state, preferentially select a to-be-processed subtask from the first priority task, and adjust the position of the selected to-be-processed subtask in the task execution sequence so that it is close to the sequence head of the task execution sequence, and the selected to-be-processed subtask is located after the to-be-processed subtask on which it depends; When the current system state does not support the execution of any first priority task, the position of any first priority task cannot be adjusted according to the corresponding dependency relationship, and / or there is no first priority task in the task execution sequence, select a to-be-processed subtask from the second priority task, and adjust the position of the selected to-be-processed subtask in the task execution sequence so that it is close to the sequence head and the selected to-be-processed subtask is located after the to-be-processed subtask on which it depends; When the current system state does not support the execution of any second priority task, the position of any second priority task cannot be adjusted according to the corresponding dependency relationship, and / or there is no second priority task in the task execution sequence, select a to-be-processed subtask from the third priority task, adjust the position of the selected to-be-processed subtask in the task execution sequence so that it is close to the sequence head, and make the selected to-be-processed subtask located after the to-be-processed subtask on which it depends, so as to obtain the corresponding target execution order.
4. The method for automatically generating and executing test scripts according to claim 1, It is characterized in that The test tool execution class agent executes the corresponding test script according to the test case in the target execution order, and obtains the test results including: Acquire a test script from the test reasoning interpretation agent; acquire a test case from the test data conversion agent; wherein the test case includes a test object and a corresponding test object value, a test step and a corresponding test step value, an expected result and a corresponding success result value; Match the parameter name in the test script with the test object, and use the test object value corresponding to the test object as the input parameter corresponding to the parameter name; determine the test steps and expected results corresponding to the test object, execute the test script based on the input parameters according to the corresponding test step values, and obtain the test result based on the corresponding success result value.
5. The method for automatically generating and executing test scripts according to claim 1, It is characterized in that The central agent analyzes the test results to obtain corresponding error and abnormal conditions; Generate a test report for the task to be processed according to the error and abnormal situation; The method for automatically generating and executing a test script also includes: Extract at least one test indicator and corresponding indicator data from historical test data; Determine an initial recognition model for the test indicator; use the indicator data to train the initial recognition model, learn a first association relationship from the indicator data, and obtain a target recognition model based on the first association relationship; wherein the first association relationship is an association relationship between a test result and an error or abnormality; use the target recognition model to process the test result to obtain an error or abnormality of the test result; According to the test indicators and corresponding indicator data, corresponding error anomaly prediction is obtained; Determine a second association relationship; wherein the second association relationship is an association relationship between the error and abnormality of the test result and the optimizable points of the software to be tested; based on the second association relationship, obtain a recommended adjustment mode for the optimizable points; The test report is generated based on the test results and the corresponding error and abnormality conditions, error and abnormality predictions and the recommended adjustment mode.
6. A device for automatically generating and executing test scripts, It is characterized in that The device for automatically generating and executing test scripts includes at least one processor and a memory, and the at least one processor and the memory are connected via a data bus. The memory stores instructions that can be executed by the at least one processor. After being executed by the processor, the instructions are used to implement the method for automatically generating and executing test scripts described in any one of claims 1-5.
7. A non-volatile computer storage medium, It is characterized in that The computer storage medium stores computer executable instructions, and the computer executable instructions are executed by one or more processors to complete the method for automatically generating and executing test scripts as described in any one of claims 1-5.
Citation Information
Patent Citations
Test case execution path generation method and corresponding device
CN117149615A
Method and device for generating automated test case script and medium
CN117112408A
Software automation testing method, system and device
CN117421231A
