CN117389890A - Method and device for generating test case, electronic equipment and storage medium - Google Patents

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

Info

Publication number
CN117389890A
CN117389890A CN202311392718.5A CN202311392718A CN117389890A CN 117389890 A CN117389890 A CN 117389890A CN 202311392718 A CN202311392718 A CN 202311392718A CN 117389890 A CN117389890 A CN 117389890A
Authority
CN
China
Prior art keywords
test
test case
model
training
preset
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
CN202311392718.5A
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.)
China Telecom Technology Innovation Center
China Telecom Corp Ltd
Original Assignee
China Telecom Technology Innovation Center
China Telecom Corp 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 China Telecom Technology Innovation Center, China Telecom Corp Ltd filed Critical China Telecom Technology Innovation Center
Priority to CN202311392718.5A priority Critical patent/CN117389890A/en
Publication of CN117389890A publication Critical patent/CN117389890A/en
Pending legal-status Critical Current

Links

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
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application relates to the technical field of software, in particular to the technical field of software testing, and provides a method and a device for generating test cases, electronic equipment and a storage medium, which are used for improving the generation efficiency of the test cases. The method comprises the following steps: acquiring test content description and test rules corresponding to the test content description in the test file; the test file is preset based on the test requirement; splicing the test content description and the test rule based on a preset format, and inputting a splicing result into a test case generation model; based on the test case generation model and a preset prompt corresponding to the test file, performing data processing on the spliced result to generate a test case; the preset prompt is used for providing a reference format for the generation of the test cases. The test case automatic generation model can be based on the test case automatic generation model to quickly generate the test case, so that the generation efficiency is greatly improved.

Description

