Automatic test code generation method and device, equipment and storage medium

By obtaining and converting users' manual-driven UI testing process and generating automated test codes, the problem of manual operation dependence during software testing is solved, and the testing efficiency and automation level are improved.

CN118964202AInactive Publication Date: 2024-11-15CHONGQING SELIS PHOENIX INTELLIGENT INNOVATION TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411114431.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-14
Publication Date
2024-11-15
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The software testing process is strongly dependent on user manual operations, which makes the testing process time-consuming and inefficient.

Method used

By obtaining the user's artificially driven UI testing process, generating test cases, and converting them into automated test code, using artificial intelligence models to identify and convert manual operation sequences to achieve automated testing.

Benefits of technology

It reduces the difficulty of automated testing, improves the efficiency of automated testing, reduces the need to manually write test code, and realizes the conversion from manual UI testing to automated UI testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118964202A_ABST
    Figure CN118964202A_ABST
Patent Text Reader

Abstract

The invention relates to an automatic test code generation method and device, equipment and a storage medium. The method comprises the steps of obtaining a manually driven UI test process of a user for a to-be-tested service; generating a test case corresponding to the to-be-tested service according to the manually-driven UI test process; and converting the test case into an automatic test code, wherein the automatic test code is used for carrying out automatic test on the to-be-tested business. Therefore, manual UI testing is converted into automatic UI testing, the difficulty of the automatic testing can be reduced, and the efficiency of the automatic testing is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of automated testing, and in particular to an automated testing code generation method, apparatus, device and storage medium. Background Art

[0002] Software testing is an important part of quality control in the software development process. Traditional software testing methods require manual writing of test cases and manual execution of the testing process, which is time-consuming and error-prone. In order to solve these problems, automated testing technology is widely used.

[0003] However, although there are some automated testing tools currently, users are still required to manually write test scripts, which results in the automated testing tools being unable to fundamentally solve the technical problem that software testing is highly dependent on user manual operations, resulting in a time-consuming and inefficient testing process. Summary of the invention

[0004] The present application provides an automated test code generation method, apparatus, device and storage medium to solve the technical problem in the prior art that the software testing process strongly relies on manual operation of the user, resulting in a time-consuming and inefficient testing process.

[0005] In a first aspect, the present application provides a method for generating automated test code, the method comprising:

[0006] Obtain the user's manually driven UI test process for the business to be tested;

[0007] Generate a test case corresponding to the business to be tested according to the manually driven UI test process;

[0008] The test case is converted into an automated test code, and the automated test code is used to perform automated testing on the service to be tested.

[0009] In a possible implementation, the step of obtaining a user's manually driven UI test process for the service to be tested includes:

[0010] Acquire screen recording data obtained by recording the screen during the user's manual UI test of the service to be tested;

[0011] The user's manually driven UI test process for the service to be tested is located from the screen recording data.

[0012] In a possible implementation, the step of obtaining a user's manually driven UI test process for the service to be tested includes:

[0013] Obtain the dynamic change process of the page during the user's manual UI test of the business to be tested;

[0014] The user's manually driven UI test process for the business to be tested is determined according to the dynamic change process of the page.

[0015] In a possible implementation manner, generating a test case corresponding to the service to be tested according to the manually driven UI test process includes:

[0016] Identify a manual operation sequence from the manual-driven UI test process;

[0017] generating a text description of the manual operation sequence;

[0018] Generate a test case corresponding to the business to be tested according to the text description.

[0019] In a possible implementation manner, generating a test case corresponding to the service to be tested according to the manually driven UI test process includes:

[0020] The manually driven UI test process is input into the trained artificial intelligence model, and the artificial intelligence model is used to execute the steps of identifying the manual operation sequence and subsequent steps from the manually driven UI test process to obtain the test case corresponding to the business to be tested output by the artificial intelligence model.

[0021] In a possible implementation, converting the test case into automated test code includes:

[0022] The test case is input into the artificial intelligence model to obtain the automated test code output by the artificial intelligence model.

[0023] In a possible implementation, the method further includes:

[0024] Obtaining UI test description information input by a user for the service to be tested, wherein the UI test description information includes one or more of the following: a test requirement document, test function points, test cases, and service description information of the service to be tested;

