Test case generation method, device, terminal device and readable storage medium

By standardizing the requirements file and inputting the test case generation model, test cases are automatically generated, which solves the problems of low efficiency, low quality and high cost of manual writing test cases, and achieves efficient and good quality test cases generation.

CN117707922BActive Publication Date: 2024-11-19NINETECH INFORMATION TECH (SHENZHEN) CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202311376022.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-20
Publication Date
2024-11-19
Estimated Expiration
2043-10-20

AI Technical Summary

Technical Problem

During the software development process, manual writing test cases has problems such as low generation efficiency, low quality and high cost.

Method used

By obtaining the requirements file, standardizing the requirements specification document, and entering it into the test case generation model, generating functional information and test requirements, thereby automatically generating test cases. This method includes steps such as keyword extraction, text cleaning, word segmentation, syntax analysis and vectorization. It uses named entity recognition, word segmentation, part-of-speech annotation, keyword extraction, syntax analysis units and other technologies to generate input data, operation steps and expected results. Form test cases.

Benefits of technology

Improve the generation efficiency and quality of test cases, reduce generation costs, and realize automated test case generation without manual writing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117707922B_ABST
    Figure CN117707922B_ABST
Patent Text Reader

Abstract

The present application is applicable to the field of information processing technology, and provides a method, apparatus, terminal device and readable storage medium for generating a test case. The above-mentioned test case generation method includes: obtaining a requirement file; standardizing the requirement file to obtain a requirement specification document; inputting the requirement specification document into a test case generation model to obtain functional information and test requirements; and generating a test case based on the functional information and test requirements. The embodiment of the present application can obtain functional information and test requirements by standardizing the requirement file and inputting it into a test case generation model, thereby automatically generating a test case without manually writing the test case, thereby improving the generation efficiency and the quality of the test case and reducing the generation cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of information processing technology, and in particular, relates to a test case generation method, apparatus, terminal device and readable storage medium. Background Art

[0002] In the process of software development, it is often necessary to perform functional testing on the software, and in the process of functional testing, it is usually necessary to use test cases for functional testing. A test case is a set of input data, operation steps, and expected results compiled for a specific goal in order to test a program path or verify whether a specific requirement is met.

[0003] In the related art, test cases are usually obtained by manual writing, but manual writing of test cases has the problems of low generation efficiency, low quality and high cost. Summary of the invention

[0004] The embodiments of the present application provide a test case generation method, apparatus, terminal device and readable storage medium, which can solve the problems of low generation efficiency, low quality and high cost when manually writing test cases in related technologies.

[0005] In a first aspect, an embodiment of the present application provides a method for generating a test case, comprising:

[0006] Get the requirements document;

[0007] Standardize the requirement documents to obtain the requirement specification document;

[0008] Input the requirement specification document into the test case generation model to obtain functional information and test requirements;

[0009] Generate test cases based on functional information and test requirements.

[0010] In a specific implementation of the first aspect, the above-mentioned standardization of the requirement document to obtain the requirement specification document includes: extracting keywords from the requirement document to obtain a first keyword; generating an initial requirement specification document based on the first keyword; performing text cleaning on the initial requirement specification document to obtain a cleaned requirement specification document; performing word segmentation on the cleaned requirement specification document to obtain a segmented requirement specification document; performing syntactic analysis on the segmented requirement specification document to obtain an analyzed requirement specification document; and vectorizing the analyzed requirement specification document to obtain a requirement specification document.

[0011] In a specific implementation of the first aspect, the test case generation model includes a named entity recognition unit, a word segmentation unit, a part-of-speech tagging unit, a keyword extraction unit, a syntactic analysis unit, a sentence structure extraction unit, and an output unit. The requirement specification document is input into the test case generation model to obtain functional information and test requirements, including: inputting the requirement specification document into the named entity recognition unit, performing named entity recognition on the requirement specification document, and obtaining a recognition result; inputting the recognition result into the word segmentation unit, performing word segmentation on the recognition result, and obtaining a word segmentation result; inputting the word segmentation result into the part-of-speech tagging unit, performing part-of-speech tagging on the word segmentation result, and obtaining a tagging result; inputting the recognition result and the tagging result into the keyword extraction unit to obtain a second keyword; inputting the second keyword into the syntactic analysis unit, performing syntactic analysis on the second keyword, and obtaining an analysis result; inputting the analysis result into the sentence structure extraction unit to obtain a sentence structure; inputting the second keyword, the tagging result, and the sentence structure into the output unit, and outputting the functional information and test requirements.

[0012] In a specific implementation of the first aspect, the above-mentioned generation of test cases based on functional information and test requirements includes: generating input data, operation steps and expected results according to the functional information and test requirements; generating an initial test case according to the functional information, test requirements, input data, operation steps and expected results; generating a use case number, test conditions, prerequisites, use case description, additional information, use case priority and importance according to the functional information and test requirements; adding the use case number, test conditions, prerequisites, use case description, additional information, use case priority and importance to the initial test case to obtain a test case.

[0013] In a specific implementation of the first aspect, before inputting the requirement specification document into the test case generation model, the method further includes: constructing a test case generation model to be trained; obtaining data to be trained; preprocessing the training data to obtain a training set; training the test case generation model to be trained based on the training set, and adjusting hyperparameters during the training process to obtain a test case generation model.

[0014] In a specific implementation of the first aspect, after generating the test case based on the functional information and the test requirements, the method further includes: obtaining feedback information obtained after executing the test case; analyzing the feedback information to determine defects in the test case; optimizing the test case according to the defects to obtain an optimized test case; adding the optimized test case to the training set of the test case generation model to obtain an optimized training set; training the test case generation model based on the optimized training set to obtain an optimized test case generation model.

[0015] In a specific implementation of the first aspect, after generating the test cases based on the functional information and the test requirements, the method further includes: obtaining preset evaluation rules; and evaluating the test cases in sequence according to the preset evaluation rules to obtain evaluation results.

[0016] In a second aspect, an embodiment of the present application provides a test case generation device, comprising:

[0017] Acquisition module, used to obtain requirement files;

[0018] A processing module is used to standardize the requirement documents to obtain requirement specification documents;

[0019] An input module is used to input the requirement specification document into the test case generation model to obtain functional information and test requirements;

[0020] The generation module is used to generate test cases based on functional information and test requirements.

[0021] In a third aspect, an embodiment of the present application provides a terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned test case generation method when executing the computer program.

[0022] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned test case generation method are implemented.

[0023] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on a terminal device, enables the terminal device to execute the above-mentioned test case generation method.

[0024] The beneficial effect of the embodiment of the present application compared with the prior art is that the embodiment of the present application obtains the requirement file and standardizes the requirement file to obtain the requirement specification document, inputs the requirement specification document into the test case generation model to obtain functional information and test requirements, and then generates test cases based on the functional information and test requirements. The embodiment of the present application obtains functional information and test requirements by standardizing the requirement file and inputting it into the test case generation model, and then automatically generates test cases without manually writing test cases, thereby improving generation efficiency and the quality of test cases and reducing generation costs. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0026] Figure 1 It is a schematic diagram of an implementation flow of a method for generating a test case provided in an embodiment of the present application;

[0027] Figure 2 It is a schematic diagram of the implementation process of standardizing the demand file provided in the embodiment of the present application;

[0028] Figure 3 It is a schematic diagram of the implementation process of obtaining functional information and testing requirements provided in an embodiment of the present application;

[0029] Figure 4 It is a schematic diagram of the implementation process of generating test cases provided in an embodiment of the present application;

[0030] Figure 5 It is a schematic diagram of the implementation process of the training test case generation model provided in the embodiment of the present application;

[0031] Figure 6 It is a schematic diagram of the implementation process of the optimized test case generation model provided in the embodiment of the present application;

[0032] Figure 7 It is a schematic diagram of the implementation process of the evaluation test case provided in the embodiment of the present application;

[0033] Figure 8 It is a structural schematic diagram of a test case generation device provided in an embodiment of the present application;

[0034] Fig. 9 It is a schematic diagram of the structure of the terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0035] In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit 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 are protected by the present application.

[0036] It should be noted that the terms "include", "comprises" and "have" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. For example, a process, method, terminal, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units that are inherent to these processes, methods, products or devices. In the claims, specification and drawings of the present application, relational terms such as "first" and "second" are merely used to distinguish one entity / operation / object from another entity / operation / object, and do not necessarily require or imply any such real-time relationship or order between these entities / operations / objects.

[0037] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0038] In the process of software development, it is often necessary to perform functional testing on the software, and in the process of functional testing, it is usually necessary to use test cases to perform functional testing. A test case is a set of input data, operation steps, and expected results compiled for a specific goal in order to test a program path or verify whether a specific requirement is met. In related technologies, test cases are usually obtained by manual writing, but manual writing of test cases has the problems of low generation efficiency, low quality, and high cost.

[0039] In view of this, the embodiment of the present application can obtain functional information and test requirements by standardizing the requirement file and inputting it into the test case generation model, and then automatically generate test cases without the need for manual writing of test cases, thereby improving generation efficiency and the quality of test cases and reducing generation costs.

[0040] In order to illustrate the technical solution of the present application, a specific embodiment is provided below for illustration.

[0041] Figure 1 The present invention provides a method for generating a test case according to an embodiment of the present invention, which can be applied to a terminal device, such as a mobile phone, a tablet computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, etc.

[0042] Specifically, the above test case generation method may include the following steps S101 to S104.

[0043] Step S101, obtaining a requirement file.

[0044] The requirements document describes the functions and behaviors of the software to be tested. The requirements document can be in the form of text, audio, pictures, etc. The above functions and behaviors can include functional requirements and non-functional requirements. Functional requirements are used to describe the specific functions and their importance that the software system needs to implement, such as user login, data query, file upload, etc. Non-functional requirements are used to describe other requirements of the software system besides the functions, such as performance requirements, security requirements, reliability requirements, etc.

[0045] In an implementation manner of the present application, the terminal device may receive a demand file sent by a user, or obtain the demand file through a network interface.

[0046] Step S102, standardize the requirement document to obtain a requirement specification document.

[0047] The requirement specification document is a document obtained after the requirement document is standardized, which records the functional requirements, non-functional requirements and other information (such as scenario description, interface description, etc.)

[0048] In the implementation of the present application, the requirement document cannot be directly input into the test case generation model in the subsequent steps. Therefore, the terminal device can first structure the requirement document and then perform standardization to obtain a requirement specification document that can be directly input into the test case generation model.

[0049] For non-text requirement files such as audio and images, it is not possible to directly standardize such requirement files and generate requirement specification documents.

[0050] In view of this, in some embodiments of the present application, the requirement file includes a non-text requirement file and a text requirement file. After obtaining the requirement file and before standardizing the requirement file to obtain the requirement specification document, the method may further include the following steps:

[0051] Convert non-text requirements files to text requirements files.

[0052] In the implementation of the present application, the terminal device can input the non-text requirement file into a natural language processing (NLP) tool, and use the NLP tool to convert the non-text requirement file into a text requirement file. The NLP tool can perform speech recognition and image recognition, and can convert audio and pictures into documents.

[0053] The implementation method of the present application can convert non-text requirement files into text requirement files so as to generate test cases through subsequent processing. Therefore, the type of requirement files input by users is not limited, thus improving the user experience.

[0054] Step S103, input the requirement specification document into the test case generation model to obtain functional information and test requirements.

[0055] The test case generation model is used to generate functional information and test requirements based on the input document, which can be a large model of the Generative Pre-training Transformer (GPT) system. Functional information can be information about the description, input, output, and processing of software functions, and test requirements can be requirements and conditions that need to be met in software testing.

[0056] In an implementation manner of the present application, the terminal device may input the requirement specification document into the test case generation model, and the test case generation model may perform operations such as semantic analysis and grammatical parsing on the requirement specification document to extract functional information and test requirements.

[0057] Step S104: Generate test cases based on the functional information and test requirements.

[0058] In the implementation manner of the present application, the terminal device can use the GPT model to generate test cases according to the functional information and the test requirements. After the test cases are generated, they can be directly used for software testing or for evaluation and screening.

[0059] The beneficial effect of the embodiment of the present application compared with the prior art is that the embodiment of the present application obtains the requirement file and standardizes the requirement file to obtain the requirement specification document, inputs the requirement specification document into the test case generation model to obtain functional information and test requirements, and then generates test cases based on the functional information and test requirements. The embodiment of the present application obtains functional information and test requirements by standardizing the requirement file and inputting it into the test case generation model, and then automatically generates test cases without manually writing test cases, thereby improving generation efficiency and the quality of test cases and reducing generation costs.

[0060] like Figure 2 As shown, in some specific implementations of the present application, the above-mentioned standardization processing of the demand file to obtain the demand specification document may specifically include steps S201 to S206.

[0061] Step S201, extract keywords from the demand document to obtain a first keyword.

[0062] In an implementation manner of the present application, the terminal device may utilize a natural language processing model, input the demand document into a language model, and extract a first keyword from the demand document by predicting the probability of the text.

[0063] Step S202: Generate an initial requirement specification document based on the first keyword.

[0064] In an implementation manner of the present application, the terminal device may input the first keyword into the GPT model and output an initial requirement specification document.

[0065] Specifically, the initial requirements specification document may include: functional requirements, which are used to describe the specific functions that the software system needs to implement, such as user login, data query, file upload and other functions; non-functional requirements, which are used to describe the non-functional requirements of the software system, such as performance requirements, security requirements, reliability requirements, etc.; user stories, which are used to describe the user's usage scenarios and expectations in specific scenarios through user stories, so as to help the development team understand user needs; scenario descriptions, which are used to use test cases to describe the interaction process between the software system and the user, including input, output and expected results, etc.; interface descriptions, which are used to describe the user interface of the software system, including page layout, interactive elements and operation processes, etc.; data requirements, which are used to describe the type of data, data format and data size that the software system needs to process, etc.; constraints, which are used to describe the constraints in the software development and testing process, such as time constraints, resource constraints, etc.; assumptions, which are used to describe the assumptions in the software development and testing process, such as certain functions have been implemented in other modules.

[0066] To generate the initial requirement specification document, it is necessary to perform natural language processing on the initial requirement specification document. In subsequent steps S203 to S205, the terminal device can perform natural language processing on the initial requirement specification document with the help of an NLP tool.

[0067] Step S203, performing text cleaning on the initial requirement specification document to obtain a cleaned requirement specification document.

[0068] In an implementation manner of the present application, the terminal device can input the initial requirement specification document into an NLP tool, perform text cleaning on the initial requirement specification document, remove unnecessary special characters, punctuation marks and format information in the initial requirement specification document, retain only the key text content therein, and obtain a cleaned requirement specification document.

[0069] Step S204, segmenting the cleaned requirement specification document to obtain a segmented requirement specification document.

[0070] In the implementation of the present application, the terminal device can input the cleaned requirement specification document into the NLP tool, perform word segmentation on the cleaned requirement specification document, and split the cleaned requirement specification document into a sequence of words or phrases to obtain a word-segmented requirement specification document. Word segmentation can divide continuous text into semantic units, providing a basis for subsequent processing and analysis.

[0071] Step S205 , performing syntactic analysis on the word-segmented requirement specification document to obtain an analyzed requirement specification document.

[0072] In the implementation of the present application, the terminal device can input the segmented requirement specification document into the NLP tool, perform syntactic analysis on the segmented requirement specification document, identify its sentence structure, components and dependencies, and obtain the analyzed requirement specification document. Syntactic analysis can help the system understand the grammatical structure of the sentence, thereby better understanding the meaning of the sentence.

[0073] Step S206, vectorizing the analyzed requirement specification document to obtain a requirement specification document.

[0074] In an implementation manner of the present application, the terminal device may use word embedding technology to represent each word as a vector, or use a text representation method (such as TF-IDF) to represent the entire text as a vector, thereby vectorizing the analyzed requirement specification document to obtain a requirement specification document.

[0075] The test case generation model may include a named entity recognition unit, a word segmentation unit, a part-of-speech tagging unit, a keyword extraction unit, a syntactic analysis unit, a sentence structure extraction unit, and an output unit. Figure 3 As shown, the above-mentioned inputting the requirement specification document into the test case generation model to obtain the functional information and the test requirements may specifically include steps S301 to S307.

[0076] Step S301: input the requirement specification document into a named entity recognition unit, perform named entity recognition on the requirement specification document, and obtain a recognition result.

[0077] In the implementation of the present application, the terminal device can input the requirement specification document into the named entity recognition unit to recognize the named entities in the requirement specification document, such as names, place names, dates, etc., to obtain a recognition result. By performing named entity recognition on the requirement specification document, these entities can be associated with specific functional information and test requirements to further distinguish key information.

[0078] Step S302: input the recognition result into the word segmentation unit, perform word segmentation on the recognition result, and obtain the word segmentation result.

[0079] In the implementation of the present application, the terminal device can input the recognition result into the word segmentation unit, perform word segmentation on the recognition result, and split the recognition result into a sequence of words or phrases to obtain a word segmentation result. Word segmentation can divide continuous text into semantic units, providing a basis for subsequent processing and analysis.

[0080] Step S303: input the word segmentation result into a part-of-speech tagging unit, perform part-of-speech tagging on the word segmentation result, and obtain a tagging result.

[0081] In the implementation of the present application, the terminal device can input the word segmentation result into the part-of-speech tagging unit, perform part-of-speech tagging on the word segmentation result, determine the part-of-speech of each word in the word segmentation result, and thus obtain the tagging result. Performing part-of-speech tagging on the word segmentation result helps to understand the role and meaning of the word in the sentence.

[0082] Step S304: input the recognition result and the annotation result into a keyword extraction unit to obtain a second keyword.

[0083] In an embodiment of the present application, the terminal device can input the recognition results and the annotation results into a keyword extraction unit to extract keywords such as nouns, verbs, adjectives, etc. in the recognition results and the annotation results (these words are usually the core information in the requirement specification document), thereby obtaining the second keyword.

[0084] Step S305: input the second keyword into the syntax analysis unit, perform syntax analysis on the second keyword, and obtain an analysis result.

[0085] In the implementation of the present application, the terminal device can input the second keyword into the syntactic analysis unit, perform syntactic analysis on the second keyword, identify its sentence structure, components and dependencies, and obtain an analysis result. Syntactic analysis can help the system understand the grammatical structure of the sentence, thereby better understanding the meaning of the sentence.

[0086] Step S306: input the analysis result into the sentence structure extraction unit to obtain the sentence structure.

[0087] In an implementation manner of the present application, the terminal device can input the analysis results into a sentence structure extraction unit to extract the structural information of the sentence in the analysis results, such as the subject-predicate-object structure, thereby capturing the key functional points in the sentence and obtaining the sentence structure.

[0088] Step S307: input the second keyword, the annotation result and the sentence structure into the output unit, and output the function information and the test requirement.

[0089] In an embodiment of the present application, the terminal device may input the second keyword, the annotation result, and the sentence structure into the output unit, thereby outputting the functional information and the test requirements. Before outputting the functional information and the test requirements, the output unit may consider the contextual semantics of the requirement specification document to ensure that the extracted functional information and the test requirements can correctly reflect the intention of the requirement specification document.

[0090] In an implementation manner of the present application, after the requirement specification document is input into the test case generation model, the test case generation model performs named entity recognition, word segmentation, part-of-speech tagging, keyword extraction, syntactic analysis, sentence structure extraction, and output on the requirement specification document, outputs key functional information and test requirements, and ensures that the extracted functional information and test requirements can correctly reflect the intent of the requirement specification document, so that the subsequently generated test cases can accurately and comprehensively cover the test requirements of the software.

[0091] like Figure 4 As shown, in some implementations of the present application, the above-mentioned generation of test cases based on functional information and test requirements may specifically include steps S401 to S404.

[0092] In step S401 to step S404, the terminal device can generate test cases using the trained GPT model.

[0093] Step S401, generating input data, operation steps and expected results according to functional information and test requirements.

[0094] Among them, input data refers to the data input into the software under test when executing the test case, which may include various specific input values, parameter combinations or boundary conditions, etc. Operation steps refer to a series of specific processes required when executing the test case, which may include inputting data, clicking buttons, executing commands, etc. Expected results refer to the software output results or reactions expected when executing the test case, including correct results, abnormal prompts, error messages, etc.

[0095] In an implementation manner of the present application, the terminal device can input functional information and test requirements into the GPT model to obtain input data, operation steps and expected results.

[0096] Step S402, generating an initial test case according to the functional information, test requirements, input data, operation steps and expected results.

[0097] In an implementation manner of the present application, after obtaining input data, operating steps and expected results, the terminal device can combine functional information, test requirements, input data, operating steps and expected results to obtain an initial test case.

