Test case and automatic script generation method and device, equipment and readable storage medium
Through extraction and generation of model technology, automated test cases and scripts are generated directly from UI requirements documents, solving the problems of high maintenance cost, low stability and low reuse rate of UI automation test scripts in the existing technology, and achieving high efficiency, Accurate test cases and script generation.
Patent Information
- Application Number
- CN202411138458.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-19
- Publication Date
- 2024-12-06
AI Technical Summary
The existing UI automation test script writing methods have problems such as high maintenance costs, long time, standardization, low packaging, poor stability and low reuse rate. Especially in the process of page element detection and extraction, there are high labor costs and complexity. Problems that lead to inaccurate information.
By extracting the key information of the original requirements document of the current page, including keyword information and business scenario information, inputting it into the preset test case generation model, generating initial test case data, and generating tests in template format through overtest test case generation model Use case copy, and finally generates automated scripts based on page element information, directly generates test cases and scripts from the requirements document to realize automation related tests.
It realizes the effect of accurately generating test cases and automated scripts, reduces labor costs and complexity, improves script normativeness and stability, improves reuse rate, and solves the inaccuracy and complexity of generating scripts in the existing technology. Sexual problems.
Smart Images

Figure CN119088687A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of automated testing, and in particular, to a method, apparatus, device and readable storage medium for generating test cases and automated scripts. Background Art
[0002] At present, automated testing has been widely used in all aspects of testing. There are two main ways to write existing UI automated test scripts. One is to write them manually, which has high maintenance costs and takes a long time to write scripts. The other is to provide a recording tool for testers to record the functional operations and generate corresponding scripts. The scripts generated by this method are not standardized and encapsulated, have poor stability, and have a low reuse rate.
[0003] Page element detection and extraction are performed through existing scripts, and the obtained element information is analyzed to finally obtain an automated script. In the process of obtaining the page script, there are labor costs and an assessment of the complexity of the acquisition. If the acquisition difficulty is too great, it will lead to inaccurate information, which will affect subsequent related work.
[0004] Therefore, how to accurately generate test cases and scripts is a technical problem that needs to be solved. Summary of the invention
[0005] The purpose of the embodiments of the present application is to provide a method for generating test cases and automated scripts. The technical solution of the embodiments of the present application can achieve the effect of accurately generating test cases and scripts.
[0006] In the first aspect, an embodiment of the present application provides a method for generating test cases and automated scripts, including extracting key information of the original requirement document of the current page, wherein the key information includes: keyword information and business scenario information; inputting the key information into a preset initial test case generation model to obtain initial test case data, wherein the initial test case data includes the relationship between the keyword information and the business scenario information; inputting the initial test case data into a preset transition test case generation model to obtain a test case text in a preset template format; inputting the keywords in the test case text in the preset template format and the page element information of the current page into the preset test case generation model to obtain a test case and a corresponding test script.
[0007] In the above-mentioned embodiment of the present application, the original requirement document of the design page is input into the model to generate an initial test case, and then the initial test case is input into the model to continue to generate a reliable test case text, and the keywords of the reliable test case text are extracted, and the keywords are combined with the interface element information and input into the final test case model, and the corresponding automation script can be generated to perform automation-related tests. This method does not generate automation scripts through existing scripts, but directly generates test cases through the original requirement document, and matches the generated test cases and element information with the business scenario to finally obtain an executable automation script. This method can achieve the effect of accurately generating test cases and automation scripts.
[0008] In some embodiments, before extracting the key information of the original requirement document of the current page, it also includes: obtaining key information samples corresponding to the historical page requirement document set, wherein the key information samples include: keyword information samples and business scenario information samples; training the initial test case generation model through the key information samples; inputting the key information samples into the initial test case generation model to obtain the initial test case samples, wherein the initial test case samples include the relationship between the information in the keyword information samples and the business scenario information samples; training the transition test case generation model through the initial test case samples; inputting the initial test case samples into the transition test case generation model to obtain the test case copy samples in the preset template format; training the test case generation model through the keywords in the test case copy samples and the corresponding page element samples.
[0009] In the above-mentioned embodiment of the present application, the initial test case generation model is trained by the key information in the original requirement document generated when the page is generated historically, and the obtained initial test case sample is used to train the transition test case generation model. At the same time, the keywords in the obtained test case copy sample are combined with the page elements to train the test case generation model. Through the test case generation model, the corresponding automation script can be directly generated through the original requirement document to perform automation-related tests.
[0010] In some embodiments, training an over-test case generation model through initial test case samples includes: preprocessing the initial test case samples to obtain processed initial test case samples, wherein the preprocessing method includes: at least one of cleaning, screening, adding, deleting and modifying; training an over-test case generation model through the processed initial test case samples.
[0011] In the above-mentioned embodiments of the present application, relevant data preprocessing work is performed on the initial test case samples to accurately train and obtain the transition test case generation model, thereby improving the accuracy of the automation script generated by the final test case generation model.
[0012] In some embodiments, an initial test case generation model is trained using key information samples, including: labeling information relationships between keyword information samples and business scenario information samples, wherein the information relationship represents the relationship between keyword information and business scenario information; inputting the key information samples into a basic initial test case generation model to obtain initial test case generation data; and adjusting parameters of the basic initial test case generation model by comparing the initial test case generation data with the information relationship to obtain an initial test case generation model.
[0013] In the above embodiments of the present application, an initial test case generation model can be trained through keyword information samples and business scenario information samples, thereby achieving the effect of directly processing the requirement document without having to generate test cases through scripts as in the prior art.
[0014] In some embodiments, an over-test case generation model is trained using an initial test case sample, including: filling in information in the initial test case sample according to a preset template format to obtain a standard test case copy; inputting the initial test case sample into a basic over-test case model to obtain copy data; and adjusting the parameters of the basic over-test case model by comparing the standard test case copy and the copy data to obtain an over-test case generation model.
[0015] In the above-mentioned embodiments of the present application, by comparing the test case text obtained by the over-test case model with the standard test case text, the over-test case model can be debugged and trained to obtain a final and accurate over-test case model.
[0016] In some embodiments, a test case generation model is trained using keywords in a test case text sample and corresponding page element samples, including: manually editing a standard test case and a corresponding script for the current page; inputting keywords in the test case text sample and corresponding page element samples into a basic test case generation model to obtain an initial test case and a corresponding script; and adjusting the basic test case generation model to obtain a test case generation model by comparing the initial test case and the corresponding script with the standard test case and the corresponding script.
[0017] In the above embodiments of the present application, manually edited page scripts and page test cases can be compared with page scripts and page test cases generated by a test case generation model, and then the test case generation model can be debugged and trained to improve the accuracy of the test case generation model.
[0018] In some embodiments, a test case generation model includes: a large model infrastructure, a custom test case generation layer, and a decoder.
[0019] In the above-mentioned embodiments of the present application, the effect of generating test cases can be achieved through the structure of the test case generation model set by the present application.
[0020] In some embodiments, the initial test case generation model, the excessive test case generation model, and the test case generation model are learned by supervised learning or unsupervised learning.
[0021] In the above embodiments of the present application, the test case generation model can be trained by supervised learning or unsupervised learning, so that the test case generation model can generate test cases for pages according to the requirement document.
[0022] In some embodiments, after inputting the keywords in the test case text in a preset template format and the page element information of the current page into a preset test case generation model to obtain the test case and the corresponding test script, it also includes: editing the test case through the test script to generate an executable test case; executing the executable test case to generate a page.
[0023] In the above-mentioned embodiments of the present application, corresponding pages can be directly generated through the generated test cases and scripts, thereby achieving the effect of page design.
[0024] In a second aspect, an embodiment of the present application provides a device for generating test cases and automated scripts, including:
[0025] An extraction module is used to extract key information of the original requirement document of the current page, wherein the key information includes keyword information and business scenario information;
[0026] A first generation module is used to input key information into a preset initial test case generation model to obtain initial test case data, wherein the initial test case data includes a relationship between keyword information and business scenario information;
[0027] The second generation module is used to input the initial test case data into a preset transition test case generation model to obtain a test case text in a preset template format;
[0028] The third generation module is used to input the keywords in the test case text in the preset template format and the page element information of the current page into the preset test case generation model to obtain the test case and the corresponding test script.
[0029] Optionally, the device further comprises:
[0030] A training module, used for the extraction module to obtain key information samples corresponding to the historical page requirement document set before extracting the key information of the original requirement document of the current page, wherein the key information samples include: keyword information samples and business scenario information samples;
[0031] The initial test case generation model is trained by using key information samples;
[0032] Inputting the key information sample into the initial test case generation model to obtain the initial test case sample, wherein the initial test case sample includes the relationship between the information in the keyword information sample and the business scenario information sample;
[0033] Train the over-test case generation model with the initial test case sample;
[0034] Input the initial test case sample into the transition test case generation model to obtain a test case copy sample in a preset template format;
[0035] The test case generation model is trained through the keywords in the test case copy samples and the corresponding page element samples.
[0036] Optionally, the training module is specifically used to:
[0037] Preprocessing the initial test case sample to obtain a processed initial test case sample, wherein the preprocessing method includes: at least one of cleaning, screening, adding, deleting and modifying;
[0038] The overtest case generation model is trained by the processed initial test case samples.
[0039] Optionally, the training module is specifically used to:
[0040] Annotating information relationships between keyword information samples and business scenario information samples, wherein the information relationship represents a relationship between keyword information and business scenario information;
[0041] Input key information samples into the basic initial test case generation model to obtain initial test case generation data;
[0042] By comparing the initial test case generation data and information relationship, the parameters of the basic initial test case generation model are adjusted to obtain the initial test case generation model.
[0043] Optionally, the training module is specifically used to:
[0044] Fill in the information in the initial test case sample according to the preset template format to obtain a standard test case copy;
[0045] Input the initial test case sample into the basic over-test case model to obtain copy data;
[0046] By comparing the standard test case text and text data, the parameters of the basic over-test case model are adjusted to obtain the over-test case generation model.
[0047] Optionally, the training module is specifically used to:
[0048] Manually edit the standard test cases and corresponding scripts of the current page;
[0049] Input the keywords and corresponding page element samples in the test case copy sample into the basic test case generation model to obtain the initial test case and corresponding script;
[0050] By comparing the initial test cases and corresponding scripts with the standard test cases and corresponding scripts, the basic test case generation model is adjusted to obtain the test case generation model.
[0051] Optional, test case generation model, including:
[0052] Large model infrastructure, custom test case generation layer, and decoder.
[0053] Optionally, the initial test case generation model, the excessive test case generation model and the test case generation model are learned by supervised learning or unsupervised learning.
[0054] Optionally, the device further comprises:
[0055] A generation module, which is used for the third generation module to input the keywords in the test case text in the preset template format and the page element information of the current page into the preset test case generation model, obtain the test case and the corresponding test script, edit the test case through the test script, and generate an executable test case;
[0056] Execute executable test cases and generate pages.
[0057] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the steps in the method provided in the first aspect are performed.
[0058] In a fourth aspect, an embodiment of the present application provides a readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps in the method provided in the first aspect are performed.
[0059] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the embodiments of the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0061] Figure 1 A flowchart of a method for generating a test case and an automated script provided in an embodiment of the present application;
[0062] Figure 2 A flowchart of an implementation method for generating a test case and an automated script and training a test case generation model provided in an embodiment of the present application;
[0063] Figure 3 A schematic block diagram of a device for generating test cases and automated scripts provided in an embodiment of the present application;
[0064] Figure 4 A schematic diagram of the structure of a device for generating test cases and automated scripts provided in an embodiment of the present application. DETAILED DESCRIPTION
[0065] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application usually described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0066] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0067] First, some terms involved in the embodiments of the present application are explained to facilitate understanding by those skilled in the art.
[0068] User Interface refers to the overall design of the software's human-computer interaction, operating logic, and aesthetic interface. A good UI design not only makes the software personalized and tasteful, but also makes the software's operation comfortable, simple, and free, fully reflecting the software's positioning and characteristics.
[0069] Artificial Intelligence Generated Content is an important sign that the AI 1.0 era has entered the 2.0 era.
[0070] BERT is a pre-trained language model, the full name of which is Bidirectional Encoder Representations from Transformers, a deep learning model built on the Transformer architecture. BERT learns deep bidirectional representations of language by pre-training on large-scale text data, and then fine-tunes it for different natural language processing (NLP) tasks.
[0071] The GPT-4 model is a highly anticipated pre-trained language model. It is the latest version of the GPT series of models, the fourth generation of pre-trained language model, and is recognized as one of the most powerful language models currently available.
[0072] AIGC refers to content automatically created by AI, which can be image-generated images or image-generated text. For example, given a picture, AIGC technology can generate a text description of the content of the picture: (The model first extracts image features through CNN, and then generates text descriptions related to the image content through a language model.)
[0073] This application is applied to the scenario of automated testing. The specific scenario is to process the original requirement document of the UI interface through multiple models and generate product processing. The corresponding test cases can be directly generated, and the UI page can be quickly generated by executing the corresponding scripts.
[0074] At present, automated testing has been widely used in all aspects of testing. There are two main ways to write existing UI automated test scripts. One is to write them manually, which has high maintenance costs and takes a long time to write scripts. The other is to provide a recording tool, where the tester records the function operation once to generate the corresponding script. The script generated by this method is not standardized and encapsulated, has poor script stability, and has a low reuse rate. The page element detection and extraction is performed through the existing script, and the obtained element information is analyzed to finally obtain the automated script. In the process of obtaining the page script, there are labor costs and an assessment of the complexity of the acquisition. If the acquisition difficulty is too great, the information will be inaccurate, which will affect subsequent related work.
[0075] For this purpose, the present application extracts the key information of the original requirement document of the current page, wherein the key information includes: keyword information and business scenario information; inputs the key information into the preset initial test case generation model to obtain the initial test case data, wherein the initial test case data includes the relationship between the keyword information and the business scenario information; inputs the initial test case data into the preset transition test case generation model to obtain the test case text in the preset template format; inputs the keywords in the test case text in the preset template format and the page element information of the current page into the preset test case generation model to obtain the test case and the corresponding test script. The original requirement document of the design page is input into the model to generate the initial test case, and then the initial test case is input into the model to continue to generate a reliable test case text, the keywords of the reliable test case text are extracted, and the keywords are combined with the interface element information into the final test case model, and the corresponding automation script can be generated to perform automation related tests. This method does not generate the automation script through the existing script, but directly generates the test case through the original requirement document, and matches the generated test case and element information with the business scenario to finally obtain an executable automation script. This method can achieve the effect of accurately generating test cases and automation scripts.
[0076] In the embodiment of the present application, the execution subject can be a test case and script generating device in a test case and script generating system. In actual applications, the test case and script generating device can be an electronic device such as a terminal device and a server, which is not limited here.
[0077] Combine the following Figure 1 The method for generating test cases and automation scripts of the embodiments of the present application is described in detail.
[0078] Please see Figure 1 , Figure 1 A flowchart of a method for generating a test case and an automated script provided in an embodiment of the present application, such as Figure 1 The test case and automation script generation method shown includes:
[0079] Step 110: Extract key information of the original requirement document of the current page.
[0080] Among them, key information includes; keyword information and business scenario information. Keyword information includes keywords, key words, key phrases and key sentences. Business scenario information includes the name, type and scenario content of the business scenario. The current page can be the UI interface to be designed, and the original requirement document can be the requirement document generated when editing or modifying the current page. The requirement document includes a variety of product requirements, such as page size, layout and specific content. The requirement document is generally text content. When it is a document combining text and images, the graphics can be converted into text through AIGC technology. The text content is used to describe the functions, requirements and stories of the system.
[0081] In some embodiments of the present application, before extracting the key information of the original requirement document of the current page, it also includes: obtaining key information samples corresponding to the historical page requirement document set, wherein the key information samples include: keyword information samples and business scenario information samples; training the initial test case generation model through the key information samples; inputting the key information samples into the initial test case generation model to obtain the initial test case samples, wherein the initial test case samples include the relationship between the information in the keyword information samples and the business scenario information samples; training the transition test case generation model through the initial test case samples; inputting the initial test case samples into the transition test case generation model to obtain the test case copy samples in the preset template format; training the test case generation model through the keywords in the test case copy samples and the corresponding page element samples.
[0082] In the above process, the present application trains the initial test case generation model through the key information in the original requirement document generated when the page is generated historically, and uses the obtained initial test case samples to train the transition test case generation model. At the same time, the keywords in the obtained test case copy samples are combined with page elements to train the test case generation model. Through the test case generation model, the corresponding automation script can be directly generated through the original requirement document to perform automation-related tests.
[0083] Among them, the historical page requirement document set includes historical requirement documents of different UI interfaces. The key information sample includes the relationship between key information and business scenario information, and the relationship between the marked key information and the business scenario. The relationship between the marked key information and the business scenario can be manually marked. The preset template format can be set according to requirements. The test case copy sample includes multiple test case copies, and the test case copy represents the text containing the page test case. The page element sample includes multiple page elements, and each page element can be a page picture, text, table and other specific content. The initial test case generation model, the transition test case generation model and the test case generation model can be trained based on the BERT model and the GPT-4 model.
[0084] Optionally, when inputting the initial test case generation model, the transition test case generation model and the test case generation model data, it is necessary to first detect whether it is the format of the input initial test case generation model, the transition test case generation model and the test case generation model. If not, it is necessary to convert the format of the input data first.
[0085] In some embodiments of the present application, a test case generation model includes: a large model infrastructure, a custom test case generation layer and a decoder.
[0086] In the above process, the present application can achieve the effect of generating test cases through the structure of the test case generation model set up in the present application.
[0087] Among them, the large model infrastructure also includes convolutional layers, fully connected layers, encoding layers, etc. It can also include attention mechanisms. The test case generation model can better understand the important information in the requirement document.
[0088] In some embodiments of the present application, the initial test case generation model, the excessive test case generation model, and the test case generation model are learned using a supervised learning method or an unsupervised learning method.
[0089] In the above process, the present application can train the test case generation model by supervised learning or unsupervised learning, so that the test case generation model can generate test cases for the page according to the requirement document.
[0090] Among them, in unsupervised learning, the initial test case generation model, the excessive test case generation model and the test case generation model can be trained directly by extracting the key information of the original requirement document as samples. During the training process, the model can autonomously learn to identify the key information in the requirement document to generate corresponding test cases and scripts.
[0091] In some embodiments of the present application, an over-test case generation model is trained by using initial test case samples, including: preprocessing the initial test case samples to obtain processed initial test case samples, wherein the preprocessing method includes: at least one of cleaning, screening, adding, deleting and modifying; and training the over-test case generation model by using the processed initial test case samples.
[0092] In the above process, the relevant data preprocessing work is performed on the initial test case samples to accurately train and obtain the transition test case generation model, thereby improving the accuracy of the final test case generation model in generating the automation script.
[0093] Among them, the preprocessing method may also include processing methods such as truncation and denoising, may also include word segmentation and part-of-speech tagging, and may also include extracting important feature information, such as verbs, nouns, functional modules, etc.
[0094] In some embodiments of the present application, an initial test case generation model is trained using key information samples, including: labeling information relationships between keyword information samples and business scenario information samples, wherein the information relationship represents the relationship between keyword information and business scenario information; inputting the key information samples into a basic initial test case generation model to obtain initial test case generation data; and adjusting parameters of the basic initial test case generation model by comparing the initial test case generation data with the information relationship to obtain an initial test case generation model.
[0095] In the above process, the present application can train an initial test case generation model through keyword information samples and business scenario information samples, thereby achieving the effect of directly processing the requirement document without having to generate test cases through scripts as in the prior art.
[0096] Among them, by comparing the data and information relationships generated by the initial test cases, the method of modifying the model parameters can be determined by calculating the cross entropy loss of the model, thereby optimizing the model.
[0097] In some embodiments of the present application, an over-test case generation model is trained using an initial test case sample, including: filling in information in the initial test case sample according to a preset template format to obtain a standard test case copy; inputting the initial test case sample into a basic over-test case model to obtain copy data; and adjusting the parameters of the basic over-test case model by comparing the standard test case copy and the copy data to obtain an over-test case generation model.
[0098] In the above process, the present application compares the test case text obtained by the over-test case model with the standard test case text, so as to debug and train the over-test case model and obtain a final accurate over-test case model.
[0099] Among them, by comparing the standard test case copy and copy data, the model parameters can be adjusted by calculating the model cross entropy loss.
[0100] In some embodiments of the present application, a test case generation model is trained using keywords in a test case text sample and corresponding page element samples, including: manually editing a standard test case and a corresponding script for the current page; inputting keywords in the test case text sample and corresponding page element samples into a basic test case generation model to obtain an initial test case and a corresponding script; and adjusting the basic test case generation model by comparing the initial test case and the corresponding script with the standard test case and the corresponding script to obtain a test case generation model.
[0101] In the above process, the manually edited page scripts and page test cases can be compared with the page scripts and page test cases generated by the test case generation model, and then the test case generation model can be debugged and trained to improve the accuracy of the test case generation model.
[0102] Among them, by comparing the initial test cases and corresponding scripts with the standard test cases and corresponding scripts, the parameters of the model can be adjusted by calculating the cross entropy loss of the model.
[0103] Step 120: Input key information into a preset initial test case generation model to obtain initial test case data.
[0104] The initial test case data includes the relationship between keyword information and business scenario information. The initial test case data is obtained by obtaining key information samples corresponding to the historical page requirement document set and training through key information samples.
[0105] Step 130: Input the initial test case data into a preset transition test case generation model to obtain a test case text in a preset template format.
[0106] Among them, the excessive test case generation model is obtained by inputting key information samples into the initial test case generation model to obtain initial test case samples, and is trained by the initial test case samples.
[0107] Step 140: Input the keywords in the test case text in the preset template format and the page element information of the current page into the preset test case generation model to obtain the test case and the corresponding test script.
[0108] Among them, the test case generation model is obtained by inputting the initial test case sample into the transition test case generation model to obtain the test case copy sample in the preset template format; it is trained by the keywords in the test case copy sample and the corresponding page element samples.
[0109] In some embodiments of the present application, after the keywords in the test case text in the preset template format and the page element information of the current page are input into the preset test case generation model to obtain the test case and the corresponding test script, it also includes: editing the test case through the test script to generate an executable test case; executing the executable test case to generate a page.
[0110] In the above process, the application can directly generate corresponding pages through the generated test cases and scripts to achieve the effect of page design.
[0111] In the above Figure 1 In the process shown, the present application extracts the key information of the original requirement document of the current page, wherein the key information includes; keyword information and business scenario information; inputs the key information into the preset initial test case generation model to obtain the initial test case data, wherein the initial test case data includes the relationship between the keyword information and the business scenario information; inputs the initial test case data into the preset transition test case generation model to obtain the test case copy in the preset template format; inputs the keywords in the test case copy in the preset template format and the page element information of the current page into the preset test case generation model to obtain the test case and the corresponding test script. The original requirement document of the design page is input into the model to generate the initial test case, and then the initial test case is input into the model to continue to generate a reliable test case copy, the keywords of the reliable test case copy are extracted, and the keywords are combined with the interface element information. Input the final test case model, the corresponding automation script can be generated, and the automation-related test can be performed. This method does not generate an automation script through an existing script, but directly generates a test case through the original requirement document, and matches the generated test case and element information with the business scenario to finally obtain an executable automation script. This method can achieve the effect of accurately generating test cases and automation scripts.
[0112] Combine the following Figure 2 The generation and implementation method of the test cases and automation scripts of the embodiments of the present application are described in detail.
[0113] Please see Figure 2 , Figure 2 A flowchart of an implementation method for generating a test case and an automated script while training a test case generation model provided in an embodiment of the present application, such as Figure 2 The test case and automation script generation and implementation methods shown include:
[0114] Step 210: Extract keywords and core business scenarios from the original requirements document.
[0115] Specific: Extract key information of the original requirement document of the current page
[0116] Step 220: Generate test cases using the large model.
[0117] Specifically: key information is input into a preset initial test case generation model to obtain initial test case data, wherein the initial test case generation model is obtained through key information training.
[0118] Step 230: Perform data processing on the test case.
[0119] Specifically: preprocessing the initial test case data includes at least one of cleaning, screening, adding, deleting and modifying to obtain processed initial test case data.
[0120] Step 240: Train the processed data using the large model.
[0121] Specifically: Train the overtest case model through the processed initial test case data.
[0122] Step 250: Extract keywords of the generated test cases.
[0123] Specifically: Input the processed initial test case data into the transition test case model to obtain the test case text.
[0124] Step 260: The extracted keywords match the corresponding page element information.
[0125] Specifically: extract test case copy keywords and match the element information corresponding to the keywords.
[0126] Step 270: Train the large model using keywords and corresponding page element information.
[0127] Specifically: after training the test case generation model with keywords and corresponding page element information, the keywords and corresponding page element information are input into the test case generation model to obtain test cases and scripts.
[0128] Step 280: Generate an automation script using the large model.
[0129] Specifically: execute the script to generate the automation script corresponding to the test case, and generate the UI interface through the automation script.
[0130] also, Figure 2 The specific methods and steps shown can be found in Figure 1 The method shown will not be described in detail here.
[0131] Previous article Figure 1-Figure 2 Describes the generation method of test cases and automation scripts. Figure 3-Figure 4 Describes the generation of test cases and automation scripts.
[0132] Please refer to Figure 3 , is a schematic block diagram of a test case and automated script generation device 300 provided in an embodiment of the present application, and the device 300 may be a module, program segment or code on an electronic device. Figure 1 The method embodiment corresponds to and can be executed Figure 1 The various steps involved in the method embodiment and the specific functions of the device 300 can be found in the description below. To avoid repetition, the detailed description is appropriately omitted here.
[0133] Optionally, the device 300 includes:
[0134] The extraction module 310 is used to extract key information of the original demand document of the current page, wherein the key information includes keyword information and business scenario information;
[0135] A first generating module 320 is used to input key information into a preset initial test case generation model to obtain initial test case data, wherein the initial test case data includes the relationship between keyword information and business scenario information;
[0136] The second generation module 330 is used to input the initial test case data into a preset transition test case generation model to obtain a test case text in a preset template format;
[0137] The third generation module 340 is used to input the keywords in the test case text in the preset template format and the page element information of the current page into the preset test case generation model to obtain the test case and the corresponding test script.
[0138] Optionally, the device further comprises:
[0139] A training module, used for the extraction module to obtain key information samples corresponding to the historical page requirement document set before extracting the key information of the original requirement document of the current page, wherein the key information samples include: keyword information samples and business scenario information samples;
[0140] The initial test case generation model is trained by using key information samples;
[0141] Input key information samples into the initial test case generation model to obtain initial test case samples, wherein the initial test case samples include the relationship between information in the keyword information sample and the business scenario information sample; train the transition test case generation model through the initial test case samples; input the initial test case samples into the transition test case generation model to obtain test case copy samples in a preset template format; train the test case generation model through the keywords in the test case copy samples and the corresponding page element samples.
[0142] Optionally, the training module is specifically used to:
[0143] Preprocessing the initial test case samples to obtain processed initial test case samples, wherein the preprocessing method includes: at least one of cleaning, screening, adding, deleting and modifying; and training the transition test case generation model through the processed initial test case samples.
[0144] Optionally, the training module is specifically used to:
[0145] Label the information relationship between the keyword information samples and the business scenario information samples, wherein the information relationship represents the relationship between the keyword information and the business scenario information; input the key information samples into the basic initial test case generation model to obtain the initial test case generation data; and adjust the parameters of the basic initial test case generation model by comparing the initial test case generation data with the information relationship to obtain the initial test case generation model.
[0146] Optionally, the training module is specifically used to:
[0147] Fill in the information in the initial test case sample according to the preset template format to obtain a standard test case copy; input the initial test case sample into the basic transition test case model to obtain copy data; adjust the parameters of the basic transition test case model by comparing the standard test case copy and copy data to obtain a transition test case generation model.
[0148] Optionally, the training module is specifically used to:
[0149] Manually edit the standard test cases and corresponding scripts of the current page; input the keywords in the test case copy sample and the corresponding page element samples into the basic test case generation model to obtain the initial test cases and corresponding scripts; adjust the basic test case generation model by comparing the initial test cases and corresponding scripts with the standard test cases and corresponding scripts to obtain the test case generation model.
[0150] Optional, test case generation model, including:
[0151] Large model infrastructure, custom test case generation layer, and decoder.
[0152] Optionally, the initial test case generation model, the excessive test case generation model and the test case generation model are learned by supervised learning or unsupervised learning.
[0153] Optionally, the device further comprises:
[0154] A generation module is used for the third generation module to input the keywords in the test case text in the preset template format and the page element information of the current page into the preset test case generation model, obtain the test case and the corresponding test script, edit the test case through the test script, generate an executable test case; execute the executable test case to generate a page.
[0155] Please refer to Figure 4 The structure schematic block diagram of a test case and automated script generation device provided in an embodiment of the present application, the device may include a memory 410 and a processor 420. Optionally, the device may also include: a communication interface 430 and a communication bus 440. The device and the above Figure 1 The method embodiment corresponds to and can be executed Figure 1 The various steps involved in the method embodiment and the specific functions of the device can be found in the description below.
[0156] Specifically, the memory 410 is used to store computer-readable instructions.
[0157] Processor 420 is used to process the readable instructions stored in the memory and can execute Figure 1 The steps in the method.
[0158] The communication interface 430 is used for signaling or data communication with other node devices, for example, for communication with a server or a terminal, or for communication with other device nodes, but the embodiments of the present application are not limited thereto.
[0159] The communication bus 440 is used to realize direct connection and communication among the above components.
[0160] The communication interface 430 of the device in the embodiment of the present application is used to communicate signals or data with other node devices. The memory 410 can be a high-speed RAM memory or a non-volatile memory, such as at least one disk memory. The memory 410 can also be at least one storage device located away from the aforementioned processor. The memory 410 stores computer-readable instructions. When the computer-readable instructions are executed by the processor 420, the electronic device executes the aforementioned Figure 1The method process shown. The processor 420 can be used on the device 300 and is used to perform the functions in the present application. Exemplarily, the above-mentioned processor 420 can be a general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, and the embodiments of the present application are not limited thereto.
[0161] The embodiment of the present application also provides a readable storage medium, when the computer program is executed by a processor, Figure 1 The method process in the method embodiment shown is executed by the electronic device.
[0162] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the device described above can refer to the corresponding process in the aforementioned method, and will not be described in detail here.
[0163] In summary, the embodiment of the present application provides a method, device, electronic device and readable storage medium for generating test cases and automation scripts, the method comprising extracting key information of the original requirement document of the current page, wherein the key information comprises: keyword information and business scenario information; inputting the key information into a preset initial test case generation model to obtain initial test case data, wherein the initial test case data comprises the relationship between keyword information and business scenario information; inputting the initial test case data into a preset transition test case generation model to obtain a test case text in a preset template format; inputting the keywords in the test case text in a preset template format and the page element information of the current page into a preset test case generation model to obtain a test case and a corresponding test script. This method can achieve the effect of accurately generating test cases and automation scripts.
[0164] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0165] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0166] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0167] The above description is only an embodiment of the present application and is not intended to limit the scope of protection of the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application. It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.
[0168] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0169] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
Claims
1. A method for generating test cases and automation scripts, It is characterized in that include: Extract key information of the original requirement document of the current page, wherein the key information includes keyword information and business scenario information; Inputting the key information into a preset initial test case generation model to obtain initial test case data, wherein the initial test case data includes the relationship between the keyword information and the business scenario information; Inputting the initial test case data into a preset transition test case generation model to obtain a test case text in a preset template format; The keywords in the test case text in the preset template format and the page element information of the current page are input into a preset test case generation model to obtain a test case and a corresponding test script.
2. The method according to claim 1, It is characterized in that Before extracting the key information of the original requirement document of the current page, the method further includes: Acquire key information samples corresponding to the historical page requirement document set, wherein the key information samples include: keyword information samples and business scenario information samples; Training the initial test case generation model through the key information samples; Inputting the key information sample into the initial test case generation model to obtain an initial test case sample, wherein the initial test case sample includes the relationship between the information in the keyword information sample and the business scenario information sample; Training the excessive test case generation model through the initial test case samples; Inputting the initial test case sample into the transition test case generation model to obtain a test case copy sample in a preset template format; The test case generation model is trained by using the keywords in the test case text samples and the corresponding page element samples.
3. The method according to claim 2, It is characterized in that The step of training the excessive test case generation model by using the initial test case sample comprises: Preprocessing the initial test case sample to obtain a processed initial test case sample, wherein the preprocessing method includes: at least one of cleaning, screening, adding, deleting and modifying; The excessive test case generation model is trained by using the processed initial test case samples.
4. The method according to claim 2, It is characterized in that The step of training the initial test case generation model by using the key information sample includes: Annotating information relationships between the keyword information samples and the business scenario information samples, wherein the information relationships represent relationships between the keyword information and the business scenario information; Inputting the key information sample into a basic initial test case generation model to obtain initial test case generation data; By comparing the initial test case generation data with the information relationship, the parameters of the basic initial test case generation model are adjusted to obtain the initial test case generation model.
5. The method according to claim 2, It is characterized in that The step of training the excessive test case generation model by using the initial test case sample comprises: Fill in the information in the initial test case sample according to a preset template format to obtain a standard test case text; Inputting the initial test case sample into a basic transition test case model to obtain copy data; By comparing the standard test case text and the text data, the parameters of the basic excessive test case model are adjusted to obtain the excessive test case generation model.
6. The method according to claim 2, It is characterized in that The step of training the test case generation model by using the keywords in the test case text sample and the corresponding page element samples includes: Manually edit the standard test cases and corresponding scripts of the current page; Input the keywords and corresponding page element samples in the test case copy sample into the basic test case generation model to obtain an initial test case and a corresponding script; By comparing the initial test case and the corresponding script with the standard test case and the corresponding script, the basic test case generation model is adjusted to obtain the test case generation model.
7. The method according to any one of claims 1 to 6, It is characterized in that The test case generation model includes: Large model infrastructure, custom test case generation layer, and decoder.
8. The method according to any one of claims 1 to 6, It is characterized in that The initial test case generation model, the excessive test case generation model and the test case generation model are learned by supervised learning or unsupervised learning.
9. The method according to any one of claims 1 to 6, It is characterized in that After inputting the keywords in the test case text in the preset template format and the page element information of the current page into the preset test case generation model to obtain the test case and the corresponding test script, the method further includes: Editing the test case through the test script to generate an executable test case; The executable test case is executed to generate a page.
10. A device for generating test cases and automated scripts, It is characterized in that include: An extraction module is used to extract key information of the original requirement document of the current page, wherein the key information includes keyword information and business scenario information; A first generating module, configured to input the key information into a preset initial test case generating model to obtain initial test case data, wherein the initial test case data includes a relationship between the keyword information and the business scenario information; A second generation module, used for inputting the initial test case data into a preset transition test case generation model to obtain a test case text in a preset template format; The third generation module is used to input the keywords in the test case text in the preset template format and the page element information of the current page into a preset test case generation model to obtain a test case and a corresponding test script.
11. An electronic device, It is characterized in that include: A memory and a processor, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the steps in the method according to any one of claims 1 to 9 are executed.
12. A computer-readable storage medium, It is characterized in that include: A computer program, when the computer program is run on a computer, causes the computer to execute the method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Test case recommendation method and device and electronic equipment
CN112416778A
Method and device for generating UI automatic test script and medium
CN118170686A
Cited By
Automatic testing method and system
CN119357067A