[0025] The UI test description information is input into the artificial intelligence model to obtain the automated test code output by the artificial intelligence model.

[0026] In a second aspect, the present application provides an automated test code generation device, the device comprising:

[0027] The manual test process acquisition module is used to obtain the user's manual driven UI test process for the business to be tested;

[0028] A test case generation module, used to generate a test case corresponding to the business to be tested according to the manually driven UI test process;

[0029] The test code generation module is used to convert the test case into an automated test code, and the automated test code is used to perform automated testing on the service to be tested.

[0030] In a possible implementation manner, the manual test process acquisition module is specifically used to:

[0031] Acquire screen recording data obtained by recording the screen during the user's manual UI test of the service to be tested;

[0032] The user's manually driven UI test process for the service to be tested is located from the screen recording data.

[0033] In a possible implementation manner, the manual test process acquisition module is specifically used to:

[0034] Obtain the dynamic change process of the page during the user's manual UI test of the business to be tested;

[0035] The user's manually driven UI test process for the business to be tested is determined according to the dynamic change process of the page.

[0036] In a possible implementation, the test case generation module includes:

[0037] A manual operation identification unit, used to identify a manual operation sequence from the manual drive UI test process;

[0038] A manual operation description unit, used to generate a text description of the manual operation sequence;

[0039] A test case generating unit is used to generate a test case corresponding to the service to be tested according to the text description.

[0040] In a possible implementation, the test case generation module is specifically used to:

[0041] The manually driven UI test process is input into the trained artificial intelligence model, and the artificial intelligence model is used to execute the steps of identifying the manual operation sequence and subsequent steps from the manually driven UI test process to obtain the test case corresponding to the business to be tested output by the artificial intelligence model.

[0042] In a possible implementation, the test code generation module is specifically used to:

[0043] The test case is input into the artificial intelligence model to obtain the automated test code output by the artificial intelligence model.

[0044] In a possible implementation manner, the test code generation module is further used to:

[0045] Obtaining UI test description information input by a user for the service to be tested, wherein the UI test description information includes one or more of the following: a test requirement document, test function points, test cases, and service description information of the service to be tested;

[0046] The UI test description information is input into the artificial intelligence model to obtain the automated test code output by the artificial intelligence model.

[0047] In a third aspect, the present application provides a device comprising: a processor and a memory, wherein the processor is used to execute an automated test code generation program stored in the memory to implement the automated test code generation method described in any one of the first aspects.

[0048] In a fourth aspect, the present application provides a storage medium storing one or more programs, wherein the one or more programs can be executed by one or more processors to implement the automated test code generation method described in any one of the first aspects.

[0049] The above-mentioned technical scheme provided by the embodiment of the present application has the following advantages over the prior art: the method provided by the embodiment of the present application, by obtaining the user's manually driven UI test process for the business to be tested, generates test cases corresponding to the business to be tested according to the manually driven UI test process, converts the test cases into automated test codes, and uses the automatically generated automated test codes to perform automated tests on the business to be tested, thereby realizing the conversion from manual UI testing to automated UI testing. In this technical scheme, the corresponding automated test codes are automatically generated through the manually driven UI test process, and the user does not need to manually write the automated test codes. Instead, the automated test codes are generated through intuitive interface operations, which can reduce the difficulty of automated testing and improve the efficiency of automated testing. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0051] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0052] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.

[0053] Figure 1 A flowchart of an embodiment of a method for generating automated test code provided in an embodiment of the present application;

[0054] Figure 2 It is a framework diagram of business system-business module-functional point;

[0055] Figure 3 A flowchart of another embodiment of a method for generating automated test code provided in an embodiment of the present application;

[0056] Figure 4 A flowchart of the artificial intelligence model training process provided in the embodiment of the present application;

[0057] Figure 5 A flowchart of another embodiment of an automated test code generation method provided in an embodiment of the present application;

[0058] Figure 6 A schematic diagram for automatically generating automated test codes based on an artificial intelligence model;

[0059] Figure 7 A block diagram of an embodiment of an automated test code generation device provided in an embodiment of the present application;

