CN117707922A - Method and device for generating test case, terminal equipment and readable storage medium - Google Patents

Method and device for generating test case, terminal equipment and readable storage medium Download PDF

Info

Publication number
CN117707922A
CN117707922A CN202311376022.3A CN202311376022A CN117707922A CN 117707922 A CN117707922 A CN 117707922A CN 202311376022 A CN202311376022 A CN 202311376022A CN 117707922 A CN117707922 A CN 117707922A
Authority
CN
China
Prior art keywords
test
test case
requirement
generating
specification document
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311376022.3A
Other languages
Chinese (zh)
Inventor
高建琼
万正勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jiuke Information Technology Shenzhen Co ltd
Original Assignee
Jiuke Information Technology Shenzhen Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jiuke Information Technology Shenzhen Co ltd filed Critical Jiuke Information Technology Shenzhen Co ltd
Priority to CN202311376022.3A priority Critical patent/CN117707922A/en
Publication of CN117707922A publication Critical patent/CN117707922A/en
Pending legal-status Critical Current

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/30Computing systems specially adapted for manufacturing

Landscapes

  • Stored Programmes (AREA)

Abstract

The application is applicable to the technical field of information processing, and provides a method and a device for generating test cases, terminal equipment and a readable storage medium. The method for generating the test case comprises the following steps: acquiring a demand file; carrying out standardized processing on the demand file to obtain a demand specification document; inputting the requirement specification document into a test case generation model to obtain functional information and test requirements; and generating test cases based on the functional information and the test requirements. According to the embodiment of the application, the function information and the test requirements can be obtained by carrying out standardized processing on the requirement file and inputting the test case generation model, so that the test case is automatically generated without manually writing the test case, the generation efficiency and the quality of the test case are improved, and the generation cost is reduced.

Description

