Method and device for generating test case, medium and equipment
By generating a tree structure of test case sets through multiple rounds of iteration, and utilizing a large model and iterative judgment, the problems of high complexity and poor adaptability in test case generation are solved, achieving high-quality and efficient test case generation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING ZITIAO NETWORK TECH CO LTD
- Filing Date
- 2024-10-18
- Publication Date
- 2026-04-21
AI Technical Summary
In existing technologies, test case generation relies on manual writing, which is time-consuming and labor-intensive, while automated generation suffers from low code coverage, numerous redundant test cases, and poor adaptability.
By generating a tree-like structure of test case sets through multiple rounds of iteration, and utilizing large models and iterative judgments to generate test cases, complexity is reduced and quality is improved.
It improves the quality and adaptability of generated test cases, reduces the probability of redundant and invalid test cases, and enhances code coverage and test effectiveness.
Smart Images

Figure CN121901089A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the fields of software testing and large model technology, and in particular to a method, apparatus, medium and device for generating test cases. Background Technology
[0002] A test case is a set of test inputs, execution conditions, and expected outputs designed for a specific test objective. It is typically the core of software testing, helping testers effectively execute tests and ensure software quality and stability. Currently, test cases primarily rely on manual writing by testers or automated generation. However, relying on manual writing consumes significant human and time resources. Automated generation of test cases still suffers from problems such as insufficient application code or functional coverage and poor adaptability to changes in software requirements. Summary of the Invention
[0003] This disclosure describes a method, apparatus, medium, and device for generating test cases.
[0004] According to the first aspect, a method for generating test cases is provided, including:
[0005] Obtain the target file and the first target model;
[0006] A target tree corresponding to a target test case set is obtained through multiple iterations based on the first target model, wherein at least one node of the target tree is generated based on the first target model and the target file; the target test case set contains one or more test cases, and the path from the root node to the leaf node in the target tree indicates the test cases. According to a second aspect, an apparatus for generating test cases is provided, comprising:
[0007] The acquisition unit is configured to acquire the target file and the first target model.
[0008] An iterative unit is configured to iterate multiple times based on the first target model to obtain a target tree corresponding to the target test case set, wherein at least one node of the target tree is generated based on the first target model and the target file; the target test case set contains one or more test cases, and the path from the root node to the leaf node in the target tree indicates the test cases.
[0009] According to a third aspect, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed in a computer, causes the computer to perform the method of the first aspect.
[0010] According to a fourth aspect, an electronic device is provided, including a memory and a processor, wherein the memory stores executable code, and the processor executes the executable code to implement the method of the first aspect.
[0011] According to embodiments of this disclosure, an apparatus, device, and medium are provided. First, a target file and a first target model can be obtained. Then, a target tree corresponding to a target test case set can be obtained through multiple iterations based on the first target model, wherein at least one node of the target tree is generated based on the first target model and the target file; the target test case set contains one or more test cases, and the path from the root node to the leaf node in the target tree indicates the test cases. This method reduces the complexity of test case generation, thereby improving the quality of the generated test cases. Attached Figure Description
[0012] Figure 1 A schematic diagram illustrating the manual generation of test cases is shown;
[0013] Figure 2 This diagram illustrates the generation of test cases using an automated method.
[0014] Figure 3 A schematic diagram of a method for generating test cases according to an embodiment of the present disclosure is shown;
[0015] Figure 4 A flowchart illustrating a method for generating test cases according to an embodiment of the present disclosure is shown;
[0016] Figure 5 A schematic diagram of a tree corresponding to a test case set according to an embodiment of this disclosure is shown;
[0017] Figure 6 A schematic block diagram of an apparatus for generating test cases according to an embodiment of the present disclosure is shown;
[0018] Figure 7 A schematic diagram of the structure of an electronic device suitable for implementing embodiments of the present disclosure is shown;
[0019] Figure 8 A schematic diagram of the structure of a storage medium suitable for implementing embodiments of the present disclosure is shown. Detailed Implementation
[0020] The technical solutions provided in this specification will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not intended to limit the invention. Furthermore, it should be noted that, for ease of description, only the parts relevant to the invention are shown in the accompanying drawings. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other.
[0021] In the description of the implementations disclosed herein, the term "comprising" and similar terms should be understood as open inclusion, i.e., "including but not limited to". The term "based on" should be understood as "at least partially based on". The term "one / an implementation" or "the implementation" should be understood as "at least one / an implementation". The term "some implementations" should be understood as "at least some implementations". Other explicit and implicit definitions may also be included below.
[0022] As mentioned earlier, a test case is a set of test inputs, execution conditions, and expected outputs designed for a specific test objective. It is typically the core of software testing, helping testers effectively execute tests and ensure software quality and stability. Currently, test cases primarily rely on manual writing by testers or automated generation. The manual writing method usually involves testers creating test cases specifically for the application under test, such as... Figure 1 As shown. However, this method requires significant manpower and time costs. Test cases generated automatically, on the other hand, are typically generated by automated test case generation tools specifically for the application under test, such as... Figure 2 As shown. However, due to the high complexity of generating complete test cases, automated test case generation tools still suffer from issues such as low quality of generated test cases. For example, there may be insufficient code or functional coverage of the application under test; a large number of redundant or invalid test cases may be generated, leading to wasted testing resources or poor testing results; and the test cases may have poor adaptability to changes in the requirements of the application under test.
[0023] To address the aforementioned technical problems, this disclosure provides a method for generating test cases. Figure 3 A schematic diagram of a method for generating test cases according to an embodiment of the present disclosure is shown. In some embodiments, a tree structure, or target tree, corresponding to a target test case set containing one or more test cases can be obtained through multiple rounds of iterative operations. The paths from the root node to each leaf node in the target tree can indicate each test case in the target test case set. Each leaf node can indicate the expected result of each test case, and the intermediate nodes between the root node and the leaf node in each path can indicate the preconditions or test steps of each test case. In any round of iterative operation, for example, the target node, which is a non-leaf node in the outermost node of the current target tree corresponding to the current round of iterative operation, can be obtained, and the child nodes of the target node can be obtained based on the requirement document and the path from the root node to the target node, according to the large model (or first target model). Figure 3As shown. The process involves judging the large model (or second target model) to determine if the generated target node's child nodes are correct. If correct, the next iteration begins; otherwise, the target node's child nodes are regenerated. This process continues until, after multiple iterations, all outermost nodes of the target tree are leaf nodes, completing the construction of the target tree. The target test case set, containing one or more test cases, can be easily obtained by traversing the paths from the root node to each leaf node within the target tree.
[0024] The advantages of this method are as follows: First, each test case in the test case set is generated in multiple iterations, with each iteration generating only a portion of the test case content, significantly reducing the complexity of test case generation. Furthermore, compared to existing automated test case generation schemes, this method improves the quality of generated test cases and reduces the probability of problems such as low code or functional coverage of the application under test, and an excessive number of redundant or invalid test cases. Second, this method can automatically generate test cases based on changes in the application under test's requirements document, thereby adapting to changes in the application's software requirements and improving the testing effectiveness for the application under test during long testing cycles.
[0025] The following describes the detailed process of this method.
[0026] Figure 4 A flowchart illustrating a method for generating test cases according to an embodiment of this disclosure is shown. Figure 4 As shown, the method includes at least the following steps:
[0027] Step S401: Obtain the target file and the first target model;
[0028] Step S403: Based on the first target model, a target tree corresponding to the target test case set is obtained through multiple iterations. At least one node of the target tree is generated based on the first target model and the target file. The target test case set contains one or more test cases, and the path from the root node to the leaf node in the target tree indicates the test cases.
[0029] First, in step S401, the target file and the first target model are obtained.
[0030] A target file is a file used to input a large model for obtaining test cases. In different embodiments, the target file can be different specific files, such as a requirements document. A requirements document is a detailed description of the product requirements for software or application (APP). In different specific embodiments, the target file can be a requirements document for different software or applications under test, and can contain different specific content; this specification does not limit this. For example, in one specific embodiment, the target file may include functional and / or non-functional requirements of the software or application under test. Functional requirements may include, for example, the data processing functions expected of the software under test (e.g., one or more of the capabilities to input, store, retrieve, update, and delete specific data). Non-functional requirements may include, for example, the performance requirements of the software under test (e.g., response time, throughput, resource utilization, etc.) and / or security requirements (e.g., access control, authentication, etc.).
[0031] Large models typically refer to artificial intelligence models with hundreds of millions or more parameters that have been pre-trained on massive datasets. In different embodiments, the first target model can be a large model of different specific types or with different neural network structures.
[0032] Then, in step S403, a target tree corresponding to the target test case set can be obtained through multiple iterations based on the first target model, wherein at least one node of the target tree is generated based on the first target model and the target file; the target test case set contains one or more test cases, and the path from the root node to the leaf node in the target tree indicates the test cases.
[0033] Specifically, this step can, for example, involve multiple iterations to obtain a target tree corresponding to a target test case set containing one or more test cases. In one example, the path from the root node to a leaf node in the target tree can indicate a test case, the root node can indicate the target test case set, the leaf node can indicate the expected result of the test case, and the intermediate nodes between the root node and the leaf node in the path indicate the preconditions or test steps of the test case. Specifically, one iteration operation can include: if all outermost nodes of the target tree are not leaf nodes, then obtaining the target node that is not a leaf node among the outermost nodes of the target tree corresponding to this iteration operation, and obtaining the child nodes of the target node through the first target model according to the target file. In one embodiment, if all outermost nodes of the current target tree are leaf nodes, it is determined that the target tree generation is complete. In this way, the end of multiple iteration operations can be determined.
[0034] Therefore, in one embodiment, the multiple iterations may include a first iteration, which may include the following operations: determining that all outermost nodes of the current target tree include non-leaf nodes, then obtaining the target node of the non-leaf nodes among the outermost nodes of the current target tree corresponding to this iteration, where the leaf nodes indicate the expected result of the test case; and obtaining the child nodes of the target node based on the target file through the first target model. In a specific embodiment, the root node may indicate the target test case set, and the intermediate nodes between the root node and the leaf nodes in the path indicate the preconditions or test steps of the test case. In this way, a test case set can be generated efficiently through multiple iterations, where each iteration only generates a portion of the test case content, greatly reducing the complexity of test case generation and improving the quality of the generated test cases.
[0035] In different embodiments, the specific method for obtaining the target node, which is a non-leaf node among the outermost nodes of the target tree corresponding to the current iteration operation, may vary, and this specification does not limit this. In one embodiment, for example, a non-leaf node among the outermost nodes of the target tree can be randomly selected as the target node. In another embodiment, the outermost nodes of the target tree can be searched, for example, based on a depth-first search algorithm or a breadth-first search algorithm, and the target node can be determined based on the non-leaf nodes among the searched outermost nodes.
[0036] In different embodiments, the specific methods for obtaining the child nodes of the target node through the first target model can vary. A prompt is the text information input to the large model, intended to guide the model to generate corresponding content based on the prompt. In one embodiment, a first prompt can be constructed based on the target file and the path from the root node to the target node. This first prompt is then input into the first target model to obtain the child nodes of the target node. This method allows for the efficient acquisition of the child nodes of the target node through the first target model.
[0037] In different specific embodiments, the specific representation of the first prompt word may differ, and this specification does not impose any limitations on this. Figure 5 In the example shown, in the multi-round iterative operation, the target node corresponding to the target round operation is, for example, the precondition C1, and its parent node is, for example, the root node of the target tree. The first prompt word could be, for example, "The requirement document is {}. Generate downstream nodes based on the upstream nodes of the test cases and return the list of downstream nodes. The upstream node is {test case set T->precondition C1}". Subsequently, for example, the child nodes "{operation step S1, operation step S2}" of the target node are obtained from the first target model.
[0038] In one embodiment, during any iteration, a second target model can be used to determine whether the target content indicated by the child node is correct. If the target content is correct, the child node is retained; if the target content is incorrect, the child node is regenerated using the first target model. In different specific embodiments, the second target model can also be a large model of different specific types or with different neural network structures. This approach can improve the quality of the child nodes retained by the target nodes in the target tree, thereby improving the quality of the generated test cases.
[0039] In different specific embodiments, the specific method for determining whether the target content indicated by the child node is correct through the second target model can vary. In one specific embodiment, a second prompt word for determining whether the target content indicated by the child node is correct can be constructed based on the target file and the path from the root node to the child node. The second prompt word is then input into the second target model to obtain a judgment result on whether the content indicated by the child node is correct. In different specific embodiments, the specific representation of the second prompt word can vary, and this specification does not limit it. This method can efficiently determine whether the content indicated by the child nodes generated from the target node is correct.
[0040] In some scenarios, multi-round iterative operations may include iterative operations for a target round, or simply target iterative operations. The target node corresponding to a target iterative operation can have multiple child nodes, for example... Figure 5 As shown, for example, the target iteration operation corresponds to the root node, which can have multiple child nodes: precondition C1, precondition C2, ... Similarly, the target iteration operation corresponds to precondition C1, which can also have multiple child nodes: operation step S1, operation step S1. Therefore, multiple child nodes of the target node can be generated in the target iteration operation. Thus, in a specific embodiment, multiple child nodes of the target node can be obtained based on the target file and through the first target model. Furthermore, the second target model can be used to determine whether the target content indicated by the multiple child nodes is correct. If the target content indicated by all child nodes of the target node is correct, then the multiple child nodes are retained; if the target content indicated by any child node of the target node is incorrect, then the multiple child nodes are regenerated. This method can reduce the probability of generating incorrect or invalid test cases and improve the quality of the generated test cases.
[0041] The reason is that the multiple child nodes of the target node generated by the first target model often correspond to the content of multiple test cases (e.g., expected conditions, operation steps, or expected results). These child nodes generated by the first target model usually have potential inherent relationships, such as generating multiple child nodes based on a single input, and different child nodes belonging to different or non-repeating test cases. Due to these inherent relationships, if any child node malfunctions, even if the other child nodes are not identified as malfunctions, it is difficult to ensure that the first target model will not malfunction when distinguishing the content of these nodes based on a single input. Therefore, when any child node of the target node malfunctions, regenerating all its child nodes can reduce the probability of generating erroneous or invalid test cases.
[0042] In different embodiments, the target tree obtained through multiple iterations can be different, and consequently, the multiple test cases that constitute the target test case set obtained from the target tree can be different. For example... Figure 5 In the example shown, multiple test cases can be obtained by following the paths from the root node (e.g., indicating the test case set T) to each leaf node. For example, the path from the root node to the expected result R1: root node -> precondition C1 -> operation step S1 -> expected result R1, yields test case T1, for example. The path from the root node to the expected result R2: root node -> precondition C1 -> operation step S2 -> expected result R2, yields test case T2, and so on. Similarly, the path from the root node T to the expected result R3 yields test case T3, and so on. Thus, all test cases in the test case set T can be obtained by following the paths from the root node T to all leaf nodes.
[0043] As mentioned earlier, large models are typically AI models pre-trained on large-scale data. To improve the generation effect of the first and / or second target models, they can be retrained. Retraining the first or second target model can be done based on the target tree or other trees similar to the target tree used to generate test case sets. Retraining the first or second target model based on the target tree can be done after the target tree is constructed. Retraining the first or second target model based on other trees can be done after obtaining the other trees, in different examples, such as... Figure 4 Before or after the method shown.
[0044] Specifically, in one embodiment, a first positive sample can be constructed based on the target file and the path from the root node to the intermediate node in the target tree. A first positive sample label is obtained based on the child nodes of the intermediate nodes. The first target model is then retrained using the first positive sample and its label. Retraining the first target model with the first positive sample and label makes the subsequent output of the first target model (the nodes in the tree structure corresponding to the test case set) closer to the correct result. In different embodiments, retraining can be performed using different specific training methods, such as different training objective functions, increasing or modifying the number of neural network layers in the first target model, etc. This specification does not limit this. Therefore, this method can improve the generation effect of the first target model after retraining.
[0045] In one embodiment, a second positive sample can be constructed based on the target file and the actual path from the root node to an intermediate or leaf node in the target tree. A label for the second positive sample is obtained based on the first value indicating correctness. The second target model is then retrained using the second positive sample and its label. Retraining the second target model with the second positive sample and its label makes the subsequent output of the second target model more closely approximate the correct result for the input content. In different embodiments, retraining can be performed using different specific training methods, such as different training objective functions, increasing or modifying the number of neural network layers in the second target model, etc. This specification does not limit this approach. This method can improve the generation effect of the retrained second target model.
[0046] In one embodiment, a first negative sample can be constructed based on the target file and the non-real paths from the root node to intermediate or leaf nodes in the target tree. A first negative sample label is obtained based on a second value indicating an error. The second target model is then retrained using the first negative sample and its label. Retraining the second target model using the second negative sample and its label allows the subsequent output of the second target model to be further away from erroneous results. In different embodiments, retraining can also be performed using different specific training methods, which are not limited in this specification. This method can further improve the generation effect of the retrained second target model.
[0047] In some scenarios, the first target model can be retrained based on other documents related to the target file. Therefore, in one embodiment, the target file may include test content for the target business. Furthermore, based on the operation manual or related preset test cases of the target business, question pairs including questions and answers can be constructed, where the questions indicate optional operations in the target business, and the answers indicate the results of the optional operations; the first target model is then retrained using these question pairs. Although generating the answers to the questions is not necessary when actually using the first target model to generate the tree structure nodes corresponding to the test case set, this method can deepen the first target model's understanding of relevant business operations and their results, thereby further improving the generation effect after retraining the first target model.
[0048] Figure 6 A schematic block diagram of an apparatus for generating test cases according to an embodiment of the present disclosure is shown. The apparatus is used to perform, for example... Figure 4 The method shown. (As illustrated) Figure 6 As shown, the device 600 includes:
[0049] Acquisition unit 601 is configured to acquire the target file and the first target model;
[0050] The iteration unit 602 is configured to obtain a target tree corresponding to the target test case set through multiple iterations based on the first target model, wherein at least one node of the target tree is generated based on the first target model and the target file; the target test case set contains one or more test cases, and the path from the root node to the leaf node in the target tree indicates the test cases.
[0051] This disclosure also provides an electronic device, including a memory and a processor. The memory stores executable code, and when the processor executes the executable code, it implements, for example... Figure 4 The method shown.
[0052] The following can also be referenced Figure 7 It shows a schematic diagram of the structure of an electronic device 700 suitable for implementing embodiments of the present disclosure. Figure 7 The illustrated electronic device 700 is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0053] like Figure 7As shown, the electronic device 700 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 701. The aforementioned processing device 701 may be a general-purpose processor, a digital signal processor (DSP), a microprocessor, or a microcontroller, and may further include an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can perform various appropriate actions and processes based on a program stored in read-only memory (ROM) 702 or a program loaded from storage device 708 into random access memory (RAM) 703. RAM 703 also stores various programs and data required for the operation of the electronic device 700. The processing device 701, ROM 702, and RAM 703 are interconnected via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0054] Typically, the following devices can be connected to I / O interface 705: input devices 706 including, for example, touchscreens, touchpads, keyboards, mice, etc.; output devices 707 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 708 including, for example, magnetic tapes, hard disks, etc.; and communication devices 709. Communication device 709 allows electronic device 700 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 7 An electronic device 700 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively. Figure 7 Each box shown can represent a device or multiple devices as needed.
[0055] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication device 709, or installed from storage device 708, or installed from ROM 702. When the computer program is executed by processing device 701, it performs the functions defined in the method for generating test cases provided by embodiments of this disclosure.
[0056] This disclosure also provides a computer-readable storage medium storing a computer program thereon. When the computer program is executed in a computer, it causes the computer to perform the functions provided in this disclosure. Figure 4 The image shows a method for generating test cases. Figure 8 A schematic diagram illustrating a storage medium for implementing an embodiment of this disclosure. For example, such as... Figure 8 As shown, the storage medium 800 can be a non-transitory computer-readable storage medium used to store non-transitory computer-executable instructions 801. When the non-transitory computer-executable instructions 801 are executed by a processor, a method for generating test cases provided in this disclosure embodiment can be implemented. For example, when the non-transitory computer-executable instructions 801 are executed by a processor, one or more steps in the method for generating test cases provided in this disclosure embodiment can be performed. For example, the storage medium 800 can be applied in the above-mentioned electronic device; for example, the storage medium 800 may include the memory in the electronic device. For a description of the storage medium 800, please refer to the description of the memory in the embodiments of the electronic device; repeated descriptions will not be repeated here. The specific functions and technical effects of the storage medium 800 can be referred to the description of the method for generating test cases provided in the embodiments of this disclosure; repeated descriptions will not be repeated here.
[0057] It should be noted that the computer-readable medium in the embodiments of this disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium may be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a memory card of a smartphone, a storage component of a tablet computer, a portable computer disk, a hard disk of a personal computer, 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), optical storage device, magnetic storage device, or any suitable combination thereof. In the embodiments of this disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the embodiments of this disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, wherein computer-readable program code is carried. The transmitted data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (Radio Frequency), etc., or any suitable combination thereof.
[0058] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device. The aforementioned computer-readable medium carries one or more programs, which, when executed by the server, cause the electronic device to implement a method for generating test cases provided in the embodiments of this disclosure.
[0059] Computer program code for performing the operations of embodiments of this disclosure can be written in one or more programming languages or a combination thereof. Programming languages include object-oriented programming languages—such as Java, Smalltalk, and C++—and conventional procedural programming languages—such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0060] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions. The units described in the embodiments of the present disclosure may be implemented in software or hardware. The names of the units do not necessarily constitute a limitation on the unit itself. The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), Systems-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0061] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the embodiments for storage media and computing devices are basically similar to the method embodiments, so they are described more simply; relevant parts can be referred to the descriptions of the method embodiments.
[0062] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above-described features with (but not limited to) technical features with similar functions disclosed in this disclosure. Furthermore, although the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, although several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of a single embodiment may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0063] The above detailed embodiments further illustrate the purpose, technical solution, and beneficial effects of the embodiments of the present invention. Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative forms of implementing the claims. It should be understood that the above are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made on the basis of the technical solutions of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for generating test cases, comprising: Obtain the target file and the first target model; Based on the first target model, a target tree corresponding to the target test case set is obtained through multiple iterations, wherein at least one node of the target tree is generated based on the first target model and the target file; The target test case set contains one or more test cases, and the path from the root node to the leaf node in the target tree indicates the test cases.
2. The method according to claim 1, wherein, The multiple iterations include a first iteration, which includes: If it is determined that all outermost nodes of the current target tree include non-leaf nodes, then the target node of the non-leaf nodes in the outermost nodes of the current target tree corresponding to this iteration is obtained, and the leaf node indicates the expected result of the test case; Based on the target file, the child nodes of the target node are obtained through the first target model.
3. The method according to claim 1, wherein, The root node indicates the target test case set, and the intermediate nodes between the root node and the leaf nodes in the path indicate the preconditions or test steps of the test cases.
4. The method according to claim 1, wherein, Based on the target file, the child nodes of the target node are obtained through the first target model, including: Based on the target file and the path from the root node to the target node, a first prompt word is constructed, and the first prompt word is input into the first target model to obtain the child nodes of the target node.
5. The method according to claim 2, wherein, The first iteration also includes: The second target model is used to determine whether the target content indicated by the child node is correct. If the target content is correct, the child node is retained; if the target content is incorrect, the child node is regenerated using the first target model.
6. The method according to claim 5, wherein, Obtaining the child nodes of the target node through the first target model includes: obtaining multiple child nodes of the target node through the first target model; Using the second target model, it is determined whether the target content indicated by the child nodes is correct, including: using the second target model, it is determined whether the target content indicated by the multiple child nodes is correct. If the target content is correct, then the child nodes are retained, including: if the target content indicated by multiple child nodes of the target node is correct, then the multiple child nodes are retained; If the target content is incorrect, the child node is regenerated using the first target model, including: if the target content indicated by any child node of the target node is incorrect, the plurality of child nodes are regenerated.
7. The method according to claim 5, wherein, Using the second target model, it is determined whether the target content indicated by the child node is correct, including: Based on the target file and the path from the root node to the child node, a second prompt word is constructed to determine whether the target content indicated by the child node is correct. The second prompt word is then input into the second target model to obtain the judgment result on whether the content indicated by the child node is correct.
8. The method according to claim 1, wherein, The first iteration also includes: If all outermost nodes of the target tree are leaf nodes, the target tree is considered to have been successfully generated.
9. The method according to claim 1, further comprising: Based on the target file and the path from the root node to the intermediate node in the target tree, a first positive sample is constructed, wherein the intermediate node is located between the root node and the leaf node. The first positive sample label is obtained based on the child nodes of the intermediate node, and the first target model is retrained using the first positive sample and the first positive sample label.
10. The method according to claim 1, wherein, The target file includes test content for the target business; The method further includes: Based on the operation manual or related preset test cases of the target service, construct a question pair including a question and an answer, wherein the question indicates an optional operation in the target service and the answer indicates the result of the optional operation; and retrain the first target model using the question pair.
11. The method according to claim 1, further comprising: Based on the target file and the actual path from the root node to the intermediate node or leaf node in the target tree, a second positive sample is constructed, wherein the intermediate node is located between the root node and the leaf node; the label of the second positive sample is obtained based on the first value indicating that it is correct, and the second target model is retrained using the second positive sample and the label of the second positive sample.
12. The method according to claim 1, further comprising: Based on the target file and the non-real paths from the root node to intermediate or leaf nodes in the target tree, a first negative sample is constructed, wherein the intermediate node is located between the root node and the leaf node; the label of the first negative sample is obtained based on the second value indicating the error; and the second target model is retrained using the first negative sample and the label of the first negative sample.
13. An apparatus for generating test cases, comprising: The acquisition unit is configured to acquire the target file and the first target model. An iterative unit is configured to iterate multiple times based on the first target model to obtain a target tree corresponding to the target test case set, wherein at least one node of the target tree is generated based on the first target model and the target file; The target test case set contains one or more test cases, and the path from the root node to the leaf node in the target tree indicates the test cases.
14. A computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to perform the method of any one of claims 1-12.
15. An electronic device comprising a memory and a processor, wherein the memory stores executable code, and the processor, when executing the executable code, implements the method of any one of claims 1-12.