[0060] Figure 8 A schematic diagram of the structure of a device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0061] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0062] The disclosure below provides many different embodiments or examples to realize the different structures of the present application. In order to simplify the disclosure of the present application, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present application. In addition, the present application can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.

[0063] In order to solve the technical problem in the prior art that the software testing process is highly dependent on manual user operations, resulting in a time-consuming and inefficient testing process, the present application provides an automated test code generation method, apparatus, device and storage medium, which can realize the conversion from manual UI testing to automated UI testing, reduce the difficulty of automated testing, and improve the efficiency of automated testing.

[0064] Figure 1 The following is a flow chart of an embodiment of an automated test code generation method provided in the present application. Figure 1 As shown, the process includes the following steps:

[0065] Step 101: Obtain the user's manually driven UI test process for the business to be tested.

[0066] The above-mentioned service to be tested may be a certain function point in the service system, such as login, or a certain service module in the service system, such as user management, or a complete service system or software, such as a shopping mall system. The embodiment of the present application does not limit this.

[0067] Here, in order to facilitate the understanding of the relationship between the above-mentioned function points, business modules and business systems, the following diagram is shown: Figure 2 .like Figure 2 The figure shows a framework diagram of business system-business module-functional point. Figure 2 The business system shown in the figure includes two business modules, namely module 1 and module 2, wherein module 1 and module 2 each have two module functions, namely Figure 2 The module function 1 and module function 2 are shown in the example. Furthermore, different module functions include different function points, such as module function 1 under module 1 includes test function point 1, test function point 2, test function point 3, etc., module function 2 under module 1 includes test function point 1, test function point 2, etc., module function 1 under module 2 includes test function point 1, module function 2 under module 2 includes test function point 1, test function point 2, etc.

[0068] For example, the mall system includes the following functional modules: user management, product management, shopping cart and order management, payment and settlement, logistics management, promotion and marketing, and back-end data statistics and analysis. In addition, in addition to some basic modules in the mall system, the actual mall system may also include other customized functional modules, such as activity management, after-sales service, etc. The functional modules of the mall system can be customized and expanded according to specific business needs.

[0069] Different functional modules contain different functional points. For example, user management includes login and logout, adding users, editing users, deleting users, user details, user rights management, login and logout management and other functional points.

[0070] Manually driven UI testing process refers to the UI testing process for the business to be tested that is manually executed by the user, such as the user manually performing the login operation. The manually driven UI testing process includes but is not limited to: the operations performed by the user, the content of the inspection, the expected results, etc.

[0071] The above-mentioned users are not limited to professional testers, but may also be other personnel, such as product personnel. It can be seen that the application of the technical solution provided by the embodiment of the present application can reduce the difficulty of automated testing, so that non-professionals can also perform automated testing on the business to be tested.

[0072] In actual applications, users can manually execute the UI test process for the business to be tested according to specific test requirements, such as the function points or business processes to be tested, test scenarios, test data and other information. In the technical solution of the embodiment of the present application, the user's manually driven UI test process for the business to be tested will be recorded. As for how to record the user's manually driven UI test process for the business to be tested, it will be explained in the following through different embodiments, which will not be described in detail here.

[0073] Step 102: Generate test cases corresponding to the business to be tested according to the manually driven UI test process.

[0074] Step 103: Convert the test case into automated test code, which is used to perform automated testing on the business to be tested.

[0075] For ease of understanding, step 102 and step 103 are described in a unified manner as follows:

[0076] It can be seen from the description of step 102 and step 103 that the technical solution of the embodiment of the present application provides a process of converting from manual UI testing to automated UI testing. In this process, firstly, a test case corresponding to the business to be tested is generated according to the manually driven UI testing process, and then the test case is converted into automated testing code, so as to use the automated testing code to perform automated testing on the business to be tested.

[0077] Among them, by analyzing the user's manually driven UI test process for the business to be tested, the test points and scenarios therein are identified, and then the corresponding test cases are generated. For example, the business to be tested is login, and the test cases generated according to the user's manually driven UI test process for the login operation are shown in the following Table 1:

[0078] Table 1

[0079]

[0080]