Method and device for generating test case, terminal equipment and readable storage medium
Technical Field
The application belongs to the technical field of information processing, and particularly relates to a method and a device for generating test cases, terminal equipment and a readable storage medium.
Background
In the process of software development, functional testing is often required on software, and in the process of functional testing, functional testing is often required by using test cases. Test cases (Test cases) are a set of input data, operational steps, and expected results that are compiled for a particular target to Test a program path or to verify whether a particular requirement is met.
In the related art, the test cases are usually obtained by manual writing, but the problem of low generation efficiency, low quality and high cost exists in the manual writing of the test cases.
Disclosure of Invention
The embodiment of the application provides a method, a device, terminal equipment and a readable storage medium for generating test cases, which can solve the problems of low generation efficiency, low quality and high cost when the test cases are manually written in the related technology.
In a first aspect, an embodiment of the present application provides a method for generating a test case, including:
acquiring a demand file;
carrying out standardized processing on the demand file to obtain a demand specification document;
inputting the requirement specification document into a test case generation model to obtain functional information and test requirements;
and generating test cases based on the functional information and the test requirements.
In a specific implementation manner of the first aspect, the normalizing the requirement file to obtain a requirement specification document includes: extracting keywords from the demand file to obtain a first keyword; generating an initial demand specification document based on the first keyword; performing text cleaning on the initial requirement specification document to obtain a cleaned requirement specification document; the cleaned requirement specification document is segmented to obtain a segmented requirement specification document; carrying out syntactic analysis on the requirement specification document after word segmentation to obtain an analyzed requirement specification document; and vectorizing the analyzed requirement specification document to obtain the requirement specification document.
In a specific implementation manner of the first aspect, the test case generating model includes a named entity identifying unit, a word segmentation unit, a part of speech tagging unit, a keyword extracting unit, a syntax analysis unit, a sentence structure extracting unit, and an output unit, and the inputting the requirement specification document into the test case generating model to obtain functional information and a test requirement includes: inputting the requirement specification document into a named entity recognition unit, and recognizing the named entity of the requirement specification document to obtain a recognition result; inputting the recognition result into a word segmentation unit, and segmenting the recognition result to obtain a word segmentation result; inputting the word segmentation result into a part-of-speech tagging unit, and performing part-of-speech tagging on the word segmentation result to obtain a tagging result; inputting the identification result and the labeling result into a keyword extraction unit to obtain a second keyword; inputting the second keywords into a syntactic analysis unit, and syntactic analyzing the second keywords to obtain analysis results; inputting the analysis result into a sentence structure extraction unit to obtain a sentence structure; and inputting the second keyword, the labeling result and the sentence structure into an output unit, and outputting the functional information and the test requirement.
In a specific implementation manner of the first aspect, the generating a test case based on the functional information and the test requirement includes: generating input data, operation steps and expected results according to the functional information and the test requirements; generating an initial test case according to the functional information, the test requirement, the input data, the operation steps and the expected result; generating a case number, test conditions, preconditions, case descriptions, additional information, case priorities and importance according to the functional information and the test requirements; and adding the case number, the test condition, the precondition, the case description, the additional information, the case priority and the importance to the initial test case to obtain the test case.
In a specific implementation manner of the first aspect, before the inputting the requirement specification document into the test case generating model, the method further includes: constructing a test case generation model to be trained; acquiring data to be trained; preprocessing data to be trained to obtain a training set; and training the test case generation model to be trained according to the training set, and adjusting the super parameters in the training process to obtain the test case generation model.
In a specific implementation manner of the first aspect, after generating the test case based on the functional information and the test requirement, the method further includes: acquiring feedback information obtained after executing the test case; analyzing the feedback information to determine defects in the test cases; optimizing the test case according to the defects to obtain an optimized test case; adding the optimized test case into a training set of the test case generation model to obtain an optimized training set; and training the test case generating model based on the optimized training set to obtain the optimized test case generating model.
In a specific implementation manner of the first aspect, after generating the test case based on the functional information and the test requirement, the method further includes: acquiring a preset evaluation rule; and sequentially evaluating the test cases according to a preset evaluation rule to obtain an evaluation result.
In a second aspect, an embodiment of the present application provides a generating device for a test case, including:
the acquisition module is used for acquiring the demand file;
the processing module is used for carrying out standardized processing on the requirement file to obtain a requirement specification document;
the input module is used for inputting the requirement specification document into the test case generation model to obtain functional information and test requirements;
And the generating module is used for generating test cases based on the functional information and the test requirements.
In a third aspect, an embodiment of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor, where the processor implements the steps of the method for generating a test case described above when the processor executes the computer program.
In a fourth aspect, embodiments of the present application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the method for generating test cases described above.
In a fifth aspect, embodiments of the present application provide a computer program product, which when run on a terminal device, causes the terminal device to execute the method for generating a test case as described above.
Compared with the prior art, the beneficial effects of the embodiment of the application are as follows: according to the embodiment of the application, the requirement file is obtained, standardized processing is carried out on the requirement file, the requirement specification document is obtained, the function information and the test requirement are obtained by inputting the requirement specification document into the test case generation model, and the test case is generated based on the function information and the test requirement. According to the embodiment of the application, the function information and the test requirements can be obtained by carrying out standardized processing on the requirement file and inputting the test case generation model, so that the test case is automatically generated without manually writing the test case, the generation efficiency and the quality of the test case are improved, and the generation cost is reduced.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required for the embodiments or the description of the prior art will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic implementation flow chart of a method for generating test cases according to an embodiment of the present application;
FIG. 2 is a schematic diagram of an implementation flow chart of a normalization process for a demand file according to an embodiment of the present application;
FIG. 3 is a schematic diagram of an implementation flow for obtaining functional information and test requirements according to an embodiment of the present application;
FIG. 4 is a schematic diagram of an implementation flow for generating test cases according to an embodiment of the present application;
FIG. 5 is a schematic diagram of an implementation flow of a training test case generation model provided in an embodiment of the present application;
FIG. 6 is a schematic diagram of an implementation flow of an optimization test case generation model provided in an embodiment of the present application;
FIG. 7 is a schematic diagram of an implementation flow of an evaluation test case according to an embodiment of the present application;
FIG. 8 is a schematic structural diagram of a device for generating test cases according to an embodiment of the present application;
Fig. 9 is a schematic structural diagram of a terminal device provided in an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present application without making any inventive effort, are intended to be protected herein.
It is noted that the terms "comprising," "including," and "having," and any variations thereof, in the description and claims of the present application and in the foregoing figures, are intended to cover non-exclusive inclusions. For example, a process, method, terminal, article, or apparatus that comprises a list of steps or elements is not limited to only those listed steps or elements but may include other steps or elements not listed or inherent to such process, method, article, or apparatus. In the claims, specification, and drawings of this application, relational terms such as "first" and "second," and the like are used solely to distinguish one entity/operation/object from another entity/operation/object without necessarily requiring or implying any such real-time relationship or order between such entities/operations/objects.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the present application. The appearances of such phrases in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of skill in the art will explicitly and implicitly appreciate that the embodiments described herein may be combined with other embodiments.
In the process of software development, functional testing is often required on software, and in the process of functional testing, functional testing is often required by using test cases. Test cases (Test cases) are a set of input data, operational steps, and expected results that are compiled for a particular target to Test a program path or to verify whether a particular requirement is met. In the related art, the test cases are usually obtained by manual writing, but the problem of low generation efficiency, low quality and high cost exists in the manual writing of the test cases.
In view of this, according to the embodiment of the application, through carrying out standardized processing on the requirement file and inputting the test case generation model, the functional information and the test requirement can be obtained, and then the test case is automatically generated, the test case does not need to be written manually, the generation efficiency and the quality of the test case are improved, and the generation cost is reduced.
In order to illustrate the technical solution of the present application, the following description is made by specific examples.
Fig. 1 shows a schematic implementation flow chart of a method for generating a test case according to an embodiment of the present application, where the method may be applied to a terminal device. The terminal device may be a mobile phone, tablet computer, notebook computer, ultra-mobile personal computer (UMPC), netbook, etc.
Specifically, the method for generating test cases may include the following steps S101 to S104.
Step S101, a demand file is acquired.
The requirement file describes functions and behaviors to be tested of the software, and the requirement file can be of the types of text, audio, pictures and the like. The functions and acts described above may include functional requirements and non-functional requirements. The functional requirements are used to describe the specific functions and importance of the software system to be implemented, such as user login, data query, file upload, etc. Non-functional requirements are used to describe other requirements of a software system in addition to functionality, such as performance requirements, security requirements, reliability requirements, etc.
In the embodiment of the application, the terminal device may receive the requirement file sent by the user, or acquire the requirement file through the network interface.
Step S102, carrying out standardization processing on the requirement file to obtain a requirement specification document.
Wherein, the requirement specification document is a document obtained by standardized processing of the requirement file, and the requirement document records functional requirement, non-functional requirement and other information (such as scene description, interface description and the like)
In the embodiment of the application, the requirement file cannot be directly input into the test case generation model in the subsequent step. Therefore, the terminal equipment can firstly perform structural processing on the requirement file and then perform standardization processing to obtain the requirement specification document which can be directly input into the test case generation model.
For non-text demand files such as audio and pictures, the standard processing of the demand files cannot be directly performed, and a demand specification document is generated.
Accordingly, in some embodiments of the present application, the requirement file includes a non-text requirement file and a text requirement file, after the requirement file is obtained, the method may further include the following steps before the requirement file is normalized to obtain the requirement specification document:
converting the non-text class requirement file into a text class requirement file.
In an embodiment of the present application, the terminal device may input the non-text class requirement file into a Natural Language Processing (NLP) tool, and convert the non-text class requirement file into the text class requirement file using the NLP tool. The NLP tool can perform speech recognition and image recognition, and can convert audio and pictures into documents.
According to the method and the device for generating the test case, the non-text type demand file can be converted into the text type demand file, so that the test case can be generated through subsequent processing. Therefore, the type of the required file input by the user is not limited, and the use experience of the user is improved.
Step S103, inputting the requirement specification document into a test case generation model to obtain functional information and test requirements.
The test case generation model is used for generating functional information and test requirements according to an input document, and can be a generation Pre-training (GPT) system large model. The functional information may be information about description, input, output, processing, etc. of the software functions, and the test requirement may be requirements and conditions to be met in the software test.
In the embodiment of the application, the terminal device can input the requirement specification document into the test case generation model, and the test case generation model can perform operations such as semantic analysis and grammar analysis on the requirement specification document to extract functional information and test requirements.
Step S104, generating test cases based on the functional information and the test requirements.
In the embodiment of the application, the terminal device can use the GPT model to generate the test case according to the functional information and the test requirement. After the test cases are generated, the method can be directly used for software testing, and evaluation screening can also be carried out.
Compared with the prior art, the beneficial effects of the embodiment of the application are as follows: according to the embodiment of the application, the requirement file is obtained, standardized processing is carried out on the requirement file, the requirement specification document is obtained, the function information and the test requirement are obtained by inputting the requirement specification document into the test case generation model, and the test case is generated based on the function information and the test requirement. According to the embodiment of the application, the function information and the test requirements can be obtained by carrying out standardized processing on the requirement file and inputting the test case generation model, so that the test case is automatically generated without manually writing the test case, the generation efficiency and the quality of the test case are improved, and the generation cost is reduced.
As shown in fig. 2, in some embodiments of the present application, the above-mentioned normalization process is performed on the requirement file to obtain the requirement specification document, which may specifically include step S201 and step S206.
Step S201, extracting keywords from the demand file to obtain a first keyword.
In the embodiment of the application, the terminal device may input the requirement file into the language model by using a natural language processing model, and extract the first keyword from the requirement file by predicting the probability of the text.
Step S202, generating an initial requirement specification document based on the first keyword.
In the embodiment of the application, the terminal device may input the first keyword into the GPT model and output the initial requirement specification document.
Specifically, the initial demand specification document may include: the function requirement is used for describing specific functions which the software system needs to realize, such as functions of user login, data query, file uploading and the like; non-functional requirements describing non-functional requirements of the software system, such as performance requirements, security requirements, reliability requirements, etc.; a user story for describing a user's usage scenario and expectations in a specific scenario through the user story, thereby helping a development team understand the user's needs; a scene description for describing an interaction process between the software system and the user by using the test case, wherein the interaction process comprises input, output, expected result and the like; the interface description is used for describing a user interface of the software system, and comprises page layout, interaction elements, operation flow and the like; the data requirements are used for describing the types, the data formats, the data sizes and the like of the data which need to be processed by the software system; constraints, such as time constraints, resource constraints, etc., used to describe constraints in the software development and testing process; hypothesis conditions, such as that certain functions have been implemented in other modules, are used to describe hypothesis conditions in the software development and testing process.
Generating an initial demand specification document requires natural language processing of the initial demand specification document. In the subsequent steps S203 to S205, the terminal device may perform natural language processing on the initial requirement specification document by means of the NLP tool.
Step S203, performing text cleaning on the initial requirement specification document to obtain a cleaned requirement specification document.
In the embodiment of the application, the terminal device can input the initial requirement specification document into the 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, and only reserve key text contents in the initial requirement specification document to obtain the cleaned requirement specification document.
Step S204, the cleaned requirement specification document is segmented, and the requirement specification document after segmentation is obtained.
In the embodiment of the application, the terminal device may input the cleaned requirement specification document into the NLP tool, word-segment the cleaned requirement specification document, split the cleaned requirement specification document into a sequence of words or phrases, and obtain the requirement specification document after word segmentation. The segmentation may divide the continuous text into semantic units, providing a basis for subsequent processing and analysis.
Step S205, carrying out syntactic analysis on the requirement specification document after word segmentation to obtain the requirement specification document after analysis.
In the embodiment of the application, the terminal device can input the requirement specification document after word segmentation into an NLP tool, perform syntactic analysis on the requirement specification document after word segmentation, and identify sentence structures, components and dependency relations of the requirement specification document after word segmentation to obtain the requirement specification document after analysis. Syntactic analysis can help the system understand the syntactic structure of a sentence, thereby better understanding the meaning of the sentence.
Step S206, vectorizing the analyzed requirement specification document to obtain the requirement specification document.
In the embodiment of the application, the terminal device may use Word Embedding (Word Embedding) technology to represent each Word as a vector, or use a text representation method (such as TF-IDF) to represent the whole text as a vector, so as to vectorize the analyzed requirement specification document, and obtain the requirement specification document.
The test case generating model may include a named entity recognition unit, a word segmentation unit, a part of speech tagging unit, a keyword extraction unit, a syntax analysis unit, a sentence structure extraction unit, and an output unit. As shown in fig. 3, the requirement specification document is input into the test case generation model to obtain the functional information and the test requirement, which may specifically include steps S301 to S307.
Step S301, inputting the requirement specification document into a named entity recognition unit, and recognizing the named entity of the requirement specification document to obtain a recognition result.
In the embodiment of the application, the terminal device may input the requirement specification document into the named entity identifying unit, and identify the named entity in the requirement specification document, such as a person name, a place name, a date, and the like, so as to obtain an identification result. Named entity recognition of the requirement specification document may correlate these entities with specific functional information and test requirements to further distinguish key information.
Step S302, inputting the recognition result into a word segmentation unit, and segmenting the recognition result to obtain a word segmentation result.
In the embodiment of the application, the terminal device may input the recognition result into the word segmentation unit, segment the recognition result, and split the recognition result into a sequence of words or phrases, thereby obtaining a word segmentation result. The segmentation may divide the continuous text into semantic units, providing a basis for subsequent processing and analysis.
Step S303, inputting the word segmentation result into a part-of-speech tagging unit, and performing part-of-speech tagging on the word segmentation result to obtain a tagging result.
In the embodiment of the application, the terminal device may input the word segmentation result into the part-of-speech tagging unit, tag the part-of-speech of the word segmentation result, and determine the part-of-speech of each word in the word segmentation result, thereby obtaining the tagged result. And part-of-speech tagging is carried out on the word segmentation result, so that roles and meanings of words in sentences can be understood.
Step S304, inputting the identification result and the labeling result into a keyword extraction unit to obtain a second keyword.
In the embodiment of the present application, the terminal device may input the recognition result and the labeling result into the keyword extraction unit, and extract keywords (these terms are usually core information in the requirement specification document) such as nouns, verbs, adjectives, and the like in the recognition result and the labeling result, so as to obtain the second keyword.
Step S305, inputting the second keywords into a syntactic analysis unit, and performing syntactic analysis on the second keywords to obtain analysis results.
In the embodiment of the application, the terminal device may input the second keyword into a syntax analysis unit, perform syntax analysis on the second keyword, and identify the sentence structure, the composition and the dependency relationship of the second keyword, so as to obtain an analysis result. Syntactic analysis can help the system understand the syntactic structure of a sentence, thereby better understanding the meaning of the sentence.
Step S306, inputting the analysis result into a sentence structure extraction unit to obtain a sentence structure.
In the embodiment of the application, the terminal device may input the analysis result into the sentence structure extraction unit, and extract structural information of a sentence in the analysis result, such as a subject-predicate-object structure, so as to capture key functional points in the sentence, and obtain a sentence structure.
Step S307, the second keyword, the labeling result and the sentence structure are input and output by the input and output unit, and the functional information and the test requirement are output.
In the embodiment of the application, the terminal device may input and output the second keyword, the labeling result and the sentence structure into and out of the unit, so as to output the functional information and the test requirement. Before outputting the functional information and the test requirement, the output unit can consider the context semantics of the requirement specification document, so that the extracted functional information and the test requirement can accurately reflect the intention of the requirement specification document.
In the embodiment of the application, after the requirement specification document is input into the test case generation model, the test case generation model performs operations such as named entity recognition, word segmentation, part of speech tagging, keyword extraction, syntactic analysis, sentence structure extraction, output and the like on the requirement specification document, outputs key functional information and test requirements, and ensures that the extracted functional information and test requirements can accurately reflect the intention of the requirement specification document, so that the test case generated later can accurately and comprehensively cover the test requirements of software.
As shown in fig. 4, in some embodiments of the present application, the generating a test case based on the functional information and the test requirement may specifically include steps S401 to S404.
In steps S401 to S404, the terminal device may generate test cases using the trained GPT model.
Step S401, input data, operation steps and expected results are generated according to the functional information and the test requirements.
The input data is data input into the tested software when the test case is executed, and may include various specific input values, parameter combinations, boundary conditions, and the like. The operation steps are a series of specific processes required when executing the test case, and may include inputting data, clicking a button, executing a command, and the like. The expected result is a software output result or response that is expected to be obtained when the test case is executed, including a correct result, an exception prompt, an error message, etc.
In the embodiment of the application, the terminal device may input the functional information and the test requirement into the GPT model, to obtain input data, an operation step and an expected result.
Step S402, generating an initial test case according to the functional information, the test requirement, the input data, the operation steps and the expected result.
In the embodiment of the application, after the input data, the operation steps and the expected result are obtained, the terminal device may combine the function information, the test requirement, the input data, the operation steps and the expected result to obtain the initial test case.
Step S403, generating case numbers, test conditions, preconditions, case descriptions, additional information, case priorities and importance according to the functional information and the test requirements.
Wherein, the case number of each test case is unique and is used for reference and tracking in the document. The test conditions may be conditions that must be met before the test case is executed, such as test environment, system configuration, data preparation, etc. The preconditions may be some conditions that the test case needs to satisfy before executing, otherwise the test case cannot execute. The description of the use case is used for describing the test use case in detail, and may include descriptions of test purposes, test environments, test steps, test results, and the like. The additional information may be supplementary description and remark information for the test case. The case priority and importance of the test case means that in the software test, the emergency degree and importance degree of the test case execute the test case according to a certain priority order.
In the embodiment of the present application, the terminal device may input the function information and the test requirement into the GPT model, to obtain the case number, the test condition, the precondition, the case description, the additional information, the case priority, and the importance. Use case priority and importance.
Step S404, adding case numbers, test conditions, preconditions, case descriptions, additional information, case priorities and importance to the initial test case to obtain the test case.
In the embodiment of the application, the terminal device may sequentially add the case number, the test condition, the precondition, the case description, the additional information, the case priority, the importance and the like to the initial test case, so as to obtain a complete test case.
In addition, the terminal equipment can classify the generated test cases according to the function points or the test requirements, so that the logic and the structure of the test cases are clear. Each test case should contain information such as input data, operating steps, and expected results to form a complete test case.
After the complete test case is obtained, the terminal equipment can verify and screen the generated test case so as to ensure that the test case meets the expectations and cover the functional points and the test requirements. Screening eliminates duplicate, redundant or unsuitable test cases, thereby improving the quality and readability of test cases. And formatting and typesetting the test cases to ensure that the format and typesetting of the whole document meet the standards of companies or industries, including fonts, word sizes, titles, header footers and the like. After the test case is generated, the quality of the test case can be verified, and the correctness, the integrity and the effectiveness of the test case are ensured. Verification may be accomplished by either simulating the execution of test cases or comparing expected results with actual results. In addition, the grammar and format of the test case can be checked to ensure that the grammar and format of the test case meet the specifications and standards, so that the test case is easy to understand and execute. Finally, the test cases can be exported to a standard format document, specifically, the checked test cases and information can be exported to a standard document format, such as Microsoft Word or PDF, so as to be convenient for sharing and distribution.
Through the steps, the test cases meeting the standardized requirements can be output, the generated functional test cases and other key information are contained in the test cases, and a clear, accurate and executable test plan is provided for a test team so as to ensure that the functions and the quality of a software system are effectively verified.
As shown in fig. 5, in some embodiments of the present application, the method may further include step S501 and step S504 before the requirement specification document is input into the test case generating model.
Step S501, a test case generation model to be trained is constructed.
The test case generation model to be trained can be a GPT model to be trained.
In embodiments of the present application, the terminal device may construct the GPT model using a deep learning framework (e.g., tensorFlow or pyrerch). It should be appreciated that GPT model models are typically based on a transducer architecture, which is a neural network architecture with a mechanism of attention that has excellent performance for processing sequence data (e.g., text).
Step S502, obtaining data to be trained.
In the embodiment of the application, the terminal device can collect text data from the texts such as the local common requirement documents, the requirement templates, the use case data, the internet, books, articles, papers, news and the like on a large scale to serve as the data to be trained.
Step S503, preprocessing the data to be trained to obtain a training set.
In the embodiment of the application, the terminal device can preprocess the data to be trained, and specifically can perform preprocessing operations such as text cleaning, word segmentation, stop word removal, word drying and the like, so as to obtain a training set. Preprocessing the data to be trained can reduce noise and extract meaningful information.
Step S504, training the test case generation model to be trained according to the training set, and adjusting the super parameters in the training process to obtain the test case generation model.
In the embodiment of the application, the terminal device may first convert the training set into a form that can be processed by the model. Each Word in the training set may be specifically converted into a corresponding vector representation, also referred to as Word Embedding (Word Embedding). Common Word embedding methods are Word2Vec, gloVe, fastText, and the like.
The terminal device can input the converted training set into the GPT model for training. During training, the GPT model may learn how to predict the next word from the input text, or fill in a blank portion in the text. Through training, the prediction of the GPT model can be made to be as close to the real text content as possible, so that the semantic and grammar rules of the text data are learned.
In the training process, the terminal device can adjust the super parameters of the GPT model, such as learning rate, batch size, training round number, etc., so as to obtain the best model performance.
In some embodiments of the present application, for the trained test case generation model, the terminal device may further evaluate the trained test case generation model to obtain an evaluation result.
In particular, the terminal device may use a portion of the training data as a validation set for evaluating the performance of the model. Common evaluation indexes include confusion (perplexity) and the like. The trained test case generation model is evaluated, so that whether the model is over-fitted or under-fitted can be determined, and the optimal model is selected.
After model training is completed, the GPT model parameters obtained through training can be saved for subsequent application and generation tasks, and the GPT model obtained through training is applied to specific standardized requirement specification documents and corresponding functional test cases.
Through the training process, the GPT model can learn rich semantics and generating capacity from large-scale text data. The model obtained through training can be widely applied to natural language processing tasks, including scenes such as standardized requirement specification documents, functional test cases and the like.
In some scenarios, the test case generated by the terminal device may have defects, which means that the test case generation model needs to be optimized.
In view of this, as shown in fig. 6, in some embodiments of the present application, after generating the test case based on the functional information and the test requirement, the method may further include steps S601 to S605.
Step S601, obtaining feedback information obtained after executing the test case.
The feedback information is used for reflecting the situation after the corresponding test case is executed, and may include a test result, an error, a defect, and the like.
In the embodiment of the application, the terminal equipment can execute the test case through the test management tool, and the feedback information obtained after the test case is executed is obtained by utilizing the test management tool.
Step S602, analyzing the feedback information to determine the defects in the test cases.
The defects are used for reflecting problems and defects existing in the process of executing the test cases and functional points and requirements which are not covered by the test cases.
In the embodiment of the application, the terminal device can analyze the collected feedback information to determine problems and defects in the test case, and functional points and requirements of insufficient coverage of the test case.
And step S603, optimizing the test case according to the defects to obtain an optimized test case.
In embodiments of the present application, specific optimization measures may include: supplementing missing test cases to cover function points and requirements not related before; optimizing input data and boundary conditions of the test cases to increase coverage and effectiveness of the test cases; errors and problems existing in the test cases are repaired to ensure the correctness and the accuracy of the test cases.
Step S604, adding the optimized test case into the training set of the test case generation model to obtain an optimized training set.
Step S605, training the test case generating model based on the optimized training set to obtain the optimized test case generating model.
In the embodiment of the application, the terminal equipment can add the optimized test case into the training set of the test case generation model to obtain the optimized training set, and train the test case generation model by utilizing the optimized training set, so that the optimized test case generation model is obtained, and the optimized test case generation model can generate test cases with higher quality and better accuracy.
As shown in fig. 7, in some embodiments of the present application, after generating the test case based on the functional information and the test requirement, the method may further include step S701 and step S702.
Step S701, obtaining a preset evaluation rule.
The preset evaluation rule is used for evaluating the test cases, and can evaluate code coverage rate, function coverage rate, validity, consistency, boundary condition coverage rate, executable performance, abnormal condition processing capacity and the like.
Specifically, the code coverage rate is used for evaluating the coverage rate of the test case on the software code, namely whether the test case executes each branch and path of the code. The functional coverage rate is used for evaluating whether the test case covers each functional point and requirement of the software system. Validity is used to evaluate whether the test case is valid, i.e., whether potential problems and defects can be detected. The consistency is used for evaluating whether the test cases are independent of each other or whether repeated or redundant test cases exist. The boundary condition coverage rate is used for evaluating whether the test case covers the boundary conditions of the input parameters, such as a maximum value, a minimum value, a boundary value, a special value and the like. The executability is used to evaluate whether the test case can be executed under specific test environments, including hardware, software, and network environments. The exception handling capability is used to evaluate whether the test case is capable of capturing and handling an exception condition of the software system, such as error hints, error handling, etc.
Step S702, sequentially evaluating the test cases according to a preset evaluation rule to obtain an evaluation result.
The evaluation result is used for reflecting the quality of the test case.
In the embodiment of the application, the terminal device can evaluate the test cases in sequence according to the preset evaluation rule to obtain an evaluation result.
Specifically, the terminal device may calculate coverage for each test case: and by executing the test cases, monitoring the execution condition of the software codes, and calculating the code coverage rate and the function coverage rate. The validity and consistency of test cases can also be analyzed: by analyzing the test cases, it is checked whether there are repeated or redundant test cases, and whether the test cases can effectively detect problems and defects is evaluated. Boundary condition coverage may also be checked: for the boundary conditions of the input parameters, it is checked whether the test cases cover various possible boundary conditions. The executability may also be verified: by checking whether the test cases can be executed correctly in the target test environment, the executability of the test cases is ensured. Abnormal situation handling capability may also be detected: when the test case is executed, the processing of the software system on the abnormal condition is observed, and whether the test case can capture and detect the abnormality is verified.
According to the method and the device for testing the software system, the test cases are evaluated to obtain the scoring results, so that testers can optimize the generation process of the test cases according to the scoring results, the testing coverage rate and the testing quality are improved, and the stability and the reliability of the software system are ensured.
Fig. 8 is a schematic structural diagram of a test case generating device provided in an embodiment of the present application, where the test case generating device 8 may be configured on a terminal device, and specifically, the test case generating device 8 may include:
an obtaining module 801, configured to obtain a requirement file.
And a processing module 802, configured to perform standardization processing on the requirement file to obtain a requirement specification document.
And the input module 803 is used for inputting the requirement specification document into the test case generation model to obtain the functional information and the test requirement.
The generating module 804 is configured to generate a test case based on the functional information and the test requirement.
Compared with the prior art, the beneficial effects of the embodiment of the application are as follows: according to the embodiment of the application, the requirement file is obtained, standardized processing is carried out on the requirement file, the requirement specification document is obtained, the function information and the test requirement are obtained by inputting the requirement specification document into the test case generation model, and the test case is generated based on the function information and the test requirement. According to the embodiment of the application, the function information and the test requirements can be obtained by carrying out standardized processing on the requirement file and inputting the test case generation model, so that the test case is automatically generated without manually writing the test case, the generation efficiency and the quality of the test case are improved, and the generation cost is reduced.
In some embodiments of the present application, the processing module 802 described above may also be used to: extracting keywords from the demand file to obtain a first keyword; generating an initial demand specification document based on the first keyword; performing text cleaning on the initial requirement specification document to obtain a cleaned requirement specification document; the cleaned requirement specification document is segmented to obtain a segmented requirement specification document; carrying out syntactic analysis on the requirement specification document after word segmentation to obtain an analyzed requirement specification document; and vectorizing the analyzed requirement specification document to obtain the requirement specification document.
In some embodiments of the present application, the test case generating model includes a named entity recognition unit, a word segmentation unit, a part of speech tagging unit, a keyword extraction unit, a syntax analysis unit, a sentence structure extraction unit, and an output unit, where the input module 803 may be further configured to: inputting the required specification document into a named entity recognition unit, and recognizing the named entity of the required specification document to obtain a recognition result; inputting the recognition result into a word segmentation unit, and segmenting the recognition result to obtain a word segmentation result; inputting the word segmentation result into a part-of-speech tagging unit, and performing part-of-speech tagging on the word segmentation result to obtain a tagging result; inputting the identification result and the labeling result into a keyword extraction unit to obtain a second keyword; inputting the second keywords into a syntactic analysis unit, and carrying out syntactic analysis on the second keywords to obtain analysis results; inputting the analysis result into a sentence structure extraction unit to obtain a sentence structure; and inputting the second keyword, the labeling result and the sentence structure into an output unit, and outputting the functional information and the test requirement.
In some embodiments of the present application, the generating module 804 may be further configured to: generating input data, operation steps and expected results according to the functional information and the test requirements; generating an initial test case according to the functional information, the test requirement, the input data, the operation steps and the expected result; generating a case number, test conditions, preconditions, case descriptions, additional information, case priorities and importance according to the functional information and the test requirements; and adding the case number, the test condition, the precondition, the case description, the additional information, the case priority and the importance to the initial test case to obtain the test case.
In some embodiments of the present application, the generating device 8 for test cases may further include a training block configured to: constructing a test case generation model to be trained; acquiring data to be trained; preprocessing data to be trained to obtain a training set; and training the test case generation model to be trained according to the training set, and adjusting the super parameters in the training process to obtain the test case generation model.
In some embodiments of the present application, the generating device 8 for a test case further includes an optimizing module, configured to: acquiring feedback information obtained after executing the test case; analyzing the feedback information to determine defects in the test cases; optimizing the test case according to the defects to obtain an optimized test case; adding the optimized test case into a training set of the test case generation model to obtain an optimized training set; and training the test case generating model based on the optimized training set to obtain the optimized test case generating model.
In some embodiments of the present application, the generating device 8 for a test case may further include an evaluation module configured to: acquiring a preset evaluation rule; and sequentially evaluating the test cases according to a preset evaluation rule to obtain an evaluation result.
Fig. 9 is a schematic diagram of a terminal device according to an embodiment of the present application. The terminal device 9 may include: a processor 901, a memory 902, and a computer program 903, such as a test case generator, stored in the memory 902 and executable on the processor 901. The processor 901 implements the steps in the embodiment of the method for generating test cases described above, such as steps S101 to S104 shown in fig. 1, when executing the computer program 903. Alternatively, the processor 901 may implement the functions of the modules/units in the above-described apparatus embodiments when executing the computer program 903, for example, the receiving module 801, the first acquiring module 802, the judging module 803, and the second acquiring module 804 shown in fig. 8.
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 performing the specified functions, which instruction segments are used for describing the execution of the computer program in the terminal device.
The terminal device may include, but is not limited to, a processor 901, a memory 902. It will be appreciated by those skilled in the art that fig. 9 is merely an example of a terminal device and is not limiting of the terminal device, and may include more or fewer components than shown, or may combine some components, or different components, e.g., the terminal device may also include input and output devices, network access devices, buses, etc.
The processor 901 may be a central processing unit (Central Processing Unit, CPU), other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), off-the-shelf programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 902 may be an internal storage unit of the terminal device, such as a hard disk or a 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 memory Card (Flash Card) or the like. Further, the memory 902 may also include both an internal storage unit and an external storage device of the terminal device. The memory 902 is used for storing 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.
It should be noted that, for convenience and brevity of description, the structure of the above terminal device may also refer to a specific description of the structure in the method embodiment, which is not repeated herein.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions. The functional units and modules in the embodiment may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit, where the integrated units may be implemented in a form of hardware or a form of a software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working process of the units and modules in the above system may refer to the corresponding process in the foregoing method embodiment, which is not described herein again.
The embodiment of the application also provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program can realize the steps in the method for generating the test case when being executed by a processor.
The embodiment of the application provides a computer program product which can realize the steps in the method for generating the test case when being executed by a mobile terminal when the computer program product runs on the mobile terminal.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and in part, not described or illustrated in any particular embodiment, reference is made to the related descriptions of other embodiments.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/terminal device and method may be implemented in other manners. For example, the apparatus/terminal device embodiments described above are merely illustrative, e.g., the division of the modules or units is merely a logical function division, and there may be additional divisions in actual implementation, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection via interfaces, devices or units, which may be in electrical, mechanical or other forms.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of 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.
In addition, each functional unit in each embodiment of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated modules/units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the present application may implement all or part of the flow of the method of the above embodiment, or may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the computer program may implement the steps of each method embodiment described above. Wherein the computer program comprises computer program code which may be in source code form, object code form, executable file or some intermediate form etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth. It should be noted that the computer readable medium contains content that can be appropriately scaled according to the requirements of jurisdictions in which such content is subject to legislation and patent practice, such as in certain jurisdictions in which such content is subject to legislation and patent practice, the computer readable medium does not include electrical carrier signals and telecommunication signals.
The above embodiments are only for illustrating the technical solution of the present application, and are not limiting; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and are intended to be included in the scope of the present application.