[0098] Step S403, generating a use case number, test conditions, prerequisites, use case description, additional information, use case priority and importance according to the functional information and test requirements.

[0099] Among them, the case number of each test case is unique and is used for reference and tracking in the document. Test conditions can be test environment, system configuration, data preparation and other conditions that must be met before executing the test case. Preconditions can be some conditions that need to be met before the test case is executed, otherwise the test case cannot be executed. The case description is used to describe the test case in detail, which may include descriptions of the test purpose, test environment, test steps, test results, etc. Additional information can be supplementary instructions and remarks for the test case. The case priority and importance of the test case refers to the urgency and importance of the test case in software testing to execute the test case in a certain priority order.

[0100] In the implementation of the present application, the terminal device can input the function information and the test requirements into the GPT model to obtain the use case number, test conditions, prerequisites, use case description, additional information, use case priority and importance. Use case priority and importance.

[0101] Step S404, adding a test case number, test conditions, prerequisites, a test case description, additional information, a test case priority, and importance to the initial test case to obtain a test case.

[0102] In an implementation manner of the present application, the terminal device may add the use case number, test conditions, prerequisites, use case description, additional information, use case priority and importance, etc. to the initial test case in sequence to obtain a complete test case.

[0103] In addition, the terminal device can classify the generated test cases according to functional points or test requirements to ensure that the logic and structure of the test cases are clear. Each test case should contain information such as input data, operation steps and expected results to form a complete test case.

[0104] After obtaining the complete test cases, the terminal device can verify and screen the generated test cases to ensure that the test cases meet expectations and cover the functional points and test requirements. Screen out duplicate, redundant or inappropriate test cases to improve the quality and readability of the test cases. Then format and layout the test cases to ensure that the format and layout of the entire document meet the company or industry standards, including fonts, font sizes, titles, headers and footers, etc. After the test cases are generated, they can also be quality verified to ensure the correctness, completeness and effectiveness of the test cases. Verification can be achieved by simulating the execution of test cases or comparing expected results with actual results. In addition, the syntax and format of the test cases can be checked to ensure that the syntax and format of the test cases meet the specifications and standards, making the test cases easy to understand and execute. Finally, the test cases can be exported to standard format documents, specifically, the checked test cases and information can be exported to standard document formats, such as Microsoft Word or PDF, for easy sharing and distribution.

[0105] Through the above steps, test cases that meet the standardization requirements can be output, which contain the generated functional test cases and other key information, providing the test team with a clear, accurate and executable test plan to ensure that the functionality and quality of the software system are effectively verified.

[0106] like Figure 5 As shown, in some implementations of the present application, before inputting the requirement specification document into the test case generation model, the method may further include step S501 and step S504.

[0107] Step S501, constructing a test case generation model to be trained.

[0108] Among them, the test case generation model to be trained can be a GPT model to be trained.

[0109] In the implementation of the present application, the terminal device can use a deep learning framework (such as TensorFlow or PyTorch) to build a GPT model. It should be understood that the GPT model is usually based on the Transformer architecture, which is a neural network architecture with an attention mechanism and has excellent performance in processing sequence data (such as text).

[0110] Step S502, obtaining data to be trained.

[0111] In an implementation manner of the present application, the terminal device can collect text data on a large scale from local commonly used requirement documents, requirement templates, use case data, the Internet, books, articles, papers, news and other texts as data to be trained.

[0112] Step S503: pre-process the training data to obtain a training set.

[0113] In the implementation of the present application, the terminal device can preprocess the training data, specifically, it can perform preprocessing operations such as text cleaning, word segmentation, stop word removal, stemming, etc. to obtain a training set. Preprocessing the training data can reduce noise and extract meaningful information.

[0114] Step S504: training the test case generation model to be trained according to the training set, and adjusting the hyperparameters during the training process to obtain the test case generation model.

[0115] In the implementation of the present application, the terminal device may first convert the training set into a form that can be processed by the model. Specifically, each word in the training set may be converted into a corresponding vector representation, also known as word embedding. Commonly used word embedding methods include Word2Vec, GloVe, and FastText.

[0116] The terminal device can input the converted training set into the GPT model for training. During the training process, the GPT model can learn how to predict the next word based on the input text, or fill in the blanks in the text. Through training, the prediction of the GPT model can be made as close as possible to the real text content, thereby learning the semantics and grammatical rules of the text data.

[0117] During the training process, the terminal device can adjust the hyperparameters of the GPT model, such as learning rate, batch size, number of training rounds, etc., to obtain the best model performance.

[0118] In some implementations of the present application, for a trained test case generation model, the terminal device may also evaluate the trained test case generation model to obtain an evaluation result.

[0119] Specifically, the terminal device can use a portion of the training data as a validation set to evaluate the performance of the model. Common evaluation indicators include perplexity, etc. Evaluating the trained test case generation model can help determine whether the model is overfitting or underfitting and select the optimal model.

[0120] After the model training is completed, the trained GPT model parameters can be saved for use in subsequent applications and generation tasks, and the trained GPT model can be applied to specific standardized requirement specification documents and corresponding functional test cases.

[0121] Through the above training process, the GPT model can learn rich semantics and generation capabilities from large-scale text data. The trained model can be widely used in natural language processing tasks, including standardized requirements specification documents, functional test cases and other scenarios.

[0122] In some scenarios, the test cases generated by the terminal device may be flawed, which means that the test case generation model needs to be optimized.

[0123] In view of this, if Figure 6 As shown, in some implementations of the present application, after generating the test cases based on the functional information and the test requirements, the method may further include steps S601 to S605.

[0124] Step S601, obtaining feedback information obtained after executing the test case.

[0125] The feedback information is used to reflect the situation after executing the corresponding test case, and may include test results, errors, defects, etc.

[0126] In an implementation manner of the present application, the terminal device may execute the test case through a test management tool, and use the test management tool to obtain feedback information obtained after executing the test case.

[0127] Step S602: Analyze the feedback information to determine defects in the test case.

[0128] Among them, defects are used to reflect the problems and defects that exist when executing test cases, as well as the functional points and requirements that are not covered by the test cases.

[0129] In an implementation manner of the present application, the terminal device may analyze the collected feedback information to determine problems and defects in the test cases, as well as functional points and requirements that are insufficiently covered by the test cases.

[0130] Step S603: Optimize the test case according to the defect to obtain an optimized test case.

[0131] In the implementation manner of the present application, specific optimization measures may include: supplementing missing test cases to cover functional points and requirements that were not previously covered; optimizing the input data and boundary conditions of test cases to increase the coverage and effectiveness of test cases; and fixing errors and problems in test cases to ensure the correctness and accuracy of test cases.

[0132] Step S604, adding the optimized test cases to the training set of the test case generation model to obtain an optimized training set.

[0133] Step S605: training the test case generation model based on the optimized training set to obtain an optimized test case generation model.

[0134] In an implementation manner of the present application, the terminal device can add optimized test cases to the training set of the test case generation model to obtain an optimized training set, and use the optimized training set to train the test case generation model to obtain an optimized test case generation model, so that the optimized test case generation model can generate test cases with higher quality and better accuracy.

[0135] like Figure 7 As shown, in some implementations of the present application, after generating the test cases based on the functional information and the test requirements, the method may further include step S701 and step S702.

[0136] Step S701, obtaining preset evaluation rules.

[0137] Among them, the preset evaluation rules are used to evaluate test cases, which can evaluate code coverage, functional coverage, effectiveness, consistency, boundary condition coverage, executableness, and abnormal situation handling capabilities.

[0138] Specifically, code coverage is used to evaluate the coverage of test cases for software code, that is, whether the test cases have executed all branches and paths of the code. Functional coverage is used to evaluate whether the test cases cover all functional points and requirements of the software system. Effectiveness is used to evaluate whether the test cases are effective, that is, whether they can detect potential problems and defects. Consistency is used to evaluate whether the test cases are independent of each other and whether there are repeated or redundant test cases. Boundary condition coverage is used to evaluate whether the test cases cover the boundary conditions of the input parameters, such as maximum value, minimum value, boundary value and special value. Executability is used to evaluate whether the test cases can be executed in a specific test environment, including hardware, software and network environment. Abnormal situation handling capability is used to evaluate whether the test cases can capture and handle abnormal situations of the software system, such as error prompts, error handling, etc.

[0139] Step S702: Evaluate the test cases in turn according to preset evaluation rules to obtain evaluation results.

[0140] Among them, the evaluation results are used to reflect the quality of the test cases.

[0141] In an implementation manner of the present application, the terminal device may evaluate the test cases in sequence according to preset evaluation rules to obtain evaluation results.

[0142] Specifically, the terminal device can calculate the coverage for each test case: by executing the test case, monitoring the execution of the software code, and calculating the code coverage and function coverage. The effectiveness and consistency of the test case can also be analyzed: by analyzing the test case, check whether there are repeated or redundant test cases, and evaluate whether the test case can effectively detect problems and defects. The boundary condition coverage can also be checked: for the boundary conditions of the input parameters, check whether the test case covers various possible boundary conditions. The executableness can also be verified: by checking whether the test case can be correctly executed in the target test environment, the executableness of the test case can be ensured. The ability to handle abnormal situations can also be detected: when executing the test case, observe the software system's handling of abnormal situations and verify whether the test case can capture and detect abnormalities.

[0143] The implementation method of the present application evaluates the test cases to obtain scoring results, which can facilitate testers to optimize the test case generation process according to the scoring results, thereby improving test coverage and quality and ensuring the stability and reliability of the software system.

[0144] Figure 8 The schematic diagram of the structure of a test case generation device provided in an embodiment of the present application is shown. The test case generation device 8 can be configured on a terminal device. Specifically, the test case generation device 8 can include:

[0145] The acquisition module 801 is used to acquire a requirement file.

[0146] The processing module 802 is used to perform standardization processing on the requirement document to obtain a requirement specification document.

[0147] The input module 803 is used to input the requirement specification document into the test case generation model to obtain functional information and test requirements.

[0148] The generating module 804 is used to generate test cases based on the functional information and the test requirements.

[0149] The beneficial effect of the embodiment of the present application compared with the prior art is that the embodiment of the present application obtains the requirement file and standardizes the requirement file to obtain the requirement specification document, inputs the requirement specification document into the test case generation model to obtain functional information and test requirements, and then generates test cases based on the functional information and test requirements. The embodiment of the present application obtains functional information and test requirements by standardizing the requirement file and inputting it into the test case generation model, and then automatically generates test cases without manually writing test cases, thereby improving generation efficiency and the quality of test cases and reducing generation costs.

[0150] In some embodiments of the present application, the above-mentioned processing module 802 can also be used for: extracting keywords from the requirement file to obtain a first keyword; generating an initial requirement specification document based on the first keyword; performing text cleaning on the initial requirement specification document to obtain a cleaned requirement specification document; performing word segmentation on the cleaned requirement specification document to obtain a segmented requirement specification document; performing syntactic analysis on the segmented requirement specification document to obtain an analyzed requirement specification document; and vectorizing the analyzed requirement specification document to obtain a requirement specification document.

[0151] In some embodiments of the present application, the test case generation model includes a named entity recognition unit, a word segmentation unit, a part-of-speech tagging unit, a keyword extraction unit, a syntactic analysis unit, a sentence structure extraction unit, and an output unit. The input module 803 can also be used to: input the requirement specification document into the named entity recognition unit, perform named entity recognition on the requirement specification document, and obtain a recognition result; input the recognition result into the word segmentation unit, perform word segmentation on the recognition result, and obtain a word segmentation result; input the word segmentation result into the part-of-speech tagging unit, perform part-of-speech tagging on the word segmentation result, and obtain a tagging result; input the recognition result and the tagging result into the keyword extraction unit to obtain a second keyword; input the second keyword into the syntactic analysis unit, perform syntactic analysis on the second keyword, and obtain an analysis result; input the analysis result into the sentence structure extraction unit to obtain a sentence structure; input the second keyword, the tagging result, and the sentence structure into the output unit, and output functional information and test requirements.

[0152] In some embodiments of the present application, the above-mentioned generation module 804 can also be used to: generate input data, operation steps and expected results according to functional information and test requirements; generate initial test cases according to functional information, test requirements, input data, operation steps and expected results; generate use case numbers, test conditions, prerequisites, use case descriptions, additional information, use case priorities and importance according to functional information and test requirements; add use case numbers, test conditions, prerequisites, use case descriptions, additional information, use case priorities and importance to the initial test cases to obtain test cases.

[0153] In some embodiments of the present application, the above-mentioned test case generation device 8 may also include a training block, which is used to: construct a test case generation model to be trained; obtain data to be trained; preprocess the training data to obtain a training set; train the test case generation model to be trained according to the training set, and adjust hyperparameters during the training process to obtain a test case generation model.

[0154] In some embodiments of the present application, the above-mentioned test case generation device 8 also includes an optimization module, which is used to: obtain feedback information obtained after executing the test case; analyze the feedback information to determine the defects in the test case; optimize the test case according to the defects to obtain an optimized test case; add the optimized test case to the training set of the test case generation model to obtain an optimized training set; train the test case generation model based on the optimized training set to obtain an optimized test case generation model.

[0155] In some embodiments of the present application, the test case generation device 8 may further include an evaluation module, which is used to: obtain preset evaluation rules; and evaluate the test cases in sequence according to the preset evaluation rules to obtain evaluation results.

[0156] like Fig. 9 FIG. 1 is a schematic diagram of a terminal device provided in an embodiment of the present application. The terminal device 9 may include: a processor 901, a memory 902, and a computer program 903 stored in the memory 902 and executable on the processor 901, such as a test case generation program. When the processor 901 executes the computer program 903, the steps in the above-mentioned test case generation method embodiments are implemented, such as Figure 1 Alternatively, when the processor 901 executes the computer program 903, the functions of each module / unit in the above-mentioned device embodiments are realized, for example Figure 8 The receiving module 801, the first obtaining module 802, the judging module 803, and the second obtaining module 804 are shown.

[0157] The computer program may be divided into one or more modules / units, which are stored in the memory 902 and executed by the processor 901 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program in the terminal device.

[0158] The terminal device may include, but is not limited to, a processor 901 and a memory 902. Those skilled in the art will appreciate that Fig. 9 It is only an example of a terminal device and does not constitute a limitation of the terminal device. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the terminal device may also include input and output devices, network access equipment, buses, etc.

[0159] The processor 901 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0160] The memory 902 may be an internal storage unit of the terminal device, such as a hard disk or memory of the terminal device. The memory 902 may also be an external storage device of the terminal device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device. Further, the memory 902 may also include both an internal storage unit of the terminal device and an external storage device. The memory 902 is used to store the computer program and other programs and data required by the terminal device. The memory 902 may also be used to temporarily store data that has been output or is to be output.

[0161] It should be noted that, for the convenience and brevity of description, the structure of the above-mentioned terminal device can also refer to the specific description of the structure in the method embodiment, which will not be repeated here.

[0162] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0163] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned test case generation method can be implemented.

[0164] An embodiment of the present application provides a computer program product. When the computer program product is run on a mobile terminal, the steps in the above-mentioned test case generation method can be implemented when the mobile terminal executes the computer program product.

[0165] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0166] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0167] In the embodiments provided in the present application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

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

[0169] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0170] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0171] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A method for generating test cases, It is characterized in that include: Get the requirements document; Standardizing the requirement document to obtain a requirement specification document; Inputting the requirement specification document into a test case generation model to obtain functional information and test requirements; Generate a test case based on the functional information and the test requirement; The standardization of the requirement document to obtain the requirement specification document includes: Extracting keywords from the demand document to obtain a first keyword; generating an initial requirements specification document based on the first keyword; Performing text cleaning on the initial requirement specification document to obtain a cleaned requirement specification document; Performing word segmentation on the cleaned requirement specification document to obtain a word segmented requirement specification document; Performing syntactic analysis on the word-segmented requirement specification document to obtain an analyzed requirement specification document; Vectorizing the analyzed requirement specification document to obtain the requirement specification document; The test case generation model includes a named entity recognition unit, a word segmentation unit, a part-of-speech tagging unit, a keyword extraction unit, a syntactic analysis unit, a sentence structure extraction unit, and an output unit. The requirement specification document is input into the test case generation model to obtain functional information and test requirements, including: Inputting the requirement specification document into the named entity recognition unit, performing named entity recognition on the requirement specification document, and obtaining a recognition result; Inputting the recognition result into the word segmentation unit, performing word segmentation on the recognition result to obtain a word segmentation result; Inputting the word segmentation result into the part-of-speech tagging unit, performing part-of-speech tagging on the word segmentation result, and obtaining a tagging result; Inputting the recognition result and the marking result into the keyword extraction unit to obtain a second keyword; Inputting the second keyword into the syntactic analysis unit, performing syntactic analysis on the second keyword, and obtaining an analysis result; Inputting the analysis result into the sentence structure extraction unit to obtain a sentence structure; The second keyword, the annotation result and the sentence structure are input into the output unit, and the function information and the test requirement are output.

2. The method for generating a test case according to claim 1, It is characterized in that The generating of test cases based on the functional information and the test requirements includes: Generate input data, operation steps and expected results according to the functional information and the test requirements; Generate an initial test case according to the functional information, the test requirements, the input data, the operation steps and the expected results; Generate a use case number, test conditions, prerequisites, use case description, additional information, use case priority and importance according to the functional information and the test requirements; The test case is obtained by adding the use case number, the test condition, the prerequisite, the use case description, the additional information, the use case priority and the importance to the initial test case.

3. The method for generating a test case according to claim 1, It is characterized in that Before inputting the requirement specification document into the test case generation model, the method further includes: Build a model to generate test cases to be trained; Get the data to be trained; Preprocessing the data to be trained to obtain a training set; The test case generation model to be trained is trained according to the training set, and hyperparameters are adjusted during the training process to obtain the test case generation model.

4. The method for generating a test case according to claim 1, It is characterized in that After generating the test case based on the functional information and the test requirement, the method further includes: Obtaining feedback information obtained after executing the test case; Analyzing the feedback information to determine defects in the test case; According to the defect, the test case is optimized to obtain an optimized test case; Adding the optimized test case to the training set of the test case generation model to obtain an optimized training set; The test case generation model is trained based on the optimized training set to obtain an optimized test case generation model.

5. The method for generating a test case according to claim 1, It is characterized in that After generating the test case based on the functional information and the test requirement, the method further includes: Get preset evaluation rules; The test cases are evaluated in sequence according to the preset evaluation rules to obtain evaluation results.

6. A test case generation device, It is characterized in that include: Acquisition module, used to obtain requirement files; A processing module, used for standardizing the demand document to obtain a demand specification document; An input module, used for inputting the requirement specification document into the test case generation model to obtain functional information and test requirements; A generating module, used for generating a test case based on the functional information and the test requirement; Wherein, the processing module is also used for: Extracting keywords from the demand document to obtain a first keyword; generating an initial requirements specification document based on the first keyword; Performing text cleaning on the initial requirement specification document to obtain a cleaned requirement specification document; Performing word segmentation on the cleaned requirement specification document to obtain a word segmented requirement specification document; Performing syntactic analysis on the word-segmented requirement specification document to obtain an analyzed requirement specification document; Vectorizing the analyzed requirement specification document to obtain the requirement specification document; The test case generation model includes a named entity recognition unit, a word segmentation unit, a part-of-speech tagging unit, a keyword extraction unit, a syntactic analysis unit, a sentence structure extraction unit, and an output unit. The input module is also used for: Inputting the requirement specification document into the named entity recognition unit, performing named entity recognition on the requirement specification document, and obtaining a recognition result; Inputting the recognition result into the word segmentation unit, performing word segmentation on the recognition result to obtain a word segmentation result; Inputting the word segmentation result into the part-of-speech tagging unit, performing part-of-speech tagging on the word segmentation result, and obtaining a tagging result; Inputting the recognition result and the marking result into the keyword extraction unit to obtain a second keyword; Inputting the second keyword into the syntactic analysis unit, performing syntactic analysis on the second keyword, and obtaining an analysis result; Inputting the analysis result into the sentence structure extraction unit to obtain a sentence structure; The second keyword, the annotation result and the sentence structure are input into the output unit, and the function information and the test requirement are output.

7. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the test case generation method according to any one of claims 1 to 5 when executing the computer program.

8. A computer-readable storage medium storing a computer program. It is characterized in that When the computer program is executed by a processor, the steps of the test case generation method according to any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Test case recommendation method and device and electronic equipment

    CN112416778A

  • Test case generation method and related device

    CN114647590A

  • Ranking model training method and device based on user retrieval, equipment and medium

    CN114676307A

  • Software scale measurement method based on demand identification

    CN114706559A

  • Software test case automatic generation method and tool based on demand specification

    CN115344504A