Automatic generation method and device of test cases based on artificial intelligence
By training AI big models and using them to generate test cases, the problem of lack of flexibility and adaptability of existing tools to generate test cases is solved, and efficient and accurate test case generation is achieved, suitable for complex business logic and rapid change needs.
Patent Information
- Application Number
- CN202411853428.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-16
- Publication Date
- 2025-04-04
AI Technical Summary
Test cases generated by existing automation tools lack flexibility and adaptability to cope with the needs of complex business logic and rapid change.
By using completed test case document data to train the AI model, obtain the user input requirements, and input them into the trained AI model, and automatically generate the final test case.
It has achieved the generation of high-quality, flexible and adaptable test cases, which can effectively respond to the needs of complex business logic and rapid changes, and improve testing efficiency and accuracy.
Smart Images

Figure CN119759774A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence, and in particular to a method and device for automatically generating test cases based on artificial intelligence. Background Art
[0002] With the rapid development of digitalization, the speed of software and system development and update is accelerating, and the importance of testing is becoming more and more prominent. Efficient, accurate and comprehensive test cases are essential to ensure software quality, discover potential problems and improve user experience. At present, whether it is a large-scale enterprise application or a small mobile application, a large number of high-quality test cases are needed for comprehensive verification to cope with the changing market demands and user expectations.
[0003] However, according to user feedback, testing work still faces significant challenges. Users hope that test cases can be generated quickly to reduce test preparation time and have the ability to cover various scenarios and boundary conditions. At the same time, users also have high requirements for the maintainability and scalability of test cases so that test cases can be quickly updated as software requirements change. In addition, users expect the generated test cases to be easy to understand and use, and to facilitate test execution and result analysis, thereby improving test efficiency and accuracy.
[0004] A survey of existing test case generation tools and solutions on the market shows that these tools have certain shortcomings. The test cases generated by some tools are too simple and lack sufficient detection capabilities for complex logic and abnormal situations, making it difficult to meet the testing needs of complex business scenarios. In addition, these tools have limited flexibility and adaptability, making it difficult to respond to frequent changes in requirements in a timely manner. Given the limitations of existing tools, how to achieve efficient and automated test case generation has become a key problem in the industry.
[0005] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0006] The embodiments of the present invention provide a method and device for automatically generating test cases based on artificial intelligence, so as to at least solve the technical problem that it is difficult to cope with complex business logic due to the lack of flexibility and adaptability of test cases generated by some automated tools.
[0007] According to one aspect of an embodiment of the present invention, there is provided a method for automatically generating test cases based on artificial intelligence, comprising: using completed test case document data to train an AI big model to obtain user input requirements, and inputting the user input requirements into the trained AI big model, and using the AI big model to automatically generate a final test case.
[0008] According to another aspect of an embodiment of the present invention, there is also provided an automatic generation device for test cases based on artificial intelligence, including: a training module, configured to train an AI big model using completed test case document data; a generation module, configured to obtain user input requirements, and input the user input requirements into the trained AI big model, and automatically generate a final test case using the AI big model.
[0009] In an embodiment of the present invention, the completed test case document data is used to train the AI big model; the user input requirements are obtained, and the user input requirements are input into the trained AI big model, and the final test case is automatically generated using the AI big model, which solves the problem of difficulty in dealing with complex business logic technology due to the lack of flexibility and adaptability of use cases generated by some automated tools. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0011] Figure 1 is a flow chart of a method for automatically generating test cases based on artificial intelligence according to an embodiment of the present application;
[0012] Figure 2 is an architecture diagram of an automatic generation system of test cases based on artificial intelligence according to an embodiment of the present application;
[0013] Figure 3 is a flowchart of another method for automatically generating test cases based on artificial intelligence according to an embodiment of the present application;
[0014] Figure 4 is a flow chart of a method for training an AI model according to an embodiment of the present application;
[0015] Figure 5 is a structural diagram of an automatic generation device of test cases based on artificial intelligence according to an embodiment of the present application;
[0016] Figure 6 A schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0017] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0018] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0019] According to an embodiment of the present invention, a method embodiment of a method for automatically generating test cases based on artificial intelligence is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0020] Figure 1 is an automatic generation method of test cases based on artificial intelligence according to an embodiment of the present invention, such as Figure 1 As shown, the method comprises the following steps:
[0021] Step S102, using the completed test case document data to train the AI big model.
[0022] For example, completed test case document data is obtained, wherein the test case document data includes a variety of project types and their corresponding test cases; the test case document data is preprocessed, wherein the preprocessing includes text cleaning, format normalization and labeling; the preprocessed test case document data is input into the AI big model, and the AI big model is trained based on a supervised learning method; during the training process, the test case generation capability of the AI big model is evaluated and optimized using a cross-validation method to obtain the optimized AI big model.
[0023] Step S104, obtaining the requirements input by the user, and inputting the requirements input by the user into the trained AI big model, and using the AI big model to automatically generate the final test case.
[0024] First, obtain the requirements input by the user. For example, obtain the requirements design draft, where the requirements design draft includes the requirements document and the design draft in the image format; obtain the project technical background introduction, where the project technical background introduction includes the project type, and the project type is used to indicate the corresponding test points for different technology stacks.
[0025] Next, the requirements document is optimized. For example, the AI big model analyzes the requirements document based on the requirements document and the design draft, finds logical loopholes in the requirements document, and optimizes the requirements document based on the logical loopholes.
[0026] Then, the final test case is automatically generated using the AI big model. For example, based on the overall integration of the requirements input by the user, the AI big model is used to generate macro test cases from a macro overall perspective; when the length of the requirements input by the user is greater than a preset threshold, the AI big model is used to disassemble the requirements input by the user to generate micro test cases with small granularity. Specifically, each small functional point is determined from the requirements input by the user; based on the various small functional points, the requirements input by the user are disassembled to generate the micro test cases with small granularity corresponding to the various small functional points. Afterwards, the final test case is generated based on the macro test case and the micro test case.
[0027] The present application also provides an automatic generation system of test cases based on artificial intelligence, such as Figure 2 As shown in the figure, the system architecture includes multiple modules: requirement design draft input module, project technical background introduction module, requirement analysis and testing module, requirement decomposition module, test case generation module based on decomposition, macro test case generation module and integration and optimization of all test case modules. These modules are used to input requirement information, background information, analyze requirements, generate test cases, and integrate and optimize the generated test case files.
[0028] The requirement design draft input module supports the input of requirement design drafts in the form of text and local images to ensure that the requirement information is complete and accurate. The project technical background introduction module is used to allow users to provide project background information, including project type, technology stack, etc. The requirement analysis and testing module analyzes requirements and identifies logical vulnerabilities based on AI models, providing a basis for test case generation. The requirement decomposition module decomposes the requirement documents and breaks down complex requirements into small functional points in order to generate fine-grained test cases. The test case generation module based on decomposition generates small-grained test cases based on the decomposed requirements. The macro test case generation module generates macro test cases from the overall perspective of requirements to ensure global coverage. The integration and optimization of all test case modules integrates all generated test cases to form the final test case document to ensure comprehensive coverage.
[0029] The following is a detailed description of the workflow of the automatic generation system of test cases based on artificial intelligence. Figure 3 As shown, the method for automatically generating test cases based on artificial intelligence includes the following steps:
[0030] Step S302, input the demand design draft.
[0031] The user inputs the design draft into the system, which supports text input and design draft image upload for further analysis by the model. The system performs a preliminary analysis of the design draft content, extracts the text content and stores it in the database, providing data support for subsequent analysis and use case generation.
[0032] Step S304, providing project background information.
[0033] The user provides background information of the project, including technology stack, development platform, project type (such as native app, hybrid app, etc.). The system records this information through the project background introduction module, providing a basis for selecting appropriate test strategies when generating use cases. For example, for different platforms, the system can set different test points based on platform characteristics to ensure that the test cases are targeted and complete.
[0034] Step S306: test requirement analysis.
[0035] The system calls the requirements analysis test module, and uses AI to analyze the requirements document and design draft content, identify potential logical loopholes and make optimization suggestions. Specifically, first, parse the requirements document. The system splits the content of the requirements document into multiple modules, analyzes them one by one, and identifies key requirements and functional points. Then, detect logical loopholes. Based on the understanding of business scenarios, the AI model identifies logical errors or unreasonable points in the requirements document, such as contradictory requirements, incomplete business processes, etc. After that, generate optimization suggestions. For the detected logical loopholes, the model automatically generates optimization suggestions and feeds them back to the user for reference. This module improves the quality of documents through a feedback iteration mechanism, providing a reliable demand basis for subsequent use case generation.
[0036] Step S308, demand decomposition.
[0037] The requirement decomposition module further refines the requirement documents, especially for those that are long or complex in content. The AI model will decompose the requirements by functional points or logical units to ensure that the generated test cases can cover each small functional point.
[0038] Specifically, first identify small functional points. The system automatically scans the requirement document, identifies small functional points and business logic in the document based on the semantic analysis function of the trained model, and forms a preliminary disassembly plan. After that, the disassembly and refinement are carried out. For larger requirement items, they are further disassembled into more fine-grained functional requirements. For example, the "user login" requirement is disassembled into small functional points such as "enter user name", "enter password", and "submit form", laying the foundation for generating more detailed test cases.
[0039] Step S310, generating test cases based on the disassembly.
[0040] After the disassembly is completed, the system enters the stage of generating test cases based on the disassembly. This module inputs each small function point into the AI model one by one to generate fine-grained test cases corresponding to the small function points. The specific steps include:
[0041] 1) Generate preliminary use cases.
[0042] Based on the output of the disassembly module, the system inputs each small function point into the AI model, and the model generates the corresponding test cases. The generated preliminary test cases will cover the core logic of the function point.
[0043] 2) Complete the use case details.
[0044] For more critical small functional points, the system will further refine the preliminary use cases to ensure the completeness of the test cases. For example, for the test case of "submit form", the system will add different scenarios such as "submit with correct data input", "submit with incorrect data input", and "submit blank" to ensure comprehensive testing of the functional point.
[0045] 3) Test scenario expansion.
[0046] By combining rules and algorithms for specific business scenarios, the AI model further expands the test scenarios for generated use cases, allowing the test cases to cover more boundary conditions and abnormal situations.
[0047] Step S312, generating a macro test case.
[0048] The macro test case generation module is responsible for generating test cases from the perspective of overall requirements. Based on the project background information and the content of the requirements design draft, this module will generate more comprehensive test cases from a global perspective to cover the overall integration requirements of the system and ensure the comprehensiveness of the test. The specific steps are as follows:
[0049] 1) Overall demand integration.
[0050] The system integrates the functional points output by the requirement analysis module, builds an overall view, and identifies the global functions and cross-module processes in the requirements.
[0051] 2) Macro test case generation.
[0052] Based on the overall demand view, the AI model generates macro test cases. For example, for an e-commerce system, macro test cases may include "the complete process from browsing to ordering" and "the connection test between the payment system and the inventory system".
[0053] 3) Multi-path coverage.
[0054] For macro test cases, the system generates multiple possible paths, covering both primary and secondary processes, in order to more comprehensively test the stability and reliability of the overall business process.
[0055] Step S314, integrating and optimizing all test cases.
[0056] After completing the generation of macro and micro test cases, the system enters the integration and optimization phase, integrating the output of all test case modules and generating the final test case document. The integration and optimization module is responsible for cleaning up redundant content and ensuring the logical order and comprehensive coverage of test cases.
[0057] Specifically, the system removes duplicates and merges test cases from different modules, and simplifies duplicate or redundant test cases. The system sorts test cases according to test priority so that users can prioritize key test cases in actual testing. The system standardizes the format of the generated test case documents to ensure that the document format is consistent and the content is clear, which is easy for users to understand and use. All optimized test cases are integrated to generate the final test case document. The document content includes detailed information such as case number, function point description, test steps, expected results, etc. to support subsequent test execution and result analysis.
[0058] After the final test case document is generated after integration and optimization, the system will display it to the user for review and confirmation. The user can review every detail in the test case document and perform the test after confirming that it is correct. If the user finds areas that need improvement, he or she can make modification suggestions, and the system will automatically record and make corresponding adjustments. After multiple rounds of confirmation, the final test case document is approved for use in the project's testing phase.
[0059] The present invention provides a method for training an AI model using existing test case document data to automatically generate high-quality test cases. Figure 4 As shown, the method comprises the following steps:
[0060] Step S402: data preprocessing.
[0061] Before starting model training, the collected test case document data must first be cleaned and standardized to ensure data quality. First, remove noise information and irrelevant content in the test case data, such as blank lines, meaningless symbols, and duplicate entries, to ensure the validity of the training data. Next, perform format standardization. The formats of test cases may vary greatly, and the data needs to be formatted uniformly. Extract and organize the key fields of each test case (such as case description, operation steps, expected results, boundary conditions) into a structured data format, such as JSON or XML format. This structured data facilitates subsequent model input processing. Then, perform data annotation. In order for the model to recognize the components of the test case, annotate the data, including the characteristics of the test case (such as test steps, expected results, input conditions, etc.), to ensure that the model can learn these characteristics during training.
[0062] Step S404, constructing a training data set.
[0063] Based on the processed data, a dataset for training AI models is constructed. The dataset includes input content (such as requirement descriptions, use case steps) and output content (such as generated test case text). The labeled structured data is divided into training sets, validation sets, and test sets. By allocating test case data, it is ensured that the model evaluation during the training process covers different business demand scenarios. In order to expand the scale and richness of training data, data enhancement technology is used to process existing samples, such as adding synonym replacement, sentence conversion and other operations to enrich the diversity of training samples and improve the generalization ability of the model.
[0064] Step S406: model selection and pre-training.
[0065] The present invention is based on a pre-trained large-scale language model (such as GPT, etc.), combined with the characteristics of test case generation, to perform further model training and fine-tuning to achieve automated test case generation.
[0066] First, select the model. A large pre-trained language model suitable for text generation tasks is selected as the basic model. GPT models have excellent capabilities in natural language processing and generation, and are suitable for tasks such as processing requirement documents and generating test cases.
[0067] Next, expand the pre-training data. In order to improve the model's ability to understand professional terms, test scenarios, and requirement documents, add a large amount of requirement documents and test case data on the basis of pre-training, so that the model has a preliminary understanding of business logic and use case structure.
[0068] After that, fine-tune the model architecture. According to the requirements of test case generation, adjust the model structure appropriately, such as adding an Attention mechanism suitable for context understanding to improve the coherence and logic of the content generated by the model.
[0069] Step S408: multi-task training.
[0070] 1) Parallelize subtasks.
[0071] In the multi-task learning framework, different subtasks (step generation, exception handling, boundary condition identification, etc.) are divided into independent training modules. Each module is trained based on independent demand characteristics and equipped with independent parameter sets to avoid interference between different tasks. In this way, the model can be allowed to learn multiple tasks simultaneously on the same batch of training data, making the model more efficient and gradually optimized on each subtask.
[0072] Although each subtask has an independent set of parameters, in order to improve the overall generation quality of the model, the model shares an inter-task gradient pool, which aggregates the parameter updates of each task in the gradient pool and optimizes the global parameters. In this way, the model can focus on different details on subtasks, while sharing consistent training results on global parameters, thereby improving the overall synergy of the model.
[0073] The multi-task model in traditional methods often adopts a shared parameter structure, which is easy to cause task interference. Through independent parameter sets and gradient sharing between tasks, this method effectively avoids such interference and improves the coordination between tasks. The improvement of gradient sharing between tasks also reduces the demand for a large amount of data, and can achieve better training results on relatively small data sets, improving training efficiency and the applicability of test case generation.
[0074] 2) Use cross entropy loss function and field weighting mechanism.
[0075] The cross entropy loss function is a commonly used supervised learning error measurement method that optimizes model parameters by calculating the difference between the model output and the standard test case. This method improves on the traditional cross entropy loss and introduces a "field weighting" mechanism, which gives higher weights to key fields such as operation steps and expected results when calculating the loss, ensuring that the model can focus on these high-priority information during the optimization process, thereby gradually reducing errors in key fields. The specific implementation is as follows:
[0076] In the test case text of each training sample, a weight matrix is constructed for fields such as operation steps and expected results, and each value in the weight matrix is weighted with the cross entropy loss. For the prediction of each key field position, a higher weight value is given, while a lower weight is given to secondary fields (such as titles or comments). The weight matrix is generated by features extracted from a specific configuration file or requirement description.
[0077] Based on the keywords and specific semantic features in the requirement description, a dynamic weight is assigned to each field by establishing a mapping relationship between the field and the degree of criticality. For example, if keywords such as "exception handling" and "boundary conditions" appear in the requirement description, the system will automatically identify and weight the corresponding fields, so that this information will receive more attention during model training.
[0078] In order to accurately identify the key fields in the requirement description, especially the parts involving the operation steps and expected results, this application designs an additional encoding network to extract the semantic features of the key fields from the requirement description. The role of the encoding network is to ensure that the model can effectively identify and locate the key content, and adjust the field weights according to the requirement description, so as to better focus on the key content when calculating the loss. A pre-trained model (such as BERT) is used as the basis of the encoding network to pre-process the requirement description and encode the text content into a feature vector. The feature vector's ability to identify key fields is further enhanced by a refined encoding network structure, such as a multi-layer convolutional neural network (CNN) or a bidirectional LSTM structure. Important keywords in the requirement description are extracted by methods such as named entity recognition (NER) and dependency syntax analysis. The process can also be combined with a weight adaptive mechanism to dynamically adjust the weights for different key fields. For example, if the requirement contains high-priority information such as "key operations" or "safety measures", these fields are assigned higher loss weights. Focusing on specific fields means mapping the semantic features identified in the requirements to the various fields output by the model, so that the model can focus on specific fields more accurately during the optimization process.
[0079] Specifically, in the keyword extraction process, the method first performs natural language processing analysis on the user input to extract keywords and deep semantic features. In the early stage of model training, the system uses the language model to extract the primary embedding vector group of the sample data and the auxiliary embedding vector group of the artificially recognized text. By generating feature representations for the sample data and the artificially recognized text, the primary embedding vector group and the auxiliary embedding vector group are formed to capture the features of the text in the multi-dimensional semantic space. These embedding vector groups can effectively represent the semantic information of the text and provide basic data in subsequent processing. In order to enhance the model's ability to capture features of different types of text, the primary embedding vector group and the auxiliary embedding vector group are respectively multi-dimensionally upgraded according to the preset expansion rank criterion. The multi-channel convolution kernel is used to perform feature coupling and fusion processing on the expanded embedding vector group to generate the coupled primary embedding group and the auxiliary embedding group. The multi-channel convolution kernel can capture and fuse the semantic information of the text in different feature spaces, so that the text features from different sources can be efficiently combined, thereby improving the performance of the model in understanding deep semantics. After feature coupling, a nonlinear activation function is applied to optimize the expressive power of the embedding vectors and generate the activated primary embedding group and auxiliary embedding group. After that, the normalization operation is performed to ensure the scale consistency of the data and avoid numerical deviations between feature levels. The primary feature matrix and the auxiliary feature matrix are respectively subjected to high-order matrix decomposition to extract the key information. First, these matrices are expanded along the expansion dimension to generate multiple sub-matrices. Then, the core subspace representation and factor matrix of each sub-matrix are extracted by singular value decomposition (SVD). The core subspace representation gathers the key information in the matrix, while the factor matrix captures the local structure of its features and can reveal the intrinsic connection between features at different levels. The similarity between the primary feature matrix and the auxiliary feature matrix is further evaluated by performing a difference analysis of the principal components. First, the similarity of the core subspace representation is calculated, and then the difference of the principal components in the factor matrix is measured to capture the subtle changes between the two sets of data. In this way, by comparing the similarity and difference, the system can more accurately identify keywords. Finally, the weight of the loss function is adjusted by comparing the principal component differences between the sample data and the manually recognized text. The updated loss function can better guide the model to focus on identifying subtle semantic differences in text in subsequent training, ensuring that the model grasps details more accurately during language understanding.
[0080] Compared with traditional keyword extraction methods, this scheme increases the ability to capture multi-level semantic information by combining multi-layer embedding vector generation, multi-dimensional up-order expansion and high-order matrix decomposition, making keyword extraction more accurate.
[0081] 3) Apply dynamic weighting mechanism.
[0082] In order to improve the adaptability and convergence of the model during the training process, this application introduces a dynamic weighting mechanism. By adjusting the field weights at different stages, the model gradually focuses on the details of generating test cases. Initial stage-global weight allocation: In the early stages of training, assign higher weights to general fields (such as background descriptions, test conditions, etc.) to ensure that the model has a basic understanding of the overall requirements. The loss weight allocation at this stage tends to be more focused on fields with wider coverage, which helps the model establish an overall understanding framework of the requirements.
[0083] As the model training progresses, the weight ratio of key fields (such as operation steps and expected results) is gradually increased. The specific implementation method is to dynamically adjust the weight of key fields based on the performance changes of the model on the validation set. When the model shows a high overall understanding, more weight is assigned to the key fields, so that the model gradually shifts its focus to the accuracy of the generated details.
[0084] In the later stages of training, the weights of key fields are increased to a higher ratio, and the weights of detail fields (such as abnormal conditions, boundary tests, etc.) are further adjusted based on the accuracy performance of specific test cases to ensure that the model has higher accuracy when generating these details. The loss calculation at this stage is basically completely focused on key fields, and the model generation results meet high-precision requirements by refining the field-level loss function optimization.
[0085] Traditional methods usually use a unified loss weight for all fields, which makes it difficult to achieve differentiated attention to the hierarchical structure of requirements. This method introduces field weighting and adaptive adjustment mechanisms, which enables the model to gradually favor key fields at different training stages, thereby improving the accuracy of generated content. By introducing an additional encoding network, the model can identify semantic features in the requirement description and dynamically adjust the loss weight based on specific keywords. This improvement ensures the accuracy of the model when processing multi-level requirements and solves the problem of insufficient recognition of key fields in traditional loss calculation. In addition, the traditional single loss function calculation method is difficult to adapt to scenarios with diverse requirements. This method can systematically improve the model's attention to key fields at different stages through gradual weight adjustment, so that the quality of the generated test cases is gradually improved and meets the detailed requirements of complex requirement descriptions.
[0086] Step S410: model optimization and verification.
[0087] After the domain fine-tuning is completed, the model needs to be verified and optimized for multiple rounds to ensure that the test cases it generates are of high quality. The quality of model generation is evaluated by inputting the verification set into the model, generating test cases and comparing them with standard test cases. Verification indicators include accuracy, coverage, generation fluency, etc. For errors in the test cases generated by the model, the weaknesses of the model are located by analyzing them one by one. Common types of errors include logical errors, missing steps, incomplete results, etc. After analysis, corresponding optimization measures are taken. Based on the verification results, the model structure and parameters are further optimized. For example, if there are many logical errors in the use cases generated by the model, the Attention layer of the model can be enhanced to improve its logical consistency; if the coverage of the test cases is low, the diversity of the training data can be increased or different data enhancement methods can be used.
[0088] The present application also provides an automatic generation device for test cases based on artificial intelligence, such as Figure 5 As shown, it includes: a training module 52, which is configured to train the AI big model using the completed test case document data; a generation module 54, which is configured to obtain the user input requirements, and input the user input requirements into the trained AI big model, and use the AI big model to automatically generate the final test case.
[0089] It should be noted that: the automatic generation device of test cases based on artificial intelligence provided in the above embodiment is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the automatic generation device of test cases based on artificial intelligence provided in the above embodiment and the automatic generation method of test cases based on artificial intelligence belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0090] Figure 6 FIG. 1 shows a schematic diagram of the structure of an electronic device suitable for implementing the embodiment of the present disclosure. It should be noted that: Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0091] like Figure 6As shown, the electronic device includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage part 1008 into a random access memory (RAM) 1003. In the RAM 1003, various programs and data required for system operation are also stored. The CPU 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.
[0092] The following components are connected to the I / O interface 1005: an input section 1006 including a keyboard, a mouse, etc.; an output section 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN card, a modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed, so that a computer program read therefrom is installed into the storage section 1008 as needed.
[0093] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for automatically generating test cases based on artificial intelligence, characterized in that: include: Use completed test case document data to train AI big models; Obtain the requirements input by the user, and input the requirements input by the user into the trained AI big model, and use the AI big model to automatically generate the final test case.
2. The method according to claim 1, characterized in that The AI big model is used to automatically generate test cases, including: Based on the overall integration of the requirements input by the user, the AI big model is used to generate macro test cases from a macro overall perspective; When the length of the requirement input by the user is greater than a preset threshold, the AI big model is used to disassemble the requirement input by the user to generate micro test cases with small granularity; The final test case is generated based on the macro test case and the micro test case.
3. The method according to claim 2, characterized in that Requirements for obtaining user input include: Obtaining a demand design draft, wherein the demand design draft includes a demand document and a design draft in picture format; Obtain a technical background introduction of the project, wherein the technical background introduction of the project includes a project type, and the project type is used to indicate corresponding test points for different technology stacks.
4. The method according to claim 3, characterized in that: Before automatically generating test cases using the AI big model, the method further includes: The AI big model analyzes the requirement document based on the requirement document and the design draft and finds out logical loopholes in the requirement document; Based on the logic loopholes, the requirement document is optimized.
5. The method according to claim 3, characterized in that: The user input requirements are disassembled to generate micro test cases with small granularity, including: Determine various small functional points from the requirements input by the user; Based on the various small functional points, the requirements input by the user are decomposed to generate the micro test cases with small granularity corresponding to the various small functional points.
6. The method according to claim 1, characterized in that Use the completed test case document data to train the AI model, including: Acquire completed test case document data, wherein the test case document data includes multiple project types and their corresponding test cases; Preprocessing the test case document data, wherein the preprocessing includes text cleaning, format normalization and labeling; Inputting the preprocessed test case document data into the AI big model, and training the AI big model based on a supervised learning method; During the training process, the cross-validation method is used to evaluate and optimize the test case generation capability of the AI big model to obtain the optimized AI big model.
7. An automatic generation device for test cases based on artificial intelligence, characterized in that: include: A training module, configured to train the AI big model using completed test case document data; The generation module is configured to obtain the requirements input by the user, input the requirements input by the user into the trained AI big model, and automatically generate the final test case using the AI big model.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the method according to any one of claims 1 to 6.
9. A computer device, characterized in that: include: Memory and processor, The memory stores a computer program; The processor is used to execute the computer program stored in the memory, and when the computer program is run, the processor is enabled to execute the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.