CN114647590A - Test case generation method and related device - Google Patents

Test case generation method and related device Download PDF

Info

Publication number
CN114647590A
CN114647590A CN202210341714.3A CN202210341714A CN114647590A CN 114647590 A CN114647590 A CN 114647590A CN 202210341714 A CN202210341714 A CN 202210341714A CN 114647590 A CN114647590 A CN 114647590A
Authority
CN
China
Prior art keywords
sample
product
modules
demand
test case
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
CN202210341714.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.)
Weikun Shanghai Technology Service Co Ltd
Original Assignee
Weikun Shanghai Technology Service 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 Weikun Shanghai Technology Service Co Ltd filed Critical Weikun Shanghai Technology Service Co Ltd
Priority to CN202210341714.3A priority Critical patent/CN114647590A/en
Publication of CN114647590A publication Critical patent/CN114647590A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • G06F40/211Syntactic parsing, e.g. based on context-free grammar [CFG] or unification grammars
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/284Lexical analysis, e.g. tokenisation or collocates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • GPHYSICS
    • G10MUSICAL INSTRUMENTS; ACOUSTICS
    • G10LSPEECH ANALYSIS TECHNIQUES OR SPEECH SYNTHESIS; SPEECH RECOGNITION; SPEECH OR VOICE PROCESSING TECHNIQUES; SPEECH OR AUDIO CODING OR DECODING
    • G10L15/00Speech recognition
    • G10L15/02Feature extraction for speech recognition; Selection of recognition unit
    • GPHYSICS
    • G10MUSICAL INSTRUMENTS; ACOUSTICS
    • G10LSPEECH ANALYSIS TECHNIQUES OR SPEECH SYNTHESIS; SPEECH RECOGNITION; SPEECH OR VOICE PROCESSING TECHNIQUES; SPEECH OR AUDIO CODING OR DECODING
    • G10L15/00Speech recognition
    • G10L15/26Speech to text systems

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • General Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Human Computer Interaction (AREA)
  • Multimedia (AREA)
  • Acoustics & Sound (AREA)
  • Biophysics (AREA)
  • Evolutionary Computation (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Data Mining & Analysis (AREA)
  • Biomedical Technology (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The embodiment of the application discloses a test case generation method and a related device, and the method comprises the following steps: acquiring a product demand audio of a target version of a product to be detected; converting the product requirement audio into a product requirement text according to a preset voice conversion method; and inputting the product requirement text into a test case generation model, and generating a target test case of the product to be tested through the test case generation model. The embodiment of the application can greatly improve the generation efficiency of the test case, reduce the operation flow and save the test cost and the labor cost.

Description

Test case generation method and related device
Technical Field
The present disclosure relates to the field of automated testing technologies, and in particular, to a test case generation method and a related device.
Background
With the development of computer technology, data communication, network engineering, and IT industry companies, automated testing technology has received increasing attention and usage. When the automated test is realized, a test case is generally selected. In the related technology, when a test case is selected, the test case is generally selected by manual experience, so that the cost is too high, the efficiency is low, and the quality of test key points in all test cases cannot be guaranteed.
Disclosure of Invention
The embodiment of the application provides a test case generation method and a related device, which greatly improve the test case generation efficiency, reduce the operation flow and save the test cost and the labor cost.
In a first aspect, an embodiment of the present application provides a test case generation method, where the method includes: acquiring a product demand audio of a target version of a product to be detected; converting the product requirement audio into a product requirement text according to a preset voice conversion method; and inputting the product requirement text into a test case generation model, and generating a target test case of the product to be tested through the test case generation model.
Optionally, the inputting the product requirement text into a test case generation model, and generating the target test case of the product to be tested through the test case generation model includes: preprocessing the product demand text to obtain N product demand modules, wherein N is a positive integer; acquiring N product demand module characteristics of the N product demand modules, wherein the product demand modules correspond to the product demand module characteristics one to one; comparing the N product demand module characteristics with pre-stored sample demand module characteristics to obtain N target sample demand module characteristics matched with the N product demand module characteristics, wherein the product demand module characteristics correspond to the target sample demand module characteristics one to one; acquiring N first sample use case modules corresponding to the N target sample demand module characteristics, wherein the target sample demand module characteristics correspond to the first sample use case modules one to one; and splicing the N first sample case modules to obtain a target test case of the product to be tested.
Optionally, the preprocessing the product requirement text to obtain N product requirement modules includes: detecting sentence boundaries of the product demand text, and blocking the product demand text according to the sentence boundaries to obtain N product demand basic modules, wherein the sentence boundaries comprise periods and semicolons; performing word segmentation processing on the N product demand basic modules; and stopping words from the N product demand texts after word segmentation processing to obtain the N product demand modules.
Optionally, the obtaining N product requirement module characteristics of the N product requirement modules includes: and acquiring the word vector of each product demand module in the N product demand modules, and splicing the word vectors in each product demand module in sequence to obtain the characteristics of the N product demand modules.
Optionally, before the obtaining of the product demand audio of the target version of the product to be tested, the method further includes: acquiring historical data of the product to be tested, wherein the product to be tested corresponds to at least one historical version product, and the historical data comprises historical product requirements, historical test cases and historical code coverage rate reports of the at least one historical version product; and constructing an initial neural network model, and training the initial neural network through the historical data to obtain a test case generation model.
Optionally, the constructing an initial neural network model, and training the initial neural network through the historical data to obtain a test case generation model includes: preprocessing the historical test case to obtain M second sample case modules, numbering the M second sample case modules, wherein M is a positive integer; preprocessing the historical product requirements to obtain K sample requirement modules, and numbering the K sample requirement modules, wherein each sample requirement module corresponds to at least one second sample case module, K is a positive integer, and N is more than N and less than M; extracting K sample demand module characteristics of the K sample demand modules, and storing the K sample demand module characteristics into a sample library, wherein the K sample demand module characteristics correspond to the K sample demand modules one to one; determining S first sample use case modules according to the historical code coverage rate report, wherein the S first sample use case modules are S second sample use case modules which meet the requirements of corresponding sample requirement modules in the M second sample use case modules, S is a positive integer, and N is more than S and less than M; adding first labels to the S first sample use case modules respectively, wherein the first labels comprise the serial numbers of the sample demand modules corresponding to the first sample use case modules and the serial numbers of the first sample use case modules; adding a second label to the sample requirement module corresponding to the first sample use case module, wherein the second label comprises the number of the sample requirement module corresponding to the first sample use case module and the number of the first sample use case module; storing the S first sample use case modules and S sample demand modules corresponding to the S first sample use case modules into the sample library; and training the initial neural network model through the K sample demand module characteristics, the S first sample case modules and the S sample demand modules corresponding to the S first sample case modules to obtain the test case generation model.
Optionally, the obtaining N first sample case modules corresponding to the N target sample demand module features includes: searching the sample library, and determining N sample demand modules corresponding to the N target sample demand module characteristics; determining the numbers of the corresponding N first sample case modules according to the second labels of the N sample demand modules; and acquiring the N first sample use case modules according to the serial numbers of the N first sample use case modules.
In a second aspect, an embodiment of the present application provides a test case generating device, where the test case generating device includes: the device comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring the product requirement audio of a target version of a product to be detected; the conversion unit is used for converting the product requirement audio into a product requirement text according to a preset voice conversion method; and the test case generation unit is used for inputting the product requirement text into a test case generation model and generating a target test case of the product to be tested through the test case generation model.
In a third aspect, an embodiment of the present application provides an electronic device, including a processor, a memory, a communication interface, and one or more programs, where the one or more programs are stored in the memory and configured to be executed by the processor, and the program includes instructions for executing the steps in the first aspect of the embodiment of the present application.
In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, where the computer-readable storage medium stores a computer program for electronic data exchange, where the computer program enables a computer to perform some or all of the steps described in the first aspect of the embodiment of the present application.
In a fifth aspect, embodiments of the present application provide a computer program product, where the computer program product includes a non-transitory computer-readable storage medium storing a computer program, where the computer program is operable to cause a computer to perform some or all of the steps as described in the first aspect of the embodiments of the present application. The computer program product may be a software installation package.
In the embodiment of the application, the product requirement of the product to be detected is determined by acquiring the product requirement audio of the target version of the product to be detected; converting the product requirement audio into a product requirement text according to a preset voice conversion method; preprocessing the product requirement text to obtain N product requirement modules, so that requirement key points in the product requirement are further defined, and the product requirement can be segmented; acquiring N product demand module characteristics of the N product demand modules; comparing the N product demand module characteristics with pre-stored first sample demand module characteristics to obtain N first target sample demand module characteristics matched with the N product demand module characteristics; acquiring N first sample case modules corresponding to the N first target sample demand module characteristics, wherein the first target sample demand module is highly matched with the corresponding first sample case module, so that the target test case finally obtained by the first sample case module can meet the product demand; and splicing the N first sample case modules to obtain a target test case of the product to be tested. Therefore, in the test case generation method provided by the embodiment of the application, the target test case can be obtained more quickly by performing feature matching on the product demand module features, compared with a method for manually designing the test case, the test case generation efficiency is greatly improved, a code coverage rate test is not required to be performed on the target test case, the operation flow is reduced, and the test cost and the labor cost are saved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic flow chart of a test case generation method according to an embodiment of the present application;
fig. 2 is a schematic diagram of a corresponding relationship between a historical test case and a historical test requirement provided in an embodiment of the present application;
fig. 3 is a schematic flowchart of a test case generation method according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure;
fig. 5 is a schematic structural diagram of a test case generation apparatus according to an embodiment of the present application.
Detailed Description
In order to make the technical solutions of the present application better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The terms "first," "second," and the like in the description and claims of the present application and in the above-described drawings are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "include" and "have," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or apparatus.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase 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. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
The electronic device according to the embodiments of the present application may include various handheld devices, vehicle-mounted devices, wireless headsets, computing devices or other processing devices connected to a wireless modem, and various forms of User Equipment (UE), Mobile Stations (MS), terminal devices (terminal device), and the like, which have wireless communication functions. For convenience of description, the above-mentioned devices are collectively referred to as electronic devices.
Referring to fig. 1, fig. 1 is a schematic flowchart of a test case generation method provided in an embodiment of the present application, where the method includes:
101. and acquiring the product requirement audio of the target version of the product to be detected.
The embodiment of the application is applied to terminal equipment, the terminal equipment can be a server or a mobile phone or other equipment, and the product to be tested is an application program to be tested.
102. And converting the product requirement audio into a product requirement text according to a preset voice conversion method.
The conversion from audio to text can be realized by building a voice conversion model, and the voice recognition and conversion can also be realized by a voice recognition toolbox kaldi, a Baidu voice recognition toolkit or a message flight voice recognition toolkit and the like. The voice conversion model comprises an acoustic module, a language module and a dictionary, wherein the acoustic module and the language module are obtained by the following method: establishing an acoustic training module and a language training module, selecting a sample from a voice database, extracting sample characteristics, and training the acoustic training module through the sample characteristics and a dictionary to obtain the acoustic module; and selecting a sample from the text database, extracting sample characteristics, and training a language training module through the sample characteristics and the dictionary to obtain a language module.
The voice conversion model filters interference by preprocessing such as sampling, quantifying and pre-emphasizing product demand audio, then extracts the characteristics of the product demand audio, inputs the extracted characteristics into the voice recognition model and outputs a product demand text.
103. And inputting the product requirement text into a test case generation model, and generating a target test case of the product to be tested through the test case generation model.
The test case generation model can automatically generate a corresponding test case after a section of product requirements described by a natural language are input.
After a target test case is obtained, updating a sample library of the test case generation model through the product requirement text and the target test case; and training the test case generation model again through the updated data in the sample library to obtain an updated test case generation model.
It can be seen that in the embodiment of the application, the product requirement audio of the target version of the product to be detected is obtained; converting the product requirement audio into a product requirement text according to a preset voice conversion method; and inputting the product requirement text into a test case generation model, and generating a target test case of the product to be tested through the test case generation model, so that the test case generation efficiency can be greatly improved, the operation flow can be reduced, and the test cost and the labor cost can be saved.
Optionally, the inputting the product requirement text into a test case generation model, and generating the target test case of the product to be tested through the test case generation model includes:
preprocessing the product demand text to obtain N product demand modules, wherein N is a positive integer;
acquiring N product demand module characteristics of the N product demand modules, wherein the product demand modules correspond to the product demand module characteristics one to one;
comparing the N product demand module characteristics with pre-stored sample demand module characteristics to obtain N target sample demand module characteristics matched with the N product demand module characteristics, wherein the product demand module characteristics correspond to the target sample demand module characteristics one to one;
acquiring N first sample use case modules corresponding to the N target sample demand module characteristics, wherein the target sample demand module characteristics correspond to the first sample use case modules one to one;
and splicing the N first sample case modules to obtain a target test case of the product to be tested.
In the embodiment, the preprocessing includes blocking, word segmentation, and word decommissioning. Due to the fact that products are updated, functions are upgraded, and product requirements are increased, the situation that target sample requirement module characteristics matched with the product requirement module characteristics do not exist in a sample library is possible, under the situation, first sample case modules corresponding to one part of product requirement modules are obtained through a test case generation model, then sample case modules meeting the requirements of the other part of product requirement modules are designed manually, and the two parts of sample case modules are spliced in sequence, so that a complete target test case is obtained.
Therefore, the test case generation method provided by the embodiment can obtain the target test case more quickly by performing feature matching on the product demand module features, greatly improves the test case generation efficiency compared with a test case designed manually, does not need to perform code coverage rate test on the target test case, reduces the operation flow, and saves the test cost and the labor cost.
Optionally, the preprocessing the product requirement text to obtain N product requirement modules includes:
detecting sentence boundaries of the product demand text, and blocking the product demand text according to the sentence boundaries to obtain N product demand basic modules, wherein the sentence boundaries comprise periods and semicolons;
performing word segmentation processing on the N product demand basic modules;
and stopping words from the N product demand texts after word segmentation processing to obtain the N product demand modules.
The sentence and semicolon indicate the end of a short sentence and are generally positioned at the end of a product demand block, so that the short sentence and semicolon can be used as the basis for blocking, and after the sentence or semicolon is detected, the product demand text is segmented according to the detected sentence or semicolon to obtain N product demand basic modules. Since the computer cannot recognize natural language, the text needs to be divided into the most basic modules, and one sentence is divided into several words, in this embodiment, each of the above several basic modules for obtaining product requirements is divided into several words, i.e. word segmentation processing, for example, "Xiaoming 1995 graduation at Beijing Qinghua university" is obtained after word segmentation processing, and "Xiaoming 1995 graduation at Beijing Qinghua university" is obtained. Stop words refer to words such as pronouns, prepositions, conjunctions, etc. that contain no or little semantics, for example, for "Xiaoming 1995 graduation at Beijing Qinghua university" stop words will be visible to "Xiaoming 1995 graduation at Beijing Qinghua university," where removal of prepositions "in" and removal of these stop words in the text enables the model to better fit the actual semantic features, thereby increasing the generalization ability of the model.
Therefore, after the preprocessing such as blocking, word segmentation and word stop is carried out on the product requirement text, a product requirement module with obvious characteristics is obtained, and the subsequent text characteristic expression is facilitated.
Optionally, the obtaining N product requirement module characteristics of the N product requirement modules includes:
and acquiring the word vector of each product demand module in the N product demand modules, and splicing the word vectors in each product demand module in sequence to obtain the characteristics of the N product demand modules.
In the natural language processing task, words in a text are represented in a computer through discrete representation or distributed representation, and both words are converted into dense (long) vectors, specifically, word vectors can be generated through a co-occurrence matrix, an SVD (singular value decomposition), a bag-of-words model, a dynamic word vector ELMo and other methods, so that a plurality of words in a product demand module can generate a plurality of corresponding word vectors, namely word vector sequences, through any one of the methods, for example, if n words exist in the product demand module (short sentence), the generated word vectors are all in a k dimension, the word vector sequences are n × k matrixes, and the n × k matrixes are characteristics of the product demand module. And after the product demand module characteristics corresponding to each product demand module are obtained, splicing the product demand module characteristics according to the sequence of the corresponding product demand modules in the product demand text, so as to obtain the N product demand module characteristics.
Therefore, the text is converted into word vectors, the text can be converted into languages understood by a computer, and the extraction of text features is facilitated.
Optionally, before the obtaining of the product demand audio of the target version of the product to be tested, the method further includes:
acquiring historical data of the product to be tested, wherein the product to be tested corresponds to at least one historical version product, and the historical data comprises historical product requirements, historical test cases and historical code coverage rate reports of the at least one historical version product;
and constructing an initial neural network model, and training the initial neural network through the historical data to obtain a test case generation model.
Wherein, the number of the historical test cases in the historical data is greater than or equal to the number of the historical product demands, the historical product demands and the historical test cases are in a one-to-one correspondence relationship or a one-to-many relationship, the historical test cases and the historical code coverage reports are in a one-to-one correspondence relationship, the historical data may further include a defect test report, and optionally, the historical data may further include historical data of products of the same type, for example, if the product is a shopping application, the products of the same type may be applications such as naobao, jingdong, and moso, as shown in fig. 2, fig. 2 is a schematic diagram of a correspondence relationship between the historical test cases and the historical test demands provided by the embodiment of the present application, in the historical data, the historical product demands include product demands of similar product 1, similar product 2, product generation 1 of the present product, and generation … … of the present product, which is exemplified by generation 1 of the present product, generation 1 has 3 corresponding historical test cases, respectively as follows: the test case 1, the test case 2 and the test case 3, the product 1 generation is composed of a sample requirement block 1, a sample requirement block 2 and a sample requirement block 3 … …, the test case 1 is composed of a sample case block 1, a sample case block 2 and a sample case block 3 … …, wherein the sample case block 1 corresponds to the sample requirement block 1 in the product 1 generation, the sample case block 2 corresponds to the sample requirement block 2 in the product 1 generation, and the sample case block 3 corresponds to the sample requirement block 3 … … in the product 1 generation.
For the Code coverage report, a Code coverage tool jacoco (java Code) can be combined to bury a point when the application to be tested is started, an execution path (package-class-method) of the application is obtained, and according to the execution path condition of the developed Code after the test case is executed, the overall test coverage of the test case and whether each part (sample case block) of the test case covers the Code of the function to be tested (sample requirement block) of the application to be tested are obtained. Specifically, when an application program is started and a test case is started to be executed, a specific jar file is specified in a JVM (Java virtual machine) through a-Java agent parameter to start an agent program of the Instrumentation, the agent program judges whether the class file is converted and modified before each class (class) needing to be detected is loaded, if not, probes, namely statistical codes, are inserted into the class (class), each execution path corresponds to different functions in the application program, each execution path of the application program can be known according to the position of each probe, whether each part (sample case block) of the test case covers the code of the function to be detected (sample requirement block) of the application to be detected can be known according to whether the code of the corresponding execution path fed back by each probe is covered, and the overall test coverage rate can be known according to the overall coverage condition of the code of the execution path. For example, the application to be tested needs to detect three functions in total, which correspond to three execution paths a, b, and c, respectively, and the weight given to the execution paths according to the importance degree is: 0.5, 0.3, and 0.2, in the test case execution process, if only the a execution path and the c execution path are executed, the overall test coverage is (0.5+0.2) × 100%: 70%.
Therefore, the more abundant the historical data is, especially the more abundant the product demand data and the test case data of the same type of product are, the higher the accuracy of the obtained test case generation model is.
Optionally, the constructing an initial neural network model, and training the initial neural network through the historical data to obtain a test case generation model includes:
preprocessing the historical test case to obtain M second sample case modules, numbering the M second sample case modules, wherein M is a positive integer;
preprocessing the historical product requirements to obtain K sample requirement modules, and numbering the K sample requirement modules, wherein each sample requirement module corresponds to at least one second sample case module, K is a positive integer, and N is more than N and less than M;
extracting K sample demand module characteristics of the K sample demand modules, and storing the K sample demand module characteristics into a sample library, wherein the K sample demand module characteristics correspond to the K sample demand modules one to one;
determining S first sample case modules according to the historical code coverage rate report, wherein the S first sample case modules are S second sample case modules which meet the requirements of corresponding sample demand modules in the M second sample case modules, S is a positive integer, and N is more than S and less than M;
adding first labels to the S first sample use case modules respectively, wherein the first labels comprise the serial numbers of the sample demand modules corresponding to the first sample use case modules and the serial numbers of the first sample use case modules;
adding a second label to the sample requirement module corresponding to the first sample use case module, wherein the second label comprises the number of the sample requirement module corresponding to the first sample use case module and the number of the first sample use case module;
storing the S first sample use case modules and S sample demand modules corresponding to the S first sample use case modules into the sample library;
and training the initial neural network model through the K sample demand module characteristics, the S first sample case modules and the S sample demand modules corresponding to the S first sample case modules to obtain the test case generation model.
Wherein the pretreatment comprises: blocking, word segmentation, and stop word. For each product demand module, at least one sample use case module in the M second sample use case modules corresponds to the product demand module, in the at least one sample use case module, the code coverage rate of each sample use case module to the corresponding requirement is different, the code coverage rate of each sample use case module in at least one sample use case module to the same requirement (function) can be determined through the corresponding historical code coverage rate report, the sample use case module with the highest code coverage rate is selected as the sample use case module which is uniquely matched with the corresponding product requirement module, labels are added to the sample use case module and the corresponding product demand module and are stored in a sample library, the content of the label is the number of the sample use case module and the number of the product requirement module corresponding to the sample use case module, the two are associated through the label, namely, the label of one party can know the number of the other party associated with the label. And finally, training an initial neural network model through data in the sample library to obtain a test case generation model. And updating the data in the sample library according to the generated test case after the test case is generated each time, so that the accuracy and the coverage range of the test case model are improved.
Therefore, the test case model can be obtained by training the initial neural network through the historical data, so that the test case can be automatically generated according to the product requirement text, the efficiency is improved, the labor cost is greatly saved, and the error of manual judgment is reduced.
Optionally, the obtaining N first sample case modules corresponding to the N target sample demand module features includes:
searching the sample library, and determining N sample demand modules corresponding to the N target sample demand module characteristics;
determining the numbers of the corresponding N first sample case modules according to the second labels of the N sample demand modules;
and acquiring the N first sample use case modules according to the serial numbers of the N first sample use case modules.
Therefore, the sample requirement module corresponding to the target sample requirement module characteristic and the first sample use case module corresponding to the sample requirement module can be obtained.
Referring to fig. 3, fig. 3 is a schematic flowchart of a test case generation method provided in the embodiment of the present application, where the method includes:
acquiring a product demand audio of a target version of a product to be detected;
converting the product requirement audio into a product requirement text according to a preset voice conversion method;
preprocessing the product demand text to obtain N product demand modules, wherein N is a positive integer;
acquiring N product demand module characteristics of the N product demand modules, wherein the product demand modules correspond to the product demand module characteristics one to one;
comparing the N product demand module characteristics with pre-stored sample demand module characteristics to obtain N target sample demand module characteristics matched with the N product demand module characteristics, wherein the product demand module characteristics correspond to the target sample demand module characteristics one to one;
acquiring N first sample use case modules corresponding to the N target sample demand module characteristics, wherein the target sample demand module characteristics correspond to the first sample use case modules one to one;
and splicing the N first sample case modules to obtain a target test case of the product to be tested.
For specific description of each step in this embodiment, reference may be made to the foregoing embodiments, which are not described herein again.
In the embodiment of the application, the product requirement of the product to be detected is determined by acquiring the product requirement audio of the target version of the product to be detected; converting the product requirement audio into a product requirement text according to a preset voice conversion method; preprocessing the product demand text to obtain N product demand modules, thereby further defining demand key points in the product demand and being capable of segmenting the product demand; acquiring N product demand module characteristics of the N product demand modules; comparing the N product demand module characteristics with pre-stored first sample demand module characteristics to obtain N first target sample demand module characteristics matched with the N product demand module characteristics; acquiring N first sample case modules corresponding to the N first target sample demand module characteristics, wherein the first target sample demand module is highly matched with the corresponding first sample case module, so that a target test case finally obtained by the first sample case module can meet product demands; and splicing the N first sample case modules to obtain a target test case of the product to be tested. Therefore, in the test case generation method provided by the embodiment of the application, the target test case can be obtained more quickly by performing feature matching on the product demand module features, compared with a test case designed manually, the test case generation efficiency is greatly improved, a code coverage rate test does not need to be performed on the target test case, the operation flow is reduced, and the test cost and the labor cost are saved.
Referring to fig. 4, fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure, which includes a processor, a memory, a communication interface, and one or more programs, where the programs are stored in the memory and configured to be executed by the processor. The program includes instructions for performing the steps of:
acquiring a product requirement audio of a target version of a product to be detected;
converting the product requirement audio into a product requirement text according to a preset voice conversion method;
and inputting the product requirement text into a test case generation model, and generating a target test case of the product to be tested through the test case generation model.
In one possible example, in the aspect of inputting the product requirement text into a test case generation model, and generating a target test case of the product to be tested through the test case generation model, the program includes instructions for performing the following steps:
preprocessing the product demand text to obtain N product demand modules, wherein N is a positive integer;
acquiring N product demand module characteristics of the N product demand modules, wherein the product demand modules correspond to the product demand module characteristics one to one;
comparing the N product demand module characteristics with pre-stored sample demand module characteristics to obtain N target sample demand module characteristics matched with the N product demand module characteristics, wherein the product demand module characteristics correspond to the target sample demand module characteristics one to one;
acquiring N first sample use case modules corresponding to the N target sample demand module characteristics, wherein the target sample demand module characteristics correspond to the first sample use case modules one to one;
and splicing the N first sample case modules to obtain a target test case of the product to be tested.
In one possible example, in the preprocessing the product requirement text to obtain N product requirement modules, the program includes instructions for performing the following steps:
detecting sentence boundaries of the product demand text, and blocking the product demand text according to the sentence boundaries to obtain N product demand basic modules, wherein the sentence boundaries comprise periods and semicolons;
performing word segmentation processing on the N product demand basic modules;
and stopping words from the N product demand texts after word segmentation processing to obtain the N product demand modules.
In one possible example, in said obtaining N product demand module characteristics for the N product demand modules, the program includes instructions for:
and acquiring the word vectors of each product demand module in the N product demand modules, and splicing the word vectors in each product demand module in sequence to obtain the characteristics of the N product demand modules.
In a possible example, before the obtaining the product demand audio of the target version of the product under test, the program further includes instructions for performing the following steps:
acquiring historical data of the product to be tested, wherein the product to be tested corresponds to at least one historical version product, and the historical data comprises historical product requirements, historical test cases and historical code coverage rate reports of the at least one historical version product;
and constructing an initial neural network model, and training the initial neural network through the historical data to obtain a test case generation model.
In a possible example, in the constructing an initial neural network model, and training the initial neural network through the historical data to obtain a test case generation model, the program further includes instructions for performing the following steps:
preprocessing the historical test case to obtain M second sample case modules, numbering the M second sample case modules, wherein M is a positive integer;
preprocessing the historical product requirements to obtain K sample requirement modules, and numbering the K sample requirement modules, wherein each sample requirement module corresponds to at least one second sample case module, K is a positive integer, and N is more than N and less than M;
extracting K sample demand module characteristics of the K sample demand modules, and storing the K sample demand module characteristics into a sample library, wherein the K sample demand module characteristics correspond to the K sample demand modules one to one;
determining S first sample use case modules according to the historical code coverage rate report, wherein the S first sample use case modules are S second sample use case modules which meet the requirements of corresponding sample requirement modules in the M second sample use case modules, S is a positive integer, and N is more than S and less than M;
adding first labels to the S first sample use case modules respectively, wherein the first labels comprise the serial numbers of the sample demand modules corresponding to the first sample use case modules and the serial numbers of the first sample use case modules;
adding a second label to the sample requirement module corresponding to the first sample use case module, wherein the second label comprises the number of the sample requirement module corresponding to the first sample use case module and the number of the first sample use case module;
storing the S first sample use case modules and S sample demand modules corresponding to the S first sample use case modules into the sample library;
and training the initial neural network model through the K sample demand module characteristics, the S first sample case modules and the S sample demand modules corresponding to the S first sample case modules to obtain the test case generation model.
In one possible example, in the obtaining N first sample use case modules corresponding to the N target sample demand module characteristics, the program further includes instructions for performing the steps of:
searching the sample library, and determining N sample demand modules corresponding to the N target sample demand module characteristics;
determining the numbers of the corresponding N first sample case modules according to the second labels of the N sample demand modules;
and acquiring the N first sample use case modules according to the serial numbers of the N first sample use case modules.
The above description mainly introduces the solution of the embodiment of the present application from the perspective of the method implementation process. It is understood that the electronic device comprises corresponding hardware structures and/or software modules for performing the respective functions in order to realize the above-mentioned functions. Those of skill in the art will readily appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments provided herein may be implemented as hardware or combinations of hardware and computer software. Whether a function is performed as hardware or computer software drives hardware 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 embodiment of the present application, the electronic device may be divided into the functional units according to the method example, for example, each functional unit may be divided corresponding to each function, or two or more functions may be integrated into one processing unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit. It should be noted that the division of the unit in the embodiment of the present application is schematic, and is only a logic function division, and there may be another division manner in actual implementation.
In accordance with the above, please refer to fig. 5, fig. 5 is a schematic structural diagram of a test case generating apparatus 500 according to an embodiment of the present application, where the test case generating apparatus 500 includes:
an obtaining unit 501, configured to obtain a product requirement audio of a target version of a product to be detected;
a conversion unit 502, configured to convert the product requirement audio into a product requirement text according to a preset voice conversion method;
the test case generating unit 503 is configured to convert the product requirement audio into a product requirement text according to a preset speech conversion method.
In a possible example, in the aspect that the product requirement text is input into a test case generation model, and a target test case of the product to be tested is generated through the test case generation model, the test case generation unit 503 is specifically configured to:
preprocessing the product demand text to obtain N product demand modules, wherein N is a positive integer;
acquiring N product demand module characteristics of the N product demand modules, wherein the product demand modules correspond to the product demand module characteristics one to one;
comparing the N product demand module characteristics with prestored sample demand module characteristics to obtain N target sample demand module characteristics matched with the N product demand module characteristics, wherein the product demand module characteristics correspond to the target sample demand module characteristics one to one;
acquiring N first sample use case modules corresponding to the N target sample demand module characteristics, wherein the target sample demand module characteristics correspond to the first sample use case modules one to one;
and splicing the N first sample case modules to obtain a target test case of the product to be tested.
In a possible example, in the aspect of preprocessing the product requirement text to obtain N product requirement modules, the test case generating unit 503 is specifically configured to:
detecting sentence boundaries of the product demand text, and blocking the product demand text according to the sentence boundaries to obtain N product demand basic modules, wherein the sentence boundaries comprise periods and semicolons;
performing word segmentation processing on the N product demand basic modules;
and stopping words from the N product demand texts after word segmentation processing to obtain the N product demand modules.
In a possible example, in the aspect of obtaining the characteristics of the N product requirement modules, the test case generating unit 503 is specifically configured to:
and acquiring the word vector of each product demand module in the N product demand modules, and splicing the word vectors in each product demand module in sequence to obtain the characteristics of the N product demand modules.
In a possible example, before the obtaining of the product requirement audio of the target version of the product to be tested, the test case generating unit 503 is specifically configured to:
acquiring historical data of the product to be tested, wherein the product to be tested corresponds to at least one historical version product, and the historical data comprises historical product requirements, historical test cases and historical code coverage rate reports of the at least one historical version product;
and constructing an initial neural network model, and training the initial neural network through the historical data to obtain a test case generation model.
In a possible example, in the constructing an initial neural network model, and training the initial neural network through the historical data to obtain a test case generation model, the test case generation unit 503 is further configured to:
preprocessing the historical test case to obtain M second sample case modules, numbering the M second sample case modules, wherein M is a positive integer;
preprocessing the historical product requirements to obtain K sample requirement modules, and numbering the K sample requirement modules, wherein each sample requirement module corresponds to at least one second sample case module, K is a positive integer, and N is more than N and less than M;
extracting K sample demand module characteristics of the K sample demand modules, and storing the K sample demand module characteristics into a sample library, wherein the K sample demand module characteristics correspond to the K sample demand modules one to one;
determining S first sample case modules according to the historical code coverage rate report, wherein the S first sample case modules are S second sample case modules which meet the requirements of corresponding sample demand modules in the M second sample case modules, S is a positive integer, and N is more than S and less than M;
adding first labels to the S first sample use case modules respectively, wherein the first labels comprise the serial numbers of the sample demand modules corresponding to the first sample use case modules and the serial numbers of the first sample use case modules;
adding a second label to the sample requirement module corresponding to the first sample use case module, wherein the second label comprises the number of the sample requirement module corresponding to the first sample use case module and the number of the first sample use case module;
storing the S first sample use case modules and S sample demand modules corresponding to the S first sample use case modules into the sample library;
and training the initial neural network model through the K sample demand module characteristics, the S first sample case modules and the S sample demand modules corresponding to the S first sample case modules to obtain the test case generation model.
In a possible example, in the aspect of obtaining N first sample case modules corresponding to the N target sample requirement module characteristics, the test case generating unit 503 is further configured to:
searching the sample library, and determining N sample demand modules corresponding to the N target sample demand module characteristics;
determining the numbers of the corresponding N first sample case modules according to the second labels of the N sample demand modules;
and acquiring the N first sample use case modules according to the serial numbers of the N first sample use case modules.
It can be seen that in the embodiment of the application, the product requirement audio of the target version of the product to be detected is obtained; converting the product requirement audio into a product requirement text according to a preset voice conversion method; and inputting the product requirement text into a test case generation model, and generating the target test case of the product to be tested through the test case generation model, so that the test case generation efficiency can be greatly improved, the operation flow is reduced, and the test cost and the labor cost are saved.
Embodiments of the present application further provide a computer-readable storage medium storing a computer program for electronic data exchange, where the computer program enables a computer to execute part or all of the steps of any one of the test case generation methods described in the above method embodiments.
Embodiments of the present application further provide a computer program product, where the computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program causes a computer to execute some or all of the steps of any one of the test case generation methods described in the above method embodiments.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present application is not limited by the order of acts described, as some steps may occur in other orders or concurrently depending on the application. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required in this application. In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
As described above, the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit the same. 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 solutions described in the foregoing embodiments may be modified, or some technical features may be equivalently replaced. And the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present application.

Claims (10)

1. A test case generation method, the method comprising:
acquiring a product demand audio of a target version of a product to be detected;
converting the product requirement audio into a product requirement text according to a preset voice conversion method;
and inputting the product requirement text into a test case generation model, and generating a target test case of the product to be tested through the test case generation model.
2. The method of claim 1, wherein the inputting the product requirement text into a test case generation model, and the generating the target test case of the product to be tested through the test case generation model comprises:
preprocessing the product demand text to obtain N product demand modules, wherein N is a positive integer;
acquiring N product demand module characteristics of the N product demand modules, wherein the product demand modules correspond to the product demand module characteristics one to one;
comparing the N product demand module characteristics with pre-stored sample demand module characteristics to obtain N target sample demand module characteristics matched with the N product demand module characteristics, wherein the product demand module characteristics correspond to the target sample demand module characteristics one to one;
acquiring N first sample use case modules corresponding to the N target sample demand module characteristics, wherein the target sample demand module characteristics correspond to the first sample use case modules one to one;
and splicing the N first sample case modules to obtain a target test case of the product to be tested.
3. The method of claim 2, wherein the preprocessing the product requirement text to obtain N product requirement blocks comprises:
detecting sentence boundaries of the product demand text, and blocking the product demand text according to the sentence boundaries to obtain N product demand basic blocks, wherein the sentence boundaries comprise periods and semicolons;
performing word segmentation processing on the N product demand basic modules;
and stopping words from the N product demand texts after word segmentation processing to obtain the N product demand modules.
4. The method of claim 1 or 2, wherein said obtaining N product demand module characteristics for the N product demand modules comprises:
and acquiring the word vector of each product demand module in the N product demand modules, and splicing the word vectors in each product demand module in sequence to obtain the characteristics of the N product demand modules.
5. The method according to any one of claims 1-4, wherein prior to said obtaining the product demand audio for the target version of the product under test, the method further comprises:
acquiring historical data of the product to be tested, wherein the product to be tested corresponds to at least one historical version product, and the historical data comprises historical product requirements, historical test cases and historical code coverage rate reports of the at least one historical version product;
and constructing an initial neural network model, and training the initial neural network through the historical data to obtain a test case generation model.
6. The method of claim 5, wherein the constructing an initial neural network model, and training the initial neural network through the historical data to obtain a test case generation model comprises:
preprocessing the historical test case to obtain M second sample case modules, numbering the M second sample case modules, wherein M is a positive integer;
preprocessing the historical product demand to obtain K sample demand modules, and numbering the K sample demand modules, wherein each sample demand module corresponds to at least one second sample case module, K is a positive integer, and N is more than K and less than M;
extracting K sample demand module characteristics of the K sample demand modules, and storing the K sample demand module characteristics into a sample library, wherein the K sample demand module characteristics correspond to the K sample demand modules one to one;
determining S first sample use case modules according to the historical code coverage rate report, wherein the S first sample use case modules are S second sample use case modules which meet the requirements of corresponding sample requirement modules in the M second sample use case modules, S is a positive integer, and N is more than S and less than M;
adding first labels to the S first sample use case modules respectively, wherein the first labels comprise the serial numbers of the sample demand modules corresponding to the first sample use case modules and the serial numbers of the first sample use case modules;
adding a second label to the sample requirement module corresponding to the first sample use case module, wherein the second label comprises the number of the sample requirement module corresponding to the first sample use case module and the number of the first sample use case module;
storing the S first sample use case modules and S sample demand modules corresponding to the S first sample use case modules into the sample library;
and training the initial neural network model through the K sample demand module characteristics, the S first sample case modules and the S sample demand modules corresponding to the S first sample case modules to obtain the test case generation model.
7. The method according to claim 6, wherein the obtaining of the N first sample use case modules corresponding to the N target sample demand module characteristics comprises:
searching the sample library, and determining N sample demand modules corresponding to the N target sample demand module characteristics;
determining the numbers of the corresponding N first sample case modules according to the second labels of the N sample demand modules;
and acquiring the N first sample use case modules according to the serial numbers of the N first sample use case modules.
8. A test case generation apparatus, comprising:
the device comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring the product requirement audio of a target version of a product to be detected;
the conversion unit is used for converting the product requirement audio into a product requirement text according to a preset voice conversion method;
and the test case generation unit is used for inputting the product requirement text into a test case generation model and generating the target test case of the product to be tested through the test case generation model.
9. An electronic device comprising a processor, a memory, a communication interface, and one or more programs stored in the memory and configured to be executed by the processor, the programs comprising instructions for performing the steps in the method of any of claims 1-7.
10. A computer-readable storage medium, characterized in that a computer program for electronic data exchange is stored, wherein the computer program causes a computer to perform the method according to any one of claims 1-7.
CN202210341714.3A 2022-04-02 2022-04-02 Test case generation method and related device Pending CN114647590A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210341714.3A CN114647590A (en) 2022-04-02 2022-04-02 Test case generation method and related device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210341714.3A CN114647590A (en) 2022-04-02 2022-04-02 Test case generation method and related device

Publications (1)

Publication Number Publication Date
CN114647590A true CN114647590A (en) 2022-06-21

Family

ID=81994973

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210341714.3A Pending CN114647590A (en) 2022-04-02 2022-04-02 Test case generation method and related device

Country Status (1)

Country Link
CN (1) CN114647590A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117234950A (en) * 2023-11-13 2023-12-15 广州品唯软件有限公司 Test case recording method and device, storage medium and computer equipment
CN117707922A (en) * 2023-10-20 2024-03-15 九科信息技术(深圳)有限公司 Method and device for generating test case, terminal equipment and readable storage medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117707922A (en) * 2023-10-20 2024-03-15 九科信息技术(深圳)有限公司 Method and device for generating test case, terminal equipment and readable storage medium
CN117234950A (en) * 2023-11-13 2023-12-15 广州品唯软件有限公司 Test case recording method and device, storage medium and computer equipment
CN117234950B (en) * 2023-11-13 2024-03-19 广州品唯软件有限公司 Test case recording method and device, storage medium and computer equipment

Similar Documents

Publication Publication Date Title
CN104951458B (en) Help processing method and equipment based on semantics recognition
CN114647590A (en) Test case generation method and related device
CN110674255B (en) Text content auditing method and device
CN109256125B (en) Off-line voice recognition method and device and storage medium
CN107291775B (en) Method and device for generating repairing linguistic data of error sample
CN111538809B (en) Voice service quality detection method, model training method and device
EP4113357A1 (en) Method and apparatus for recognizing entity, electronic device and storage medium
CN111144128A (en) Semantic parsing method and device
CN112016275A (en) Intelligent error correction method and system for voice recognition text and electronic equipment
CN112528663B (en) Text error correction method and system in power grid field scheduling scene
CN112468658A (en) Voice quality detection method and device, computer equipment and storage medium
CN112181835A (en) Automatic testing method and device, computer equipment and storage medium
CN113268588A (en) Text abstract extraction method, device, equipment, storage medium and program product
CN113312258A (en) Interface testing method, device, equipment and storage medium
CN117556011A (en) Internal interaction question-answering auxiliary method and system based on generation type large model
CN114490969B (en) Question and answer method and device based on table and electronic equipment
CN110647537A (en) Data searching method, device and storage medium
CN107977304B (en) System debugging method and device
CN115620726A (en) Voice text generation method, and training method and device of voice text generation model
CN111737572B (en) Search statement generation method and device and electronic equipment
CN110083807B (en) Contract modification influence automatic prediction method, device, medium and electronic equipment
CN114443000A (en) Internet + -based software engineering development system
CN113724738A (en) Voice processing method, decision tree model training method, device, equipment and storage medium
CN111626052A (en) Hash dictionary-based alarm receiving and handling text item name extraction method and device
CN113255292B (en) End-to-end text generation method based on pre-training model and related equipment

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