[0081] As for how to generate test cases corresponding to the business to be tested according to the manually driven UI test process, it will be explained through specific embodiments below and will not be described in detail here.

[0082] In addition, in one embodiment, after generating test cases corresponding to the business to be tested according to the manually driven UI test process, the user can also review the automatically generated test cases and improve the automatically generated test cases based on the review results, such as modifying, deleting, adding, etc., to ensure the accuracy and completeness of the test cases.

[0083] Further, as described in step 103, the technical solution of the embodiment of the present application also converts the automatically generated test cases into automated test codes, which are used to perform automated tests on the business to be tested. In this way, there is no need for professional testers to manually write automated test codes, which can improve the efficiency of automated testing and reduce the difficulty and labor costs of automated testing.

[0084] Among them, when using automated test code to perform automated testing on the business to be tested, the automated test code is embedded in the automated test framework, and then the automated test code is run in the automated test framework to observe whether the test results meet expectations, and to locate and repair problems in a timely manner when they occur, thereby realizing automated testing of the business to be tested.

[0085] In addition, in one embodiment, after the automatically generated test cases are converted into automated test code, the user can also review the automatically generated automated test code and perform improvement operations on the automatically generated automated test code based on the review results, such as modification, deletion, addition, etc., to ensure the accuracy and completeness of the automated test code, thereby ensuring the accuracy and completeness of subsequent automated testing of the business to be tested using the automated test code.

[0086] In addition, in one embodiment, maintenance and updates can be performed based on the automatically generated test users and automated test codes as the version of the business to be tested is updated or the test requirements change. This can reduce the workload of automated testing of the business to be tested after the version is updated and improve the efficiency of automated testing.

[0087] The method provided in the embodiment of the present application obtains the user's manually driven UI test process for the business to be tested, generates test cases corresponding to the business to be tested according to the manually driven UI test process, converts the test cases into automated test codes, and uses the automatically generated automated test codes to perform automated tests on the business to be tested, thereby realizing the conversion from manual UI testing to automated UI testing. In this technical solution, the corresponding automated test codes are automatically generated through the manually driven UI test process, and the user does not need to manually write the automated test codes. Instead, the automated test codes are generated through intuitive interface operations, which can reduce the difficulty of automated testing and improve the efficiency of automated testing.

[0088] Figure 3 The following is a flow chart of another embodiment of the method for generating automated test code provided in the present application. Figure 3 As shown, the following steps are included:

[0089] Step 301: Acquire screen recording data obtained by recording the screen during the process of the user performing manual UI testing on the service to be tested, and locate the user's manually driven UI testing process for the service to be tested from the screen recording data.

[0090] In one embodiment, when the user performs manual UI testing on the service to be tested, a screen recording tool is started to record the screen, thereby obtaining screen recording data of the user performing manual UI testing on the service to be tested.

[0091] Among them, as an optional implementation method, the above-mentioned screen recording refers to recording the manual operations performed by the user during the manual UI test of the business to be tested through video. Accordingly, the above-mentioned screen recording data includes a video containing the manual operation process recorded by the user during the manual UI test of the business to be tested.

[0092] As another optional implementation, the screen recording refers to image recording, which only records the image changes of the screen during the user's manual UI test of the service to be tested. Accordingly, the screen recording data includes the image changes recorded during the user's manual UI test of the service to be tested.

[0093] Regardless of which of the above implementation methods is adopted, the user's manually driven UI test process for the business to be tested can be located from the screen recording data.

[0094] As an optional implementation method, the screen recording data is directly determined as a user's manually driven UI test process for the business to be tested.

[0095] As another optional implementation method, the start frame and the end frame of the manually driven UI test process are located from the screen recording data, and the screen recording data between the start frame and the end frame are determined as the user's manually driven UI test process for the business to be tested.

[0096] Step 302: input the manually driven UI test process into the trained artificial intelligence model, use the artificial intelligence model to identify the manual operation sequence from the manually driven UI test process, generate a text description of the manual operation sequence, and generate a test case corresponding to the business to be tested based on the text description.

[0097] As described in step 302, in one embodiment, the manually driven UI test process is input into a trained artificial intelligence model so that the artificial intelligence model automatically analyzes the manually driven UI test process and generates test cases corresponding to the business to be tested.