Method and device for generating test case, electronic equipment and storage medium
Technical Field
The application relates to the technical field of software, in particular to the technical field of software testing, and provides a method and a device for generating test cases, electronic equipment and a storage medium.
Background
With the continuous development of internet science and technology, various software layers are endless, in order to ensure normal functions of a software system and good software quality, software testing becomes more and more important, and as the volume of software becomes larger and the logic of software service becomes more and more complex, the number of test cases required to be used in software testing work and the complexity of the test cases are greatly improved, and in the related art, writing of the test cases can be completed only in a completely manual mode according to specific requirements of the software testing, and a large amount of manpower is required to be consumed; or the test cases written in history are stored in a database, and when the software test is carried out next time, relevant test cases are searched in the database and are modified, so that new test cases are generated, but the situation that the history test cases cannot be completely matched with the required test cases easily occurs, a great deal of manpower is still required for modification and supplementation, and the writing efficiency of the test cases is low.
In summary, how to improve the generation efficiency of test cases is needed to be solved.
Disclosure of Invention
The embodiment of the application provides a method, a device, electronic equipment and a storage medium for generating test cases, which are used for improving the generation efficiency of the test cases.
The method for generating the test case provided by the embodiment of the application comprises the following steps:
acquiring test content description in a test file and a test rule corresponding to the test content description; the test file is preset based on test requirements;
splicing the test content description and the test rule based on a preset format, and inputting a splicing result into a test case generation model;
based on the test case generation model and a preset prompt corresponding to the test file, carrying out data processing on the splicing result to generate a test case; the preset prompt is used for providing a reference format for the generation of the test cases.
The device for generating the test case provided by the embodiment of the application comprises:
the acquisition unit is used for acquiring the test content description in the test file and the test rule corresponding to the test content description; the test file is preset based on test requirements;
the input unit is used for splicing the test content description and the test rule based on a preset format and inputting the splicing result into a test case generation model;
the generating unit is used for carrying out data processing on the splicing result based on the test case generating model and a preset prompt corresponding to the test file to generate a test case; the preset prompt is used for providing a reference format for the generation of the test cases.
Optionally, the test file is a functional requirement test file, the test content description is a functional requirement description in the functional requirement test file, and the test rule is a condition constraint rule corresponding to the functional requirement description; the preset prompt is a first preset prompt corresponding to the function requirement test file.
Optionally, the test file is an interface interaction test file, the test content is described as a data calling parameter in the interface interaction test file, and the test content is a message interaction protocol corresponding to the data calling parameter; the preset prompt is a second preset prompt corresponding to the interface interaction test file.
Optionally, the test case generating model is a dialogue generating model; the apparatus further comprises:
the training unit is used for taking the dialogue generating model as an original dialogue generating model and acquiring a training sample if the generated test case does not meet the preset test case specification after the test case is generated;
performing iterative training on the original dialogue generating model by adopting the training sample to obtain a target dialogue generating model;
And using the target dialogue generating model as a new test case generating model to regenerate the test case.
Optionally, the training sample includes a preset training test case and a generated test case generated by the dialogue generation model; the training test case and the generated test case are provided with sample labels; the sample label of the training test case is used for identifying that the corresponding training test case is a positive sample or a negative sample; the sample label of the generated test case is used for identifying the corresponding generated test case as a positive sample or a negative sample;
the training unit is specifically used for:
performing iterative training on the original dialogue generating model based on the training samples and sample labels corresponding to the training samples respectively until the preset iteration times are reached; wherein each iterative training performs the following process:
selecting at least one training sample, and carrying out parameter fine adjustment on the reference dialogue generating model by combining sample labels corresponding to the at least one training sample to obtain an adjusted reference dialogue generating model; the adjusted reference dialogue generating model is used as a reference dialogue generating model for the next iteration training; a reference dialogue generating model in the first iterative training generates a model for the original dialogue;
And taking the last iteration as the target dialogue generation type model.
Optionally, the training unit is specifically configured to:
testing the target dialogue generating model based on the training samples and the sample labels corresponding to the training samples;
determining whether the test case generated by the target dialogue generation model meets the test case specification or not based on a test result;
and if the test case generated by the target dialogue generating model meets the test case specification, taking the target dialogue generating model as a new test case generating model.
The electronic device provided by the embodiment of the application comprises a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the method for generating any one of the test cases.
An embodiment of the present application provides a computer readable storage medium including a computer program for causing an electronic device to execute the steps of any one of the above-described methods for generating test cases when the computer program is run on the electronic device.
Embodiments of the present application provide a computer program product comprising a computer program stored in a computer readable storage medium; when the processor of the electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the electronic device executes the steps of the method for generating any one of the test cases.
The beneficial effects of the application are as follows:
the embodiment of the application provides a method, a device, electronic equipment and a storage medium for generating test cases, which can automatically acquire test content description and test rules in a test file, splice the test content description and the test rules and input the test content description and the test rules into a test case generation model, process the test content description and the test rules based on preset corresponding prompt languages by utilizing semantic analysis capability and code generation capability of the model, quickly generate required test cases, solve the problem that a repeated test case writing process consumes a large amount of human resources, improve the writing efficiency of the test cases, quickly generate the required test cases, do not need to query and modify historical test cases, do not have mismatching conditions between the historical test cases and the required test cases, have more complete test requirement, have high test case generation speed and lighten the pressure of test staff.
Additional features and advantages of the application will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the application. The objectives and other advantages of the application will be realized and attained by the structure particularly pointed out in the written description and claims thereof as well as the appended drawings.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the application and together with the description serve to explain the application and do not constitute an undue limitation to the application. In the drawings:
fig. 1 is an application scenario schematic diagram of a method for generating a test case according to an embodiment of the present application;
FIG. 2 is an overall flowchart of a method for generating test cases according to an embodiment of the present application;
fig. 3 is a schematic diagram of extracting text contents such as a function requirement description and a condition constraint rule from a function requirement test file according to an embodiment of the present application;
FIG. 4 is a logic diagram of training and testing of a model according to an embodiment of the present application;
FIG. 5 is a schematic diagram of a test case generation logic provided in an embodiment of the present application;
FIG. 6 is a schematic diagram of a composition structure of a device for generating test cases according to an embodiment of the present application;
fig. 7 is a schematic diagram of a hardware composition structure of an electronic device according to an embodiment of the present application;
fig. 8 is a schematic diagram of a hardware composition structure of another electronic device according to an embodiment of the present application.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the embodiments of the present application more clear, the technical solutions 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 apparent that the described embodiments are some embodiments of the technical solutions of the present application, but not all embodiments. All other embodiments, which can be made by a person of ordinary skill in the art without any inventive effort, based on the embodiments described in the present application are intended to be within the scope of the technical solutions of the present application.
Some of the concepts involved in the embodiments of the present application are described below.
Prompt language: the method is used for limiting the output content of the model, guiding the model to generate test cases meeting requirements, providing format references for the model to generate the test cases, and guiding the model to generate expected content by setting prompt.
Small sample learning (english: few-shot): with fewer training samples, the model is trained so that the model can learn to generalize and adapt to new tasks.
The preferred embodiments of the present application will be described below with reference to the accompanying drawings of the specification, it being understood that the preferred embodiments described herein are for illustration and explanation only, and are not intended to limit the present application, and embodiments and features of embodiments of the present application may be combined with each other without conflict.
Fig. 1 is a schematic view of an application scenario in an embodiment of the present application. The application scenario diagram includes two terminal devices 110 and a server 120.
In the embodiment of the present application, the terminal device 110 includes, but is not limited to, a mobile phone, a tablet computer, a notebook computer, a desktop computer, an electronic book reader, an intelligent voice interaction device, an intelligent home appliance, a vehicle-mounted terminal, and the like; the terminal device may be provided with a client related to the generation of the test case, where the client may be software (for example, a browser, software for generating the test case, etc.), or may be a web page, an applet, etc., and the server 120 may be a background server corresponding to the software, the web page, the applet, etc., or a server specifically used for generating the test case, which is not specifically limited in this application. The server 120 may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or may be a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, a content delivery network (Content Delivery Network, CDN), basic cloud computing services such as big data and an artificial intelligence platform.
It should be noted that, the method for generating the test case in the embodiments of the present application may be executed by an electronic device, which may be the terminal device 110 or the server 120, that is, the method may be executed by the terminal device 110 or the server 120 separately, or may be executed by both the terminal device 110 and the server 120 together. For example, when the server 120 is an execution subject, the server 120 obtains test content descriptions in the test file and test rules corresponding to the test content descriptions; and splice the test content description and the test rule based on a preset format, then the server 120 inputs the splice result into a test case generation model, and performs data processing on the splice result based on the test case generation model and a preset prompt corresponding to the test file to generate a test case.
In an alternative embodiment, the terminal device 110 and the server 120 may communicate via a communication network.
In an alternative embodiment, the communication network is a wired network or a wireless network.
It should be noted that, the embodiment shown in fig. 1 is merely an example, and the number of terminal devices and servers is not limited in practice, and is not specifically limited in the embodiment of the present application.
In addition, the embodiments of the present application may be applied to various scenarios including, but not limited to, cloud technology, artificial intelligence, intelligent transportation, etc.
The method for generating test cases according to the exemplary embodiments of the present application will be described below with reference to the accompanying drawings in conjunction with the application scenario described above, and it should be noted that the application scenario described above is only shown for the convenience of understanding the spirit and principles of the present application, and embodiments of the present application are not limited in this respect.
Referring to fig. 2, a flowchart of an implementation of a method for generating a test case according to an embodiment of the present application is shown, where a specific implementation flow of the method is as follows:
s201: the server acquires the test content description in the test file and the test rule corresponding to the test content description.
In the above, the test file is preset based on the test requirement; the test rules are often used for restricting functions; the test cases are divided into a plurality of types, such as functional test cases, and are used for testing whether various functions (such as a registration function, a search function, an attribute adding function and the like) of the software meet the requirements; the interface test case is used for testing whether interface interaction and communication are normal or not; the compatibility test case is used for testing whether the software can normally run in different environments or not and the like.
The test cases of different types correspond to different test files, and one test file can contain test content descriptions and corresponding test rules corresponding to each of the plurality of test cases to be generated; a test content description and the corresponding test rules may be stored in a table form in a test file or in a form provided by a preset template; the server can extract information of each table in the test file, firstly, the server identifies the table format in the test file, and extracts the test content description and the corresponding test rule through table analysis.
In addition to table parsing, text content may be extracted by regular expressions, keyword extraction, deep learning based information extraction, and the like for test content descriptions and test rules stored in test files in other formats.
The following is mainly an expanded description of the functional test case and the interface test case.
When the test file is a functional requirement test file, the test content description is the functional requirement description in the functional requirement test file, and the test rule is a condition constraint rule corresponding to the functional requirement description; as shown in fig. 3, a schematic diagram of extracting text contents such as function requirement descriptions and condition constraint rules from a function requirement test file is provided in the embodiment of the present application, and a scenario is assumed to be a piece of sales software, so that a merchant is supported to add new attributes in respective stores, for example, a clothing merchant wants to add a "dress" sub-attribute under an original "skirt" attribute, and the method can be implemented by the function.
In a certain table of the function requirement test file, a test case number, a case name, a role required to be played by the model, a pre-condition of the newly added attribute, a function description, a function requirement description and a condition constraint rule corresponding to the newly added function of the attribute are recorded. The server analyzes and extracts text contents in the text contents through the table, and the extracted text contents are as follows:
case name: the attribute is newly added.
Roles: a system administrator.
The pre-condition is as follows: the main data used already exists.
Description of the functions: providing attribute adding function for the sales platform.
Description of functional requirements: 1. in the attribute management page, a merchant can enter a newly added attribute interface through a newly added button, and the interface supports input: attribute coding (filling-in), attribute value classification (filling-in), attribute name (filling-in), attribute description, father attribute, attribute type (filling-in), attribute feature (including feature type, feature value name), service type, attribute source (filling-in), group attribute coding, length, precision, empty or not, dynamic attribute identification and other information.
2. The feature type and feature value can be selected as: rendering type, control type, special access feature, business control type, sales attribute control type, etc.
3. If the attribute type is enumeration type, a plurality of attribute values are allowed to be added, including attribute value codes and attribute value names, and the added attribute values can support deletion. And when the attribute value is newly added, repeated attribute value codes and attribute value names can be checked.
4. When the attribute is newly added, repeated attribute codes can be encoded, and repeated attribute names can be checked.
Conditional constraint rules: attribute value classification value source dictionary type attribute value classification.
When the test file is an interface interaction test file, the test content is described as data calling parameters in the interface interaction test file, and in addition, other application programming interface parameters can be also included; the test rule is a message interaction protocol, and the message interaction protocol is used for specifying a message format and the like; when the test file is a unit test file, the server can extract functional points to realize a flow chart and program interface design information (such as interface information, interface processing logic, page design information, database change information and the like) from the unit test file.
Taking an actual scene as an example, assuming that a certain software needs to test the registration function of the software, a server acquires a test form corresponding to the registration function from a function requirement test file, analyzes text contents in the form, and the acquired text contents are as follows:
case name: and (5) registering.
Description of the functions: providing the software user with the ability to register a new account.
Description of functional requirements: 1. in the personal page, the software user can enter an account registration interface through a register new account button, and the interface supports input: account name (must be filled), gender, phone number (must be filled).
2. After the software user correctly fills in the information and clicks the completion button, the software user jumps to the registration success interface.
3. After the software user does not fill in the information correctly and clicks the completion button, the error is prompted at the corresponding position of the original interface.
Conditional constraint rules: and no.
S202: and the server splices the test content description and the test rule based on a preset format, and inputs a splicing result into the test case generation model.
After extracting text contents such as test content description, test rules, case names, case numbers and the like, the server splices all the text contents into a whole text based on a preset splicing format, and inputs the whole text into a test case generation model; the test case generation model may be a dialogue generation model.
And S201, after obtaining the content such as the function requirement description and the condition constraint rule corresponding to the registration function, the server splices the content according to a preset format and inputs the spliced content into the test case generation model.
S203: the server processes the data of the spliced result based on the test case generation model and a preset prompt corresponding to the test file to generate the test case.
In the above, the preset prompt is used for limiting the output content of the model, so that the model can be guided to generate test cases meeting the requirements, format references are provided for the test cases generated by the model, namely, the model can be guided to generate expected content by setting the prompt. In an actual application scene, different prompt languages are preset according to the types of the test cases, and in addition, the prompt languages can be changed based on specific requirements of the generation formats of the test cases.
After inputting a spliced whole text into the test case generation model, the model can output a corresponding test case according to a preset prompt; if the function test case is required to be generated, namely, when the test file is a function requirement test file, the corresponding preset prompt is a first preset prompt; if the interface test case needs to be generated, that is, when the test file is the interface interaction test file, the corresponding preset prompt is a second preset prompt.
The prompt is mainly used for providing test case format reference for the model, and still presumes that the test case corresponding to the attribute newly added function needs to be generated at present, after the main contents such as corresponding function requirement description, condition constraint rules and the like are spliced and input into the model, the server adopts the prompt to constrain and guide the output of the model, for example, the prompt can be:
assuming that software testing is required at present, please write functional test cases based on the input functional requirement description, condition constraint rules and other contents, and output the test cases according to the following templates:
test case number: beginning with the letter FN, numbered from 01.
Test case name: the attribute is newly added with a function test case.
Test purpose: and filling in actual contents of the test purpose according to the input text contents.
The pre-condition is as follows: and filling out the conditions required for testing according to the input text content.
The testing steps are as follows: and writing specific test execution steps according to the function requirement description in the input text content.
The expected results are: according to the text content input, the software should show the correct result after writing and executing the test step.
Actual results: and no.
Test conclusion: and no.
For the generated test cases, a tester can confirm whether the test cases are available, for example, whether the test rules are correct, whether the descriptions of all the functional points are covered or not, and the like, and store the test cases in a document form or output the test cases to a test case recording system; the tester can further optimize and fine tune the test cases, such as further refining the operation steps, adjusting the test case generation templates, and the like, so that the test cases can be stored in a document format conveniently later, or test scripts can be generated according to the test cases.
In addition, if the generated test case does not meet the preset test case specification, for example, the format of the test case is inaccurate and is not identical to the reference format provided by the prompt, the server may perform fine adjustment on the dialogue generating model, and in an alternative implementation manner, the server uses the dialogue generating model as an original dialogue generating model, and obtains training samples and sample labels corresponding to the training samples respectively to perform iterative training on the original dialogue generating model until the preset iteration times are reached, so as to obtain a target dialogue generating model; and then, using the target dialogue generating model as a new test case generating model to regenerate the test cases meeting the preset test case specifications.
In the above, the training sample mainly includes a preset training test case and a generated test case generated by a dialogue generated model; the training test case and the generated test case are provided with sample labels; the sample labels of the training test cases are used for identifying the corresponding training test cases as positive samples or negative samples; the sample label of the generated test case is used for identifying the corresponding generated test case as a positive sample or a negative sample; and because the generated test cases generated by the dialogue generated model mostly do not meet the test case specification, most or even all of the generated test cases are negative samples, and most of the training test cases are positive samples.
For each iterative training, the server performs the following process: selecting at least one training sample, and carrying out parameter fine adjustment on the reference dialogue generating model by combining sample labels corresponding to the at least one training sample to obtain an adjusted reference dialogue generating model; the adjusted reference dialogue generating model is used as a reference dialogue generating model for the next iteration training; the reference dialogue generating model in the first iterative training is the original dialogue generating model; and the adjusted reference dialogue generating model obtained by the last iteration training is the target dialogue generating model.
In the training process of the model, each training sample corresponds to a test content description and a test rule in a corresponding test file, for example, a certain training sample is a generated test case, is a negative sample (i.e. does not meet the test case specification), and the type of the test case is a functional test case, and is tested to be an attribute deleting function, then the attribute deleting function corresponds to a function requirement description and a condition constraint rule of the attribute deleting function in the function requirement test file, when the function requirement description and the condition constraint rule corresponding to the training sample are input into an original dialogue generating model, the model outputs a functional test case, the functional test case output by the model is compared with the training sample based on a sample label, and parameter fine adjustment is performed on the model according to a comparison result.
In the above, the training samples and the corresponding test content descriptions and test rules thereof may be recorded in a comparison table; under the condition of a small number of samples, the model is mainly trained by adopting a small sample learning mode, for example, 50 training samples can be selected for one iteration training, and the proportion of positive samples to negative samples in the 50 samples is approximately balanced.
The server can divide the training sample into two parts, one part is used for carrying out iterative training on the model, the other part is used for carrying out model test on the target dialogue generating model, and the parameter adjustment effect of the model is verified; that is, the server tests the target dialogue generating model based on each training sample and the sample label corresponding to each training sample; determining whether the test case generated by the target dialogue generation type model meets the test case specification or not based on the test result; and if the test case generated by the target dialogue generating model meets the test case specification, taking the target dialogue generating model as a new test case generating model.
If the test case generated by the target dialogue generation type model still does not meet the test case specification, further parameter adjustment can be performed on the target dialogue generation type model, and training and testing of the model are performed alternately until the model can stably generate the test case meeting the test case specification.
According to the method, the prompt is utilized, the control dialogue generation type model is used for generating the test cases in the appointed format according to the text content of the test file, the method for automatically generating the test cases directly according to the test text is realized, the coverage of the test requirements is full, the test case generation speed is high, and the pressure of testers is reduced.
Based on the above process, as shown in fig. 4, a logic diagram of training and testing of a model provided by an embodiment of the present application, a server extracts information from an acquired test file to obtain a test content description and a corresponding test rule, and splices and inputs the test content description and the corresponding test rule into a dialogue generating model, the dialogue generating model generates and outputs a test case according to a reference format of the test case provided by a preset prompt, and the server uses the generated test case as a generated test case, and adds the generated test case and the preset training test case to a training sample set, wherein the training sample set is used for parameter adjustment and model testing of the dialogue generating model.
And (3) along the assumption in S202, outputting a functional test case by the model according to the input contents of the functional requirement description, the condition constraint rule and the like and the test case format provided by the prompt, and taking the output test case as a training sample and marking as a negative sample by the server if the output test case does not accord with the test case specification.
After the model generates a certain number of test cases, parameter fine adjustment and model test are carried out on the model according to the generated test cases and preset training test cases until the model can stably output the test cases meeting the test case specifications.
As shown in fig. 5, for a logic diagram generated by a test case provided in this embodiment of the present application, a server performs table parsing on a test file, extracts text contents such as test content descriptions and test rules therein, splices and inputs the text contents into a dialogue generation model according to a preset format, and processes the input contents based on a prompt, so as to output the test case, where the test case shown in fig. 5 is:
1. case number FN01.
2. And (5) testing the name, namely adding the attribute and successfully storing.
3. Precondition, merchant is logged into the system and enters the newly added attribute interface.
4. Input data:
attribute coding, namely effective attribute coding;
attribute name: valid attribute name;
attribute type, effective attribute type;
attribute source, namely effective attribute source;
and other optional fields are effectively valued.
5. The operation steps are as follows.
(1) The valid values of the attribute codes, attribute names, attribute types, attribute sources and other optional fields are input.
(2) Clicking the save button.
6. The expected results are:
successfully saves the attribute and returns to the attribute management page.
The newly added attribute is displayed correctly in the attribute list.
7. Actual results:
8. whether or not by:
thereafter, the relevant personnel can manually make further optimizations to the test case.
Based on the same inventive concept, the embodiment of the application also provides a device for generating the test case. As shown in fig. 6, which is a schematic structural diagram of a test case generating device, may include:
an obtaining unit 601, configured to obtain a test content description in a test file and a test rule corresponding to the test content description; the test file is preset based on the test requirement;
the input unit 602 is configured to splice the test content description and the test rule based on a preset format, and input a splicing result into the test case generation model;
the generating unit 603 is configured to perform data processing on the splicing result based on the test case generating model and a preset prompt corresponding to the test file, so as to generate a test case; the preset prompt is used for providing a reference format for the generation of the test cases.
Optionally, the test file is a functional requirement test file, the test content description is a functional requirement description in the functional requirement test file, and the test rule is a condition constraint rule corresponding to the functional requirement description; the preset prompt is a first preset prompt corresponding to the functional requirement test file.
Optionally, the test file is an interface interaction test file, and the test content is described as a data calling parameter in the interface interaction test file, and is a message interaction protocol corresponding to the data calling parameter; the preset prompt is a second preset prompt corresponding to the interface interaction test file.
Optionally, the test case generating model is a dialogue generating model; the apparatus further comprises:
the training unit 604 is configured to, after generating the test case, take the dialogue generating model as an original dialogue generating model and obtain a training sample if the generated test case does not meet a preset test case specification;
performing iterative training on the original dialogue generating model by adopting a training sample to obtain a target dialogue generating model;
and using the target dialogue generating model as a new test case generating model to regenerate the test case.
Optionally, the training sample includes a preset training test case and a generated test case generated by the dialogue generation model; the training test case and the generated test case are provided with sample labels; the sample labels of the training test cases are used for identifying the corresponding training test cases as positive samples or negative samples; the sample label of the generated test case is used for identifying the corresponding generated test case as a positive sample or a negative sample;
Training unit 604 is specifically configured to:
performing iterative training on the original dialogue generating model based on the training samples and the sample labels corresponding to the training samples respectively until the preset iteration times are reached; wherein each iterative training performs the following process:
selecting at least one training sample, and carrying out parameter fine adjustment on the reference dialogue generating model by combining sample labels corresponding to the at least one training sample to obtain an adjusted reference dialogue generating model; the adjusted reference dialogue generating model is used as a reference dialogue generating model for the next iteration training; the reference dialogue generating model in the first iterative training is an original dialogue generating model;
the last iteration is used as a target dialogue generating model.
Optionally, the training unit 604 is specifically configured to:
testing the target dialogue generating model based on each training sample and the sample label corresponding to each training sample;
determining whether the test case generated by the target dialogue generation model meets the test case specification or not based on the test result;
and if the test case generated by the target dialogue generating model meets the test case specification, taking the target dialogue generating model as a new test case generating model.
Having introduced the method and apparatus for generating test cases according to an exemplary embodiment of the present application, next, an electronic device according to another exemplary embodiment of the present application is described.
Those skilled in the art will appreciate that the various aspects of the present application may be implemented as a system, method, or program product. Accordingly, aspects of the present application may be embodied in the following forms, namely: an entirely hardware embodiment, an entirely software embodiment (including firmware, micro-code, etc.) or an embodiment combining hardware and software aspects may be referred to herein as a "circuit," module "or" system.
The embodiment of the application also provides electronic equipment based on the same inventive concept as the embodiment of the method. In one embodiment, the electronic device may be a server, such as server 120 shown in FIG. 1. In this embodiment, the electronic device may be configured as shown in fig. 7, including a memory 701, a communication module 703, and one or more processors 702.
Memory 701 for storing a computer program for execution by processor 702. The memory 701 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, a program required for running an instant communication function, and the like; the storage data area can store various instant messaging information, operation instruction sets and the like.
The memory 701 may be a volatile memory (RAM), such as a random-access memory (RAM); the memory 701 may also be a nonvolatile memory (non-volatile memory), such as a read-only memory (rom), a flash memory (flash memory), a hard disk (HDD) or a Solid State Drive (SSD); or memory 701 is any other medium that can be used to carry or store a desired computer program in the form of instructions or data structures and that can be accessed by a computer, but is not limited to such. Memory 701 may be a combination of the above.
The processor 702 may include one or more central processing units (central processing unit, CPU) or digital processing units, or the like. A processor 702 for implementing the method for generating test cases when calling the computer program stored in the memory 701.
The communication module 703 is used for communicating with a terminal device and other servers.
The specific connection medium between the memory 701, the communication module 703, and the processor 702 is not limited in the embodiments of the present application. In the embodiment of the present application, the memory 701 and the processor 702 are connected by the bus 704 in fig. 7, and the bus 704 is depicted by a bold line in fig. 7, and the connection manner between other components is only schematically illustrated, and is not limited thereto. The bus 704 may be divided into an address bus, a data bus, a control bus, and the like. For ease of description, only one thick line is depicted in fig. 7, but only one bus or one type of bus is not depicted.
The memory 701 stores a computer storage medium, in which computer executable instructions are stored for implementing the method for generating test cases according to the embodiments of the present application. The processor 702 is configured to execute the method for generating test cases as described above, as shown in fig. 2.
In another embodiment, the electronic device may also be other electronic devices, such as terminal device 110 shown in fig. 1. In this embodiment, the structure of the electronic device may include, as shown in fig. 8: communication component 810, memory 820, display unit 830, camera 840, sensor 850, audio circuit 860, bluetooth module 870, processor 880, and the like.
The communication component 810 is for communicating with a server. In some embodiments, a circuit wireless fidelity (Wireless Fidelity, wiFi) module may be included, where the WiFi module belongs to a short-range wireless transmission technology, and the electronic device may help the user to send and receive information through the WiFi module.
Memory 820 may be used to store software programs and data. The processor 880 performs various functions of the terminal device 110 and data processing by executing software programs or data stored in the memory 820. Memory 820 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage device. Memory 820 stores an operating system that enables terminal device 110 to operate. The memory 820 may store an operating system and various application programs, and may also store a computer program for executing the method for generating test cases according to the embodiment of the present application.
The display unit 830 may also be used to display information input by a user or information provided to the user and a graphical user interface (graphical user interface, GUI) of various menus of the terminal device 110. In particular, the display unit 830 may include a display 832 disposed on a front surface of the terminal device 110. The display 832 may be configured in the form of a liquid crystal display, light emitting diodes, or the like.
The display unit 830 may also be used to receive input numeric or character information, generate signal inputs related to user settings and function controls of the terminal device 110, and in particular, the display unit 830 may include a touch screen 831 disposed on the front surface of the terminal device 110, and may collect touch operations on or near the user, such as clicking buttons, dragging scroll boxes, and the like.
The touch screen 831 may cover the display screen 832, or the touch screen 831 may be integrated with the display screen 832 to implement input and output functions of the terminal device 110, and after integration, the touch screen may be abbreviated as touch screen. The display unit 830 may display an application program and corresponding operation steps.
The camera 840 may be used to capture still images and a user may post images captured by the camera 840 through an application. The camera 840 may be one or more. The object generates an optical image through the lens and projects the optical image onto the photosensitive element. The photosensitive element may be a charge coupled device (charge coupled device, CCD) or a Complementary Metal Oxide Semiconductor (CMOS) phototransistor. The photosensitive elements convert the optical signals to electrical signals, which are then transferred to a processor 880 for conversion to digital image signals.
The terminal device may further comprise at least one sensor 850, such as an acceleration sensor 851, a distance sensor 852, a fingerprint sensor 853, a temperature sensor 854. The terminal device may also be configured with other sensors such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, light sensors, motion sensors, and the like.
Audio circuitry 860, speaker 861, microphone 862 may provide an audio interface between a user and terminal device 110. The audio circuit 860 may transmit the received electrical signal converted from audio data to the speaker 861, and the electrical signal is converted into a sound signal by the speaker 861 and output. The terminal device 110 may also be configured with a volume button for adjusting the volume of the sound signal. On the other hand, microphone 862 converts the collected sound signals into electrical signals, which are received by audio circuit 860 and converted into audio data, which are output to communication component 810 for transmission to, for example, another terminal device 110, or to memory 820 for further processing.
The bluetooth module 870 is used for exchanging information with other bluetooth devices having a bluetooth module through a bluetooth protocol. For example, the terminal device may establish a bluetooth connection with a wearable electronic device (e.g., a smart watch) that also has a bluetooth module through the bluetooth module 870, thereby performing data interaction.
The processor 880 is a control center of the terminal device, connects various parts of the entire terminal using various interfaces and lines, and performs various functions of the terminal device and processes data by running or executing software programs stored in the memory 820 and calling data stored in the memory 820. In some embodiments, processor 880 may include one or more processing units; the processor 880 may also integrate an application processor that primarily handles operating systems, user interfaces, applications, etc., and a baseband processor that primarily handles wireless communications. It will be appreciated that the baseband processor described above may not be integrated into the processor 880. The processor 880 in the present application may run an operating system, an application program, a user interface display, a touch response, and a method for generating a test case according to an embodiment of the present application. In addition, the processor 880 is coupled to the display unit 830.
In some possible embodiments, aspects of the test case generation method provided herein may also be implemented in the form of a program product, which includes a computer program for causing an electronic device to perform the steps in the test case generation method according to the various exemplary embodiments of the present application described herein above when the program product is run on the electronic device, for example, the electronic device may perform the steps as shown in fig. 2.
The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium would include the following: an electrical connection having one or more wires, a portable disk, a hard disk, random Access Memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various modifications and variations can be made in the present application without departing from the spirit or scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims and the equivalents thereof, the present application is intended to cover such modifications and variations.

Claims (10)

1. A method for generating test cases, the method comprising:
acquiring test content description in a test file and a test rule corresponding to the test content description; the test file is preset based on test requirements;
splicing the test content description and the test rule based on a preset format, and inputting a splicing result into a test case generation model;
Based on the test case generation model and a preset prompt corresponding to the test file, carrying out data processing on the splicing result to generate a test case; the preset prompt is used for providing a reference format for the generation of the test cases.
2. The method of claim 1, wherein the test file is a functional requirement test file, the test content description is a functional requirement description in the functional requirement test file, and the test rule is a condition constraint rule corresponding to the functional requirement description; the preset prompt is a first preset prompt corresponding to the function requirement test file.
3. The method of claim 1, wherein the test file is an interface interaction test file, the test content is described as a data call parameter in the interface interaction test file, and the test content is a message interaction protocol corresponding to the data call parameter; the preset prompt is a second preset prompt corresponding to the interface interaction test file.
4. A method according to any one of claims 1 to 3, wherein the test case generation model is a dialogue generation model; after the test case is generated, the method further comprises:
If the generated test case does not meet the preset test case specification, taking the dialogue generating model as an original dialogue generating model, and acquiring a training sample;
performing iterative training on the original dialogue generating model by adopting the training sample to obtain a target dialogue generating model;
and using the target dialogue generating model as a new test case generating model to regenerate the test case.
5. The method of claim 4, wherein the training samples comprise preset training test cases, and the generated test cases generated by the dialogue generation model; the training test case and the generated test case are provided with sample labels; the sample label of the training test case is used for identifying that the corresponding training test case is a positive sample or a negative sample; the sample label of the generated test case is used for identifying the corresponding generated test case as a positive sample or a negative sample;
performing iterative training on the original dialogue generating model by using the training sample to obtain a target dialogue generating model, including:
performing iterative training on the original dialogue generating model based on the training samples and sample labels corresponding to the training samples respectively until the preset iteration times are reached; wherein each iterative training performs the following process:
Selecting at least one training sample, and carrying out parameter fine adjustment on the reference dialogue generating model by combining sample labels corresponding to the at least one training sample to obtain an adjusted reference dialogue generating model; the adjusted reference dialogue generating model is used as a reference dialogue generating model for the next iteration training; a reference dialogue generating model in the first iterative training generates a model for the original dialogue;
and taking the last iteration as the target dialogue generation type model.
6. The method of claim 5, wherein said generating the model of the target dialog as a new test case generation model comprises:
testing the target dialogue generating model based on the training samples and the sample labels corresponding to the training samples;
determining whether the test case generated by the target dialogue generation model meets the test case specification or not based on a test result;
and if the test case generated by the target dialogue generating model meets the test case specification, taking the target dialogue generating model as a new test case generating model.
7. A test case generating apparatus, comprising:
the acquisition unit is used for acquiring the test content description in the test file and the test rule corresponding to the test content description; the test file is preset based on test requirements;
the input unit is used for splicing the test content description and the test rule based on a preset format and inputting the splicing result into a test case generation model;
the generating unit is used for carrying out data processing on the splicing result based on the test case generating model and a preset prompt corresponding to the test file to generate a test case; the preset prompt is used for providing a reference format for the generation of the test cases.
8. An electronic device comprising a processor and a memory, wherein the memory stores a computer program which, when executed by the processor, causes the processor to perform the steps of the method of any of claims 1 to 6.
9. A computer readable storage medium, characterized in that it comprises a computer program for causing an electronic device to perform the steps of the method according to any one of claims 1-6 when said computer program is run on the electronic device.
10. A computer program product comprising a computer program, the computer program being stored on a computer readable storage medium; when the computer program is read from the computer readable storage medium by a processor of an electronic device, the processor executes the computer program, causing the electronic device to perform the steps of the method of any one of claims 1-6.
CN202311392718.5A 2023-10-25 2023-10-25 Method and device for generating test case, electronic equipment and storage medium Pending CN117389890A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311392718.5A CN117389890A (en) 2023-10-25 2023-10-25 Method and device for generating test case, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311392718.5A CN117389890A (en) 2023-10-25 2023-10-25 Method and device for generating test case, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117389890A true CN117389890A (en) 2024-01-12

Family

ID=89435562

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311392718.5A Pending CN117389890A (en) 2023-10-25 2023-10-25 Method and device for generating test case, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117389890A (en)

Similar Documents

Publication Publication Date Title
US12008343B2 (en) System and method for a registration system within an intelligent digital experience development platform
CN108985358B (en) Emotion recognition method, device, equipment and storage medium
KR20210037619A (en) Multimodal content processing method, apparatus, device and storage medium
US11328116B2 (en) Intelligently identifying collaborators for a document
US11507677B2 (en) Image classification modeling while maintaining data privacy compliance
CN110442515B (en) Application testing method, device, equipment and readable storage medium
CN109815448B (en) Slide generation method and device
WO2023142451A1 (en) Workflow generation methods and apparatuses, and electronic device
US20190147104A1 (en) Method and apparatus for constructing artificial intelligence application
KR20210090576A (en) A method, an apparatus, an electronic device, a storage medium and a program for controlling quality
CN111611797A (en) Prediction data labeling method, device and equipment based on Albert model
US20230315990A1 (en) Text detection method and apparatus, electronic device, and storage medium
CN113568621A (en) Data processing method and device for page embedded point
CN117520497A (en) Large model interaction processing method, system, terminal, equipment and medium
US10825254B1 (en) Augmented reality book selection-assist
JP7029557B1 (en) Judgment device, judgment method and judgment program
US20210271720A1 (en) Method and apparatus for sending information
CN117389890A (en) Method and device for generating test case, electronic equipment and storage medium
CN114297380A (en) Data processing method, device, equipment and storage medium
CN109857838B (en) Method and apparatus for generating information
CN113420531A (en) Code text conversion method and device and storage medium
CN112951274A (en) Voice similarity determination method and device, and program product
CN118170378A (en) Page generation method, page generation device, electronic device, storage medium and program product
CN114611530A (en) Reading interaction device and method, computer equipment and reading pen
CN116342081A (en) Text processing method, device, equipment and medium

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