Claims (10)

1. The method for generating the test case is characterized by comprising the following steps:
acquiring a demand file;
carrying out standardized processing on 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 the test requirement.
2. The method for generating test cases according to claim 1, wherein the normalizing the requirement file to obtain a requirement specification document comprises:
extracting keywords from the demand file to obtain a first keyword;
Generating an initial demand 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 requirement specification document subjected to word segmentation;
carrying out syntactic analysis on the requirement specification document subjected to word segmentation to obtain an analyzed requirement specification document;
and vectorizing the analyzed requirement specification document to obtain the requirement specification document.
3. The method for generating test cases according to claim 1, wherein 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 syntax analysis unit, a sentence structure extraction unit, and an output unit, and the inputting the requirement specification document into the test case generation model to obtain the functional information and the test requirement includes:
inputting the requirement specification document into the named entity recognition unit, and recognizing the named entity of the requirement specification document to obtain a recognition result;
Inputting the recognition result into the word segmentation unit, and segmenting the recognition result to obtain a word segmentation result;
inputting the word segmentation result into the part-of-speech tagging unit, and tagging the word segmentation result with part-of-speech to obtain a tagging result;
inputting the identification result and the labeling result into the keyword extraction unit to obtain a second keyword;
inputting the second keywords into the syntactic analysis unit, and carrying out syntactic analysis on the second keywords to obtain analysis results;
inputting the analysis result into the sentence structure extraction unit to obtain a sentence structure;
and inputting the second keyword, the labeling result and the sentence structure into the output unit, and outputting the functional information and the test requirement.
4. The method for generating test cases according to claim 1, wherein the generating test cases based on the functional information and the test requirements comprises:
generating input data, operation steps and expected results according to the functional information and the test requirements;
generating an initial test case according to the functional information, the test requirement, the input data, the operation steps and the expected result;
Generating a case number, a test condition, a precondition, a case description, additional information, a case priority and importance according to the functional information and the test requirement;
and adding the case number, the test condition, the precondition, the case description, the additional information, the case priority and the importance to the initial test case to obtain the test case.
5. The method for generating test cases according to claim 1, wherein before said inputting the requirement specification document into the test case generation model, the method further comprises:
constructing a test case generation model to be trained;
acquiring data to be trained;
preprocessing the data to be trained to obtain a training set;
and training the test case generation model to be trained according to the training set, and adjusting the super parameters in the training process to obtain the test case generation model.
6. The method for generating test cases according to claim 1, wherein after said generating test cases based on said function information and said test requirements, said method further comprises:
Acquiring feedback information obtained after the test case is executed;
analyzing the feedback information to determine defects in the test cases;
optimizing the test case according to the defects to obtain an optimized test case;
adding the optimized test case into a training set of the test case generation model to obtain an optimized training set;
and training the test case generation model based on the optimized training set to obtain an optimized test case generation model.
7. The method for generating test cases according to claim 1, wherein after said generating test cases based on said function information and said test requirements, said method further comprises:
acquiring a preset evaluation rule;
and sequentially evaluating the test cases according to the preset evaluation rules to obtain an evaluation result.
8. A test case generating apparatus, comprising:
the acquisition module is used for acquiring the demand file;
the processing module is used for carrying out standardized processing on the requirement file to obtain a requirement specification document;
the input module is used for inputting the requirement specification document into a test case generation model to obtain functional information and test requirements;
And the generating module is used for generating test cases based on the functional information and the test requirements.
9. A terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the steps of the method of generating test cases according to any one of claims 1 to 7 when the computer program is executed.
10. A computer-readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the steps of the test case generation method according to any one of claims 1 to 7.
CN202311376022.3A 2023-10-20 2023-10-20 Method and device for generating test case, terminal equipment and readable storage medium Pending CN117707922A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311376022.3A CN117707922A (en) 2023-10-20 2023-10-20 Method and device for generating test case, terminal equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311376022.3A CN117707922A (en) 2023-10-20 2023-10-20 Method and device for generating test case, terminal equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN117707922A true CN117707922A (en) 2024-03-15