[0098] Among them, the main processing flow of the artificial intelligence model includes the following three steps:

[0099] Step 1: Identify the manual operation sequence from the manual-driven UI test process;

[0100] Step 2, generating a text description of the manual operation sequence;

[0101] Step 3: Generate test cases corresponding to the business to be tested based on the text description.

[0102] In the above step 1, the artificial intelligence model can convert the screen recording data into images, and identify the manual operation sequence therefrom through image processing technology. For example, the identified manual operation sequence includes: opening the login page, entering the user name and password, and clicking the login button.

[0103] In step 2 above, the artificial intelligence model can generate a text description of each manual operation in the manual operation sequence through intent recognition and natural language processing technology. For example, the text description of the manual operation "enter username and password" is generated as "enter username 123, enter password abc".

[0104] In the above step 3, the artificial intelligence model can generate test cases corresponding to the business to be tested through the trained function of automatically generating test cases based on text descriptions.

[0105] Step 303: input the test case into the above-mentioned artificial intelligence model to obtain the automated test code output by the artificial intelligence model.

[0106] As described in step 303, the above-mentioned trained artificial intelligence model also has the function of automatically generating corresponding automated test code according to the test case. Therefore, in actual applications, the manually driven UI test process is input into the trained artificial intelligence model, and the automated test code output by the artificial intelligence model can be directly obtained. This realizes the transformation from manual UI testing to automated UI testing in one go, and further improves the efficiency of automated testing.

[0107] The general process of converting test cases into automated test codes by the artificial intelligence model includes: the artificial intelligence model analyzes the text description of the test case, identifies the operations and expected results, and generates the corresponding automated test code accordingly. For example, if the text description of the test case is "click the login button", the artificial intelligence model will split it into: the action "login" (click) and the page element "login button" (find_element(By.NAME,"login")), and then output the corresponding automated operation code according to the split result.

[0108] The following describes the training process of the AI ​​model, which is divided into four parts:

[0109] Part 1: Business model framework building training

[0110] This part of the training process aims to enable the artificial intelligence model to automatically build a business module framework.

[0111] Specifically, the business model framework building capability of the artificial intelligence model is trained according to the system-module-function-function point hierarchy. Through this capability training, when the user gives a requirement document or requirement description, the artificial intelligence model can extract the key information and automatically build the business model framework of the system-module-function-function point, for example Figure 2 shown.

[0112] During the training process, the existing business model framework is used as training data for training. For example, the mall system includes the following functional modules: user management, product management, shopping cart and order management, payment and settlement, logistics management, promotion and marketing, and background data statistics and analysis. In addition to some basic modules in the mall system, the actual mall system may also include other customized functional modules, such as activity management, after-sales service, etc. According to specific business needs, the modules of the mall system can be customized and expanded. Different functional modules contain different functional points. For example, user management includes login and logout, adding users, editing users, deleting users, user details, user permission management, login and logout management, etc.

[0113] Part 2: Function point and test case association training

[0114] This part of the training process aims to enable the artificial intelligence model to automatically generate test cases given a function point description.

[0115] For example, when a user inputs the function point description "login", the artificial intelligence model can output a test case as shown in Table 1 above.

[0116] Part 3: Automated Test Code Generation Training

[0117] This part of the training process aims to enable the artificial intelligence model to automatically generate automated test code given a test case.

[0118] The automated test code includes two key parts: UI positioning code and interface operation code. Therefore, the training process of this part includes two parts of training:

[0119] 1. UI Automation Training

[0120] Step a, page element marking: marking each page element of the existing application, such as a button, an input box, a drop-down menu, etc.

[0121] Step b, constructing a training data set: Matching the page element tags with the text descriptions of the page elements, and forming a training data set, the training data uses the text descriptions of the page elements as input and the page element tags as the desired output. It can be understood that the page element location code can be obtained through the page element tags.

[0122] Step c, training model: Use a suitable algorithm to train the model on the training data set to generate an artificial intelligence model that can generate positioning codes for page elements based on text descriptions.

[0123] Through the above training process, it is possible to use the page code as the basic input and provide the desired page element (such as the login button) as the required input to the artificial intelligence model. The artificial intelligence model can then automatically identify the location code of the corresponding page element (such as the login button) from the page code (such as find_element(By.NAME,"login")).

[0124] 2. Interface automation training

[0125] Step a: Collect a large number of interface automation test code examples. These examples may include the code of API testing frameworks (such as Postman, RestAssured, Requests, etc.).

[0126] Step b, constructing a training data set: matching the interface automation test code examples collected above with the corresponding text descriptions to form a training data set. The training data takes the text description as input and the interface automation test code as the expected output.

[0127] Step c, training model: Use a suitable algorithm to train the model on the training data set to generate an artificial intelligence model that can generate interface automation test code based on text descriptions.

[0128] Through the above training process, it is possible to use the interface information as the basic input and provide the desired interface operation as the demand input to the artificial intelligence model, and the artificial intelligence model will output the corresponding interface operation code based on the interface information.

[0129] Part 4: Model Optimization

[0130] In practical applications, the trained artificial intelligence model can be optimized from the following two perspectives:

[0131] 1. Business model optimization

[0132] The business model framework generated by the artificial intelligence model is verified. If it does not meet the requirements, the artificial intelligence model is retrained and optimized so that the output of the artificial intelligence model meets user needs.

[0133] 2. Function point test case optimization

[0134] The test cases generated by the AI ​​model are verified. If they do not meet the requirements, the AI ​​model is trained and optimized again so that the output of the AI ​​model meets user needs.

[0135] See also Figure 4 , which is a flow chart of the artificial intelligence model training process provided in an embodiment of the present application.

[0136] Figure 3 The process shown obtains the screen recording data obtained by recording the screen when the user performs manual UI testing on the business to be tested, locates the user's manually driven UI test process for the business to be tested from the screen recording data, inputs the manually driven UI test process into the trained artificial intelligence model, uses the artificial intelligence model to identify the manual operation sequence from the manually driven UI test process, generates a text description of the manual operation sequence, and generates test cases corresponding to the business to be tested based on the text description, and then generates automated test code based on the test cases, thereby realizing the acquisition of the user's manually driven UI test process by screen recording, and using the artificial intelligence model to seamlessly convert manual UI testing into automated UI testing, thereby reducing the difficulty of automated testing and improving the efficiency of automated testing.

[0137] Figure 5 The following is a flow chart of another embodiment of an automated test code generation method provided in the present application. Figure 5 As shown, the following steps are included:

[0138] Step 501: Obtain the dynamic change process of the page during the manual UI test of the service to be tested by the user, and determine the manual driven UI test flow of the user for the service to be tested according to the dynamic change process of the page.

[0139] When the user performs manual UI testing, new changes to the page or changes in the page address will occur as the page is manually operated. For example, when the user manually performs a login operation, when the user enters the user name and password in the user input box and the password input box, two input information will be added to the page, and then when the user clicks the login button, the page will trigger a response request and the page address will change or the page will be updated (the page elements will change). Therefore, the user's manual operation can be analyzed through the changes in the page, including which page elements the user operates and the interface operations triggered. Therefore, in one embodiment, the dynamic change process of the page during the user's manual UI testing of the business to be tested is obtained, and the user's manually driven UI test process for the business to be tested is determined according to the dynamic change process of the page. The dynamic change process of the page mentioned here includes the page changes described above and changes such as the page address.

[0140] In practical applications, a page information collection tool can be used to collect the page dynamic changes mentioned above during the user's manual UI test of the service to be tested. As for which page information collection tool is specifically used, the embodiment of the present application does not limit this.

[0141] Step 502: input the manually driven UI test process into the trained artificial intelligence model, use the artificial intelligence model to identify the manual operation sequence from the manually driven UI test process, generate a text description of the manual operation sequence, and generate a test case corresponding to the business to be tested based on the text description.

[0142] Step 503: Input the test case into the above-mentioned artificial intelligence model to obtain the automated test code output by the artificial intelligence model.

[0143] pass Figure 3 From the relevant description of the artificial intelligence model in the shown process, it can be seen that the artificial intelligence model trained in the technical solution provided in the embodiment of the present application can identify the user's manual operation sequence by analyzing page changes, and because the page elements and text descriptions have been trained accordingly, the user's manual operations can be directly converted into corresponding automated test codes.

[0144] As for the training process of the artificial intelligence model, please refer to the above Figure 3 The relevant descriptions in the process shown will not be repeated here.

[0145] Figure 5 The process shown in FIG. 1 obtains the dynamic change process of the page when the user performs manual UI testing on the business to be tested, determines the user's manually driven UI test process for the business to be tested based on the dynamic change process of the page, inputs the manually driven UI test process into the trained artificial intelligence model, and uses the artificial intelligence model to identify the manual operation sequence from the manually driven UI test process, generates a text description of the manual operation sequence, and generates test cases corresponding to the business to be tested based on the text description, and then generates automated test code based on the test cases. This realizes the acquisition of the user's manually driven UI test process by collecting dynamic changes in the page, and uses the artificial intelligence model to seamlessly transform manual UI testing into automated UI testing, thereby reducing the difficulty of automated testing and improving the efficiency of automated testing.

[0146] Based on the above description, in one embodiment, the technical solution provided by the embodiment of the present application also includes the following steps: obtaining UI test description information input by the user for the business to be tested, the UI test description information including one or more of the following: test requirement documents, test function points, test cases, and business description information of the business to be tested; inputting the UI test description information into the artificial intelligence model to obtain the automated test code output by the artificial intelligence model.

[0147] pass Figure 3 From the description of the artificial intelligence model in the process shown, it can be seen that the artificial intelligence model trained in the technical solution of the embodiment of the present application has the ability to automatically build a business module framework, the ability to automatically generate test cases given a function point description, and the ability to automatically generate automated test code given a test case. Therefore, in actual applications, when the artificial intelligence model is input with information of any level in the test requirement document, test function points, test cases, and business description information of the business to be tested, and the page code of the business to be tested is given at the same time, the corresponding automated test code can be automatically generated.

[0148] See also Figure 6 , which is a schematic diagram of automatically generating automated test code based on artificial intelligence models.

[0149] The technical solution provided in the embodiment of the present application can realize automatic generation of automated test code in each test link, thereby improving the efficiency of automated testing and enhancing the degree of automation of testing.

[0150] Figure 7 This is a block diagram of an embodiment of an automated test code generation device provided in an embodiment of the present application. Figure 7As shown, the device comprises:

[0151] The manual test process acquisition module 71 is used to obtain the user's manual driven UI test process for the business to be tested;

[0152] A test case generation module 72, used to generate a test case corresponding to the business to be tested according to the manually driven UI test process;

[0153] The test code generation module 73 is used to convert the test case into an automated test code, and the automated test code is used to perform automated testing on the service to be tested.

[0154] In a possible implementation manner, the manual test process acquisition module 71 is specifically used to:

[0155] Acquire screen recording data obtained by recording the screen during the user's manual UI test of the service to be tested;

[0156] The user's manually driven UI test process for the service to be tested is located from the screen recording data.

[0157] In a possible implementation manner, the manual test process acquisition module 71 is specifically used to:

[0158] Obtain the dynamic change process of the page during the user's manual UI test of the business to be tested;

[0159] The user's manually driven UI test process for the business to be tested is determined according to the dynamic change process of the page.

[0160] In a possible implementation, the test case generation module 72 includes:

[0161] A manual operation identification unit, used to identify a manual operation sequence from the manual drive UI test process;

[0162] A manual operation description unit, used to generate a text description of the manual operation sequence;

[0163] A test case generating unit is used to generate a test case corresponding to the service to be tested according to the text description.

[0164] In a possible implementation, the test case generation module 72 is specifically configured to:

[0165] The manually driven UI test process is input into the trained artificial intelligence model, and the artificial intelligence model is used to execute the steps of identifying the manual operation sequence and subsequent steps from the manually driven UI test process to obtain the test case corresponding to the business to be tested output by the artificial intelligence model.

[0166] In a possible implementation manner, the test code generation module 73 is specifically used to:

[0167] The test case is input into the artificial intelligence model to obtain the automated test code output by the artificial intelligence model.

[0168] In a possible implementation manner, the test code generation module 73 is further used to:

[0169] Obtaining UI test description information input by a user for the service to be tested, wherein the UI test description information includes one or more of the following: a test requirement document, test function points, test cases, and service description information of the service to be tested;

[0170] The UI test description information is input into the artificial intelligence model to obtain the automated test code output by the artificial intelligence model.

[0171] like Figure 8 As shown, an embodiment of the present application provides a device, including a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.

[0172] Memory 113, used for storing computer programs;

[0173] In one embodiment of the present application, the processor 111 is used to execute the program stored in the memory 113 to implement the automatic test code generation method provided by any of the above method embodiments, including:

[0174] Obtain the user's manually driven UI test process for the business to be tested;

[0175] Generate a test case corresponding to the business to be tested according to the manually driven UI test process;

[0176] The test case is converted into an automated test code, and the automated test code is used to perform automated testing on the service to be tested.

[0177] An embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the automated test code generation method provided in any of the aforementioned method embodiments are implemented.

[0178] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0179] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0180] It should be understood that the terms used herein are only for the purpose of describing specific example embodiments and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used herein may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.

[0181] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest range consistent with the principles and novel features applied for herein.

Claims

1. A method for generating automated test code, characterized in that: The method comprises: Obtain the user's manually driven UI test process for the business to be tested; Generate a test case corresponding to the business to be tested according to the manually driven UI test process; The test case is converted into an automated test code, and the automated test code is used to perform automated testing on the service to be tested.

2. The method according to claim 1, characterized in that The process of obtaining a user's manually driven UI test for the service to be tested includes: Acquire screen recording data obtained by recording the screen during the user's manual UI test of the service to be tested; The user's manually driven UI test process for the service to be tested is located from the screen recording data.

3. The method according to claim 1, characterized in that The process of obtaining a user's manually driven UI test for the service to be tested includes: Obtain the dynamic change process of the page during the user's manual UI test of the business to be tested; The user's manually driven UI test process for the business to be tested is determined according to the dynamic change process of the page.

4. The method according to any one of claims 1 to 3, characterized in that: Generating a test case corresponding to the business to be tested according to the manually driven UI test process includes: Identify a manual operation sequence from the manual-driven UI test process; generating a text description of the manual operation sequence; Generate a test case corresponding to the business to be tested according to the text description.

5. The method according to claim 4, characterized in that Generating a test case corresponding to the business to be tested according to the manually driven UI test process includes: The manually driven UI test process is input into the trained artificial intelligence model, and the artificial intelligence model is used to execute the steps of identifying the manual operation sequence and subsequent steps from the manually driven UI test process to obtain the test case corresponding to the business to be tested output by the artificial intelligence model.

6. The method according to claim 5, characterized in that The step of converting the test case into automated test code comprises: The test case is input into the artificial intelligence model to obtain the automated test code output by the artificial intelligence model.

7. The method according to claim 5, characterized in that The method further comprises: Obtaining UI test description information input by a user for the service to be tested, wherein the UI test description information includes one or more of the following: a test requirement document, test function points, test cases, and service description information of the service to be tested; The UI test description information is input into the artificial intelligence model to obtain the automated test code output by the artificial intelligence model.

8. An automated test code generation device, characterized in that: The device comprises: The manual test process acquisition module is used to obtain the user's manual driven UI test process for the business to be tested; A test case generation module, used to generate a test case corresponding to the business to be tested according to the manually driven UI test process; The test code generation module is used to convert the test case into an automated test code, and the automated test code is used to perform automated testing on the service to be tested.

9. A device, characterized in that: include: A processor and a memory, wherein the processor is used to execute an automated test code generation program stored in the memory to implement the automated test code generation method according to any one of claims 1 to 7.

10. A storage medium, characterized in that: The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the automatic test code generation method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Test code generation method and device, electronic equipment and storage medium

    CN117033204A

  • Test code generation method and device, equipment and storage medium

    CN117632710A

  • Method and device for generating UI automatic test script and medium

    CN118170686A

  • Method and system for automated user interface (UI) testing through model driven techniques

    US20170277624A1