Family

ID=90157724

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311376022.3A Pending CN117707922A (en) 2023-10-20 2023-10-20 Method and device for generating test case, terminal equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN117707922A (en)

Similar Documents

Publication Publication Date Title
CN110852065B (en) Document auditing method, device, system, equipment and storage medium
CN110163478B (en) Risk examination method and device for contract clauses
US20230004604A1 (en) Ai-augmented auditing platform including techniques for automated document processing
CN108170468B (en) Method and system for automatically detecting annotation and code consistency
US20200005089A1 (en) System and method for enrichment of ocr-extracted data
WO2021121158A1 (en) Official document file processing method, apparatus, computer device, and storage medium
CN112464927B (en) Information extraction method, device and system
CN113312258A (en) Interface testing method, device, equipment and storage medium
CN110852082B (en) Synonym determination method and device
CN116881971A (en) Sensitive information leakage detection method, device and storage medium
CN117272982A (en) Protocol text detection method and device based on large language model
CN114969334B (en) Abnormal log detection method and device, electronic equipment and readable storage medium
CN116453125A (en) Data input method, device, equipment and storage medium based on artificial intelligence
CN116360794A (en) Database language analysis method, device, computer equipment and storage medium
CN116385189A (en) Method and system for checking matching degree of account listed subjects of financial account-reporting document
CN115373982A (en) Test report analysis method, device, equipment and medium based on artificial intelligence
CN115687136A (en) Script program processing method, system, computer equipment and medium
CN117707922A (en) Method and device for generating test case, terminal equipment and readable storage medium
CN113836297A (en) Training method and device for text emotion analysis model
US20230140546A1 (en) Randomizing character corrections in a machine learning classification system
CN113239205B (en) Data labeling method, device, electronic equipment and computer readable storage medium
CN113779251B (en) Clue information acquisition method, clue information acquisition device, clue information acquisition medium and electronic equipment
Flynn Document classification in support of automated metadata extraction form heterogeneous collections
Akyıldız Text2test: From Natural Language Descriptions To Executable Test Cases Using Named Entity Recognition
CN115238037A (en) Function point generation method and device based on agile user story

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination