Test case generation method and device based on artificial intelligence, electronic equipment, readable storage medium and computer program product

Through the large language model based on artificial intelligence, the problem of inefficient design of traditional test cases is solved, and more efficient and comprehensive test case generation is achieved.

CN120144455APending Publication Date: 2025-06-13BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510221762.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-26
Publication Date
2025-06-13

AI Technical Summary

Technical Problem

The design and generation of traditional test cases rely on manual labor, is inefficient and is prone to miss test coverage, resulting in incomplete testing.

Method used

Using a large language model based on artificial intelligence, by obtaining test demand data related to the functions of the product to be tested, a first state diagram with the functional module as the state node and a second state diagram with the functional point as the state node is generated, and a corresponding set of test cases is automatically generated.

Benefits of technology

Improves the efficiency and coverage of test case generation, reduces manual intervention, and ensures the comprehensiveness and accuracy of test cases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120144455A_ABST
    Figure CN120144455A_ABST
Patent Text Reader

Abstract

The invention provides a test case generation method and device based on artificial intelligence, electronic equipment, a readable storage medium and a computer program product, and relates to the field of intelligent generation, in particular to the field of artificial intelligence and testing. According to the implementation scheme, test demand data related to functions of a to-be-tested product are obtained, the functions of the to-be-tested product comprise a plurality of function modules, and each function module comprises at least one function point; based on the test demand data, a large language model is utilized to obtain a first state diagram and a second state diagram, the first state diagram comprises a plurality of first state nodes, the first state nodes correspond to one corresponding function module in the function modules, and the second state diagram comprises a plurality of second state nodes; and based on the first state diagram and the second state diagram, obtaining a first test case set corresponding to the test demand data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence, and particularly to the fields of intelligent generation and testing. Specifically, it relates to a method, apparatus, electronic device, computer-readable storage medium, and computer program product for generating test cases based on artificial intelligence. Background Art

[0002] Artificial intelligence is a discipline that studies how to make a computer simulate certain human thinking processes and intelligent behaviors (such as learning, reasoning, thinking, planning, etc.). It has both hardware-level technologies and software-level technologies. Artificial intelligence hardware technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, and big data processing; artificial intelligence software technologies mainly include several major directions such as computer vision technology, speech recognition technology, natural language processing technology, and machine learning / deep learning, big data processing technology, and knowledge graph technology.

[0003] With the highly mature software development technology, in order to ensure the quality of the developed products, how to efficiently and effectively test the product functions has attracted more and more attention from the relevant industries. And an adaptable and comprehensive set of test cases is an important basis for effective testing. In traditional technologies, test cases usually need to be manually designed by developers, and then the corresponding tests are completed by executing the test cases through code. The maturity of artificial intelligence technology provides a technical basis for the automatic generation of test cases, including the analysis of user requirements, the automatic generation of test case code, and the automatic generation of test data, etc.

[0004] The methods described in this section are not necessarily methods that have been previously conceived or adopted. Unless otherwise specified, any method described in this section should not be considered prior art merely because it is included in this section. Similarly, unless otherwise specified, the problems mentioned in this section should not be considered to have been recognized in any prior art. Summary of the Invention

[0005] The present disclosure provides a method, apparatus, electronic device, computer-readable storage medium, and computer program product for generating test cases based on artificial intelligence.

[0006] According to one aspect of the present disclosure, there is provided an artificial intelligence-based test case generation method, including: obtaining test requirement data related to the functions of a product under test, wherein the functions of the product under test include multiple function modules, the function modules include at least one function point, and the function point corresponds to the smallest execution unit for completing a specific function; based on the test requirement data, using a large language model, obtaining a first state diagram and a second state diagram, wherein the first state diagram includes multiple first state nodes, the first state nodes correspond to a respective function module among the multiple function modules, the second state diagram includes multiple second state nodes, the second state nodes correspond to a respective function point of the functions of the product under test, and the node information of the first state node includes the node indexes of one or more second state nodes corresponding to the first state node; and based on the first state diagram and the second state diagram, obtaining a first test case set corresponding to the test requirement data.

[0007] According to a second aspect of the present disclosure, there is provided an artificial intelligence-based test case generation device, including: a test requirement data acquisition module for obtaining test requirement data related to the functions of a product under test, wherein the functions of the product under test include multiple function modules, the function modules include at least one function point, and the function point corresponds to the smallest execution unit for completing a specific function; a state diagram generation module for obtaining a first state diagram and a second state diagram based on the test requirement data using a large language model, wherein the first state diagram includes multiple first state nodes, the first state nodes correspond to a respective function module among the multiple function modules, the second state diagram includes multiple second state nodes, the second state nodes correspond to a respective function point of the functions of the product under test, and the node information of the first state node includes the node indexes of one or more second state nodes corresponding to the first state node; and a test case set generation module for obtaining a first test case set corresponding to the test requirement data based on the first state diagram and the second state diagram.

[0008] According to a third aspect of the present disclosure, there is provided an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and when the instructions are executed by the at least one processor, the at least one processor is enabled to execute the above-mentioned test case generation method.

[0009] According to a fourth aspect of the present disclosure, there is provided a computer-readable storage medium having stored thereon a computer program, which when executed by a processor, causes the processor to implement the test case generation method as described above.

[0010] According to a fifth aspect of the present disclosure, there is provided a computer program product including a computer program, wherein the computer program, when executed by a processor, implements the above-described test case generation method.

[0011] According to one or more embodiments of the present disclosure, a first state diagram with functional modules as state nodes and a second state diagram with function points as state nodes are obtained using a large language model. Based on the first state diagram and the second state diagram, test cases corresponding to product requirement data are generated, providing an efficient artificial intelligence-based test case generation method and device.

[0012] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it used to limit the scope of the present disclosure. Other features of the present disclosure will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] The drawings exemplarily illustrate embodiments and form a part of the specification, and are used together with the written description of the specification to explain the exemplary embodiments of the embodiments. The illustrated embodiments are for illustrative purposes only and do not limit the scope of the claims. In all the drawings, the same reference numerals refer to similar but not necessarily identical elements.

[0014] Figure 1 A schematic diagram of an exemplary system in which the various methods described herein can be implemented according to an embodiment of the present disclosure;

[0015] Figure 2 A flowchart of an artificial intelligence-based test case generation method according to an embodiment of the present disclosure;

[0016] Figure 3 A flowchart of a first test case set generation method 300 according to an embodiment of the present disclosure;

[0017] Figure 4 A flowchart of a first test case set generation method 400 according to an embodiment of the present disclosure;

[0018] Figure 5 A flowchart of a method 500 for updating a first test case set according to an embodiment of the present disclosure;

[0019] Figure 6 A block diagram of an artificial intelligence-based test case generation device 600 according to an embodiment of the present disclosure;

[0020] Figure 7 A block diagram of an exemplary electronic device capable of implementing the embodiments of the present disclosure. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0021] Exemplary embodiments of the present disclosure will be described below with reference to the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0022] In the present disclosure, unless otherwise specified, the terms "first", "second", etc. are used to describe various elements and are not intended to limit the positional relationship, temporal relationship, or importance relationship of these elements. Such terms are only used to distinguish one element from another. In some examples, the first element and the second element may refer to the same instance of the element, and in certain cases, based on the context description, they may also refer to different instances.

[0023] In the description of various examples in the present disclosure, the terms used are only for the purpose of describing specific examples and are not intended to be limiting. Unless the context clearly indicates otherwise, if the number of elements is not specifically limited, the element may be one or more. In addition, the term "and / or" used in the present disclosure covers any one of the listed items and all possible combinations.

[0024] Embodiments of the present disclosure will be described in detail below with reference to the accompanying drawings.

[0025] Figure 1 A schematic diagram of an exemplary system 100 in which various methods and apparatuses described herein can be implemented according to embodiments of the present disclosure is shown. Referring Figure 1 , the system 100 includes one or more client devices 101, 102, 103, 104, 105, and 106, a server 120, and one or more communication networks 110 that couple the one or more client devices to the server 120. The client devices 101, 102, 103, 104, 105, and 106 can be configured to execute one or more applications.

[0026] In embodiments of the present disclosure, the server 120 can run one or more services or software applications that enable the execution of an artificial intelligence-based test case generation method.

[0027] In certain embodiments, the server 120 can also provide other services or software applications, which can include non-virtual environments and virtual environments. In certain embodiments, these services can be provided as web-based services or cloud services, for example, provided to users of the client devices 101, 102, 103, 104, 105, and / or 106 under a software as a service (SaaS) model.

[0028] In Figure 1 the configuration shown, server 120 may include one or more components that implement the functions performed by server 120. These components may include software components, hardware components, or a combination thereof that may be executed by one or more processors. Users operating client devices 101, 102, 103, 104, 105, and / or 106 may in turn utilize one or more client applications to interact with server 120 to utilize the services provided by these components. It should be understood that a variety of different system configurations are possible, which may differ from system 100. Thus, Figure 1 is an example of a system for implementing the various methods described herein and is not intended to be limiting.

[0029] Users may use client devices 101, 102, 103, 104, 105, and / or 106 to implement the generation of test cases. The client device may provide an interface that enables a user of the client device to interact with the client device. The client device may also output information to the user via the interface. Although Figure 1 only six client devices are depicted, those skilled in the art will be able to understand that the present disclosure may support any number of client devices.

[0030] Client devices 101, 102, 103, 104, 105, and / or 106 may include various types of computer devices, such as portable handheld devices, general-purpose computers (such as personal computers and laptop computers), workstation computers, wearable devices, smart screen devices, self-service terminal devices, service robots, gaming systems, thin clients, various messaging devices, sensors, or other sensing devices, etc. These computer devices may run various types and versions of software applications and operating systems, such as MICROSOFT Windows, APPLE iOS, UNIX-like operating systems, Linux, or Linux-like operating systems (such as GOOGLE Chrome OS); or include various mobile operating systems, such as MICROSOFT WindowsMobile OS, iOS, Windows Phone, Android. Portable handheld devices may include cellular phones, smartphones, tablets, personal digital assistants (PDAs), etc. Wearable devices may include head-mounted displays (such as smart glasses) and other devices. Gaming systems may include various handheld gaming devices, Internet-enabled gaming devices, etc. The client device is capable of executing various different applications, such as various Internet-related applications, communication applications (such as email applications), short message service (SMS) applications, and may use various communication protocols.

[0031] Network 110 can be any type of network well-known to those skilled in the art, which can support data communication using any one of a variety of available protocols (including but not limited to TCP / IP, SNA, IPX, etc.). By way of example only, one or more networks 110 can be a local area network (LAN), an Ethernet-based network, Token Ring, a wide area network (WAN), the Internet, a virtual network, a virtual private network (VPN), an intranet, an extranet, a blockchain network, a public switched telephone network (PSTN), an infrared network, a wireless network (such as Bluetooth, WIFI), and / or any combination of these and / or other networks.

[0032] Server 120 can include one or more general-purpose computers, dedicated server computers (such as PC (personal computer) servers, UNIX servers, midrange servers), blade servers, mainframes, server clusters, or any other suitable arrangement and / or combination. Server 120 can include one or more virtual machines running a virtual operating system, or other computing architectures involving virtualization (such as one or more flexible pools of logical storage devices that can be virtualized to maintain virtual storage devices of the server). In various embodiments, server 120 can run one or more services or software applications that provide the functions described below.

[0033] The computing units in server 120 can run one or more operating systems including any of the above operating systems as well as any commercially available server operating systems. Server 120 can also run any one of a variety of additional server applications and / or middleware applications, including HTTP servers, FTP servers, CGI servers, JAVA servers, database servers, etc.

[0034] In some embodiments, server 120 can include one or more applications to analyze and merge data feeds and / or event updates received from users of client devices 101, 102, 103, 104, 105, and / or 106. Server 120 can also include one or more applications to display data feeds and / or real-time events via one or more display devices of client devices 101, 102, 103, 104, 105, and / or 106.

[0035] In some embodiments, the server 120 can be a server of a distributed system or a server integrated with a blockchain. The server 120 can also be a cloud server or an intelligent cloud computing server or an intelligent cloud host with artificial intelligence technology. A cloud server is a host product in a cloud computing service system, which solves the defects of high management difficulty and weak business scalability existing in traditional physical hosts and virtual private server (VPS) services.

[0036] The system 100 may further include one or more databases 130. In certain embodiments, these databases can be used to store data and other information. For example, one or more of the databases 130 can be used to store information such as audio files and video files. The databases 130 can reside in various locations. For example, the databases used by the server 120 can be local to the server 120, or can be remote from the server 120 and can communicate with the server 120 via a network-based or dedicated connection. The databases 130 can be of different types. In certain embodiments, the databases used by the server 120 can be, for example, relational databases. One or more of these databases can store, update, and retrieve data to and from the databases in response to commands.

[0037] In certain embodiments, one or more of the databases 130 can also be used by applications to store application data. The databases used by applications can be different types of databases, such as key-value repositories, object repositories, or conventional repositories supported by a file system.

[0038] Figure 1 The system 100 can be configured and operated in various ways to enable the application of the various methods and apparatuses described according to the present disclosure.

[0039] Figure 2 is a flowchart showing an artificial intelligence-based test case generation method 200 according to an embodiment of the present disclosure, as Figure 2As shown, the artificial intelligence-based test case generation method may include: Step S202, obtaining test requirement data related to the functions of the product under test. Among them, the functions of the product under test include multiple functional modules, and the functional module includes at least one function point, and the function point corresponds to the smallest execution unit for completing a specific function; Step S204, based on the test requirement data, using a large language model to obtain a first state diagram and a second state diagram. Among them, the first state diagram includes multiple first state nodes, and the first state node corresponds to a corresponding functional module among the multiple functional modules. Among them, the second state diagram includes multiple second state nodes, and the second state node corresponds to a corresponding function point of the function of the product under test. The node information of the first state node includes the node indexes of one or more second state nodes corresponding to the first state node; and Step S206, based on the first state diagram and the second state diagram, obtaining a first test case set corresponding to the test requirement data.

[0040] In this embodiment, a first state diagram with functional modules as state nodes and a second state diagram with function points as state nodes are obtained based on a large language model. Based on the first state diagram and the second state diagram, a first test case set corresponding to the test requirement data is generated, effectively improving the efficiency and coverage of test case generation.

[0041] In some embodiments, the test requirement data can be obtained by using a large model to perform structured extraction on the product requirement document, such as distinguishing chapter titles, function lists, and specific function descriptions; splitting the requirements in a functional segmentation and tagging manner, such as mapping function descriptions, input / output requirements, and business logics to corresponding hierarchical relationships respectively.

[0042] In some embodiments, the test requirement data at least includes scenario description data, functional module description data, functional module input / output rule description data, and function point input / output rule description data.

[0043] In some embodiments, the functional module is a large functional unit or subsystem divided by product developers according to requirements for the product system. One functional module includes multiple function points; the function point is a specific and realizable smallest unit under the functional module, used to meet the sub-requirements of specific user needs, and the function point is the direct mapping object of user needs to technical implementation.

[0044] For example, in a user management system, there can be a "login module", a "registration module", and a "permission management module". The function points under the "functional module" can include: Function point 1: Verify the username and password; Function point 2: Redirection logic after successful login; and Function point 3: Locking function after multiple failed logins.

[0045] In some embodiments, the first state diagram describes the dynamic behavior of the first state nodes based on the first state trigger conditions, shows the responses of the first state nodes to different events according to the current state and the first constraint conditions, and the first state nodes are linked together by the first state transition conditions.

[0046] In some embodiments, the second state diagram describes the dynamic behavior of the second state nodes based on the second state trigger conditions, shows the responses of the second state nodes to different events according to the current state and the second constraint conditions, and the second state nodes are linked together by the second state transition conditions.

[0047] In some embodiments, according to the product requirement data, one or more second state nodes in the second state diagram can be logically associated with the first state nodes; the second state nodes in the second state diagram can be logically associated with one or more first state nodes in the first state diagram.

[0048] Figure 3 is a flowchart showing a first test case set generation method 300 according to an embodiment of the present disclosure. As Figure 3 shown, obtaining a first test case set corresponding to the test requirement data based on the first state diagram and the second state diagram includes: Step S302, for at least one first state node among the multiple first state nodes, based on the node index corresponding to the first state node and the second state diagram, obtaining a first number of test cases corresponding to at least one second state node corresponding to the first state node; based on the first number of test cases, obtaining a first test case for the functional module corresponding to the first state node; and Step S304, based on the first state diagram and the first test cases of at least one functional module among the multiple functional modules, obtaining a first test case set corresponding to the test requirement data.

[0049] In this embodiment, a first number of test cases for one or more second state nodes of the first state node corresponding to the functional module are respectively constructed, and based on the first number of test cases, a first test case for the functional module corresponding to the first state node is obtained, ensuring the independence between the functional module test cases, thereby effectively improving the flexibility of test case scheduling.

[0050] In some embodiments, the node index is used to uniquely identify the second state node; the first quantity of test cases corresponding to the second state node includes at least one of the following test cases: normal path test case, abnormal path test case, and boundary condition test case. For example, corresponding to the second state node with the function point of "user login", the normal path test case may be that after entering the correct username / password, it jumps to the main page; the abnormal path test case may be that when the username or password is incorrect, a prompt of "username or password is incorrect" is displayed; the boundary condition test case may be that when the length of the password field exceeds the set length, the re-verification function is triggered.

[0051] In some embodiments, in step S304, the obtaining of the first test case set corresponding to the test requirement data based on the first state diagram and the first test cases of at least one functional module among the multiple functional modules includes: using the first test cases of each functional module among the at least one functional module to obtain the first test case set corresponding to the test requirement data.

[0052] In some embodiments, in step S304, the obtaining of the first quantity of test cases corresponding to at least one second state node corresponding to the first state node based on the node index corresponding to the first state node and the second state diagram includes: obtaining the first requirement priority of the first state node based on the product requirement data; based on the first requirement priority and system resources, using the first test cases of the functional modules that meet the first requirement priority threshold among the at least one functional module to obtain the first test case set corresponding to the test requirement data.

[0053] In some embodiments, obtaining the first quantity of test cases corresponding to at least one second state node corresponding to the first state node based on the node index corresponding to the first state node and the second state diagram includes: for at least one second state node corresponding to the first state node, constructing a first test case template for the second state node based on the second state diagram and the first function description data of the function point corresponding to the second state node, where the first test case template at least includes the test path and the test expected result of the second state node; based on the second state diagram and the first constraint condition data of the function point corresponding to the second state node, using a test data generation model, obtaining first test data corresponding to the first test case template of the second state node, where the test data generation model is trained based on a generative large model based on a test corpus in a specific domain, and the first constraint condition data indicates data for describing the constraint conditions of the input data and output data of the function point; and obtaining the first quantity of test cases corresponding to the second state node based on the first test case template of the second state node and the first test data corresponding to the first test case template of the second state node.

[0054] In this embodiment, constructing a first test case template for the second state node corresponding to the function point according to the second state diagram and the first function description data ensures the logical coupling of the first test cases of each second state node; and generating first test data corresponding to the first test case template according to the second state diagram and the first constraint condition data, and the first test case is composed of the first test case template and the first test data, meeting the convenience of the combination of the first test data and the first test case template of the second state node in different application scenarios.

[0055] In some embodiments, the first test case template at least includes a case index, a case title, preconditions, postconditions, a test path, and an expected result; the case index is used to uniquely identify the first test case.

[0056] In some embodiments, the preconditions indicate the prerequisite conditions for triggering the first test case, and the postconditions indicate the effects that will occur after the first test case is executed.

[0057] In some embodiments, the test path indicates a series of jump paths of the test case for completing the test requirements corresponding to the second state node with respect to the second state node, and the jump path can be a simple straight-line path, a conditional branch path, or a loop path; the expected result indicates the result expected to be generated after the first test case is executed.

[0058] In some embodiments, obtaining the first quantity of test cases corresponding to at least one second state node corresponding to the first state node based on the node index corresponding to the first state node and the second state diagram includes: constructing the first quantity of test cases corresponding to each second state node among the at least one second state node.

[0059] In some embodiments, obtaining the first quantity of test cases corresponding to at least one second state node corresponding to the first state node based on the node index corresponding to the first state node and the second state diagram includes: obtaining the second requirement priority of the second state node based on the product requirement data; constructing the first quantity of test cases corresponding to the second state nodes that meet the second requirement priority threshold among the at least one second state node based on the second requirement priority and system resources.

[0060] In some embodiments, obtaining the first test data corresponding to the first test case template corresponding to the second state node by using a test data generation model based on the second state diagram includes obtaining at least one of the following data: normal path test data, abnormal path test data, and boundary path test data.

[0061] In this embodiment, the robustness of the first test data is improved by normal path test data, abnormal path test data, and boundary condition test data.

[0062] In some embodiments, the normal path test data indicates data for verifying the jump logic between function modules or function points when the product function is normal.

[0063] In some embodiments, the abnormal path test data indicates data for testing the response ability of the product under abnormal conditions; the abnormal conditions include one of the following: illegal input, unexpected operation, and system error; the illegal input includes, but is not limited to, inputting special characters, undefined symbols, and null values.

[0064] The above description of the abnormal path test data is not a restrictive description, but only an exemplary description, and the specific type of data is adjusted according to the actual product requirements or product application scenarios.

[0065] In some embodiments, the boundary path test data indicates data for testing the processing ability of the product under boundary conditions; the boundary path test data includes the maximum value, minimum value, or critical value of the input data corresponding to the input constraint rule of the function point.

[0066] Figure 4 is a flowchart showing a first test case set generation method 400 according to an embodiment of the present disclosure, as Figure 4As shown, in some embodiments, the first test case set corresponding to the test requirement data obtained from the first test case based on the first state diagram and at least one of the multiple functional modules includes: Step S402, for the first state node corresponding to at least one of the multiple functional modules, based on the first state diagram and the second functional description data of the functional module corresponding to this first state node, construct the second test case template for this first state node; based on the first state diagram and the second constraint condition data of the functional module corresponding to this first state node, use the test data generation model to obtain the second test data for the second test case template corresponding to this first state node, where the second constraint condition data indicates the data describing the constraint conditions of the input data and output data of the functional module; based on the second test case template of this first state node and the second test data for the second test case template corresponding to this first state node, obtain the first test case for this first state node; and Step S404, based on the first test cases of the first state nodes corresponding to at least one of the multiple functional modules, obtain the first test case set corresponding to the test requirement data.

[0067] In this embodiment, according to the first state diagram and the second functional description data, construct the second test case template for the first state node corresponding to the functional module, ensuring the logical coupling of the second test cases of each first state node; and according to the first state diagram and the second constraint condition data, generate the second test data corresponding to the second test case template, and the second test case is composed of the second test case template and the second test data, meeting the convenience of the combination of the second test data and the second test case template of the first state node in different application scenarios.

[0068] In some embodiments, the method further includes: obtaining the coverage rate of the first test case set based on the historical test results of the first test case set; and in response to determining that the coverage rate does not meet the set coverage rate threshold, updating the first test case set until the coverage rate meets the coverage rate threshold.

[0069] In this embodiment, in response to the coverage rate of the test case set not meeting the set coverage rate threshold, by updating the test case set, further improve the coverage rate of the test case.

[0070] In some embodiments, the coverage rate of the first test case set can be obtained through the API call situation of the test path corresponding to the first test case, and can also be obtained through other data that can indicate the execution situation of the test path of the first test case of the second state node.

[0071] In some embodiments, the coverage threshold is set according to the industry or scenario of product application. For example, for products with high security requirements, the coverage threshold can be set to 95%; for the testing of critical services, the coverage threshold can be set to 100%; and for products in the same application scenario, the setting of the coverage threshold can also be dynamically adjusted according to the test results. The above settings of the coverage threshold are only exemplary and not restrictive descriptions.

[0072] Figure 5 is a flowchart showing a method 500 for updating the first test case set according to an embodiment of the present disclosure, as Figure 5 shown, the updating of the first test case set includes: step S502, obtaining at least one uncovered test path based on the historical test results and the second state diagram; step S504, for the at least one uncovered test path, obtaining the data characteristics of the first test data of the second state node corresponding to the test path; mutating the first test data based on the data characteristics to obtain the second test data of the second state node corresponding to the test path; and step S506, using the second test data as the first test data of the second state node corresponding to the test path.

[0073] In this embodiment, the first test data of the function points corresponding to the uncovered test paths is mutated according to the data characteristics, improving the efficiency of optimizing the test case coverage.

[0074] In some embodiments, the data characteristics of the first test data include at least one of the following characteristics: the data type of the first test data, the numerical range of the first test data, the associated data associated with the first test data, and the semantic logic of the first test data corresponding to the product requirement document.

[0075] In some embodiments, the mutating of the first test data includes mutating the first test data according to at least one of the following methods: expanding the numerical range of the first test data, changing the data type of the first test data, performing cross-combination on the test fields corresponding to the first test data, and changing the semantic logic corresponding to the first test data.

[0076] In this embodiment, according to the data characteristics of the first test data, the robustness of the first test case is improved by various first test data mutation methods.

[0077] In some embodiments, when cross - combining and indicating the test fields corresponding to the first test data to test multiple variable data, not only is a certain variable data itself mutated, but the first test data corresponding to multiple variable data is cross - combined and mutated to test the dependency relationship of multiple variable data.

[0078] In some embodiments, changing the semantic logic corresponding to the first test data includes: identifying the context corresponding to the first test data in the product requirement document; obtaining the relevant fields of the first test data according to the context; mutating the data corresponding to the relevant fields; wherein, the data corresponding to the relevant fields can be the first test data of the first test case or the auxiliary data for completing the first test case; the method of mutating the data corresponding to the relevant fields can refer to the method of mutating the first test data, which will not be elaborated here.

[0079] In some embodiments, the method includes: for at least one uncovered test path, using a fuzz testing mechanism to generate third test data for the second state node corresponding to the test path, wherein the third test data is randomly generated data; and using the third test data as the first test data for the second state node corresponding to the test path.

[0080] In this embodiment, by using a fuzz testing mechanism to generate random test data as the first test data of the first test case, the range of the first test data is effectively increased, thereby further improving the coverage rate of the first test case.

[0081] In some embodiments, the fuzz testing mechanism discovers vulnerabilities in product functions by providing unexpected data that has no logical relationship with the data characteristics of the first test data and monitoring abnormal results.

[0082] In some embodiments, the method further includes: based on the historical test results, determining whether there are test cases that do not meet the test expected results; and in response to determining that there is at least one test case that does not meet the test expected results, marking the at least one test case that does not meet the test expected results as the priority test case for the corresponding second state node.

[0083] In this embodiment, the first test case template of the second state node further includes a test case priority identifier. By increasing the priority of the test cases that do not meet the expected results, the adaptability of the test case set is effectively improved.

[0084] In some embodiments, the method further includes: in response to determining that there is at least one test case that does not meet the expected test result, for the at least one test case that does not meet the expected test result, obtaining the number of times the test case is called; and based on the number of times called, marking the priority of the test case.

[0085] In this embodiment, for the test case that does not meet the expected test result, the priority of the test case is adjusted according to the number of times called, and the scheduling of the test case is guided according to the priority, further improving the adaptability of the test case set.

[0086] In some embodiments, the method further includes performing at least one of the following operations on the first test case set: modifying the test cases in the first test case set and supplementing the test cases in the first test case set.

[0087] In this embodiment, by modifying and / or supplementing the automatically generated first test case set, the adaptability of the test case set is further improved.

[0088] In some embodiments, the generated first test case set can also be converted into a specific format that meets the user's needs to improve the adaptability of the method, such as an Excel file that is convenient for sharing and archiving, an automated script format that supports PyTest, an SQL file that supports database unit testing, and other file formats that meet the user's needs.

[0089] Figure 6 FIG. is a block diagram showing a test case generation device 600 based on artificial intelligence according to an embodiment of the present disclosure. The following will be combined with Figure 6 , and the test case generation device 600 based on artificial intelligence will be described in detail. The test case generation device based on artificial intelligence includes: a test requirement data acquisition module 602, configured to obtain test requirement data related to the functions of the product under test, where the functions of the product under test include multiple function modules, the function modules include at least one function point, and the function point corresponds to the smallest execution unit for completing a specific function; a state diagram generation module 604, configured to obtain a first state diagram and a second state diagram based on the test requirement data by using a large language model, where the first state diagram includes multiple first state nodes, the first state nodes correspond to a corresponding function module among the multiple function modules, the second state diagram includes multiple second state nodes, the second state nodes correspond to a corresponding function point of the functions of the product under test, and the node information of the first state node includes the node indexes of one or more second state nodes corresponding to the first state node; and a test case set generation module 606, configured to obtain a first test case set corresponding to the test requirement data based on the first state diagram and the second state diagram.

[0090] It should be noted that Figure 6 each module of the device 600 shown in Figure 2 corresponds to each step of the method 200 described with reference to

[0091] According to an embodiment of the present disclosure, an electronic device, a readable storage medium, and a computer program product are also provided.

[0092] With reference to Figure 7 , the structural block diagram of the electronic device 700 that can be used as a server or a client of the present disclosure will now be described. It is an example of a hardware device that can be applied to various aspects of the present disclosure. The electronic device is intended to represent various forms of digital electronic computer devices, such as, a laptop computer, a desktop computer, a workbench, a personal digital assistant, a server, a blade server, a mainframe computer, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as, a personal digital processor, a cellular phone, a smart phone, a wearable device, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0093] As Figure 7 shown, the electronic device 700 includes a computing unit 701, which can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 702 or the computer program loaded from the storage unit 708 into the random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the electronic device 700 can also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other through a bus 704. The input / output (I / O) interface 705 is also connected to the bus 704.

[0094] Multiple components in the electronic device 700 are connected to the I / O interface 705, including: an input unit 706, an output unit 707, a storage unit 708, and a communication unit 709. The input unit 706 can be any type of device capable of inputting information into the electronic device 700. The input unit 706 can receive input digital or character information and generate key signal inputs related to the user settings and / or function controls of the electronic device, and can include, but is not limited to, a mouse, a keyboard, a touch screen, a track pad, a track ball, a joystick, a microphone, and / or a remote control. The output unit 707 can be any type of device capable of presenting information, and can include, but is not limited to, a display, a speaker, a video / audio output terminal, a vibrator, and / or a printer. The storage unit 708 can include, but is not limited to, magnetic disks and optical discs. The communication unit 709 allows the electronic device 700 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks, and can include, but is not limited to, a modem, a network card, an infrared communication device, a wireless communication transceiver, and / or a chip set, such as a Bluetooth device, an 802.11 device, a WiFi device, a WiMax device, a cellular communication device, and / or the like.

[0095] The computing unit 701 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 701 executes the various methods and processes described above, such as method 200. For example, in some embodiments, method 200 can be implemented as a computer software program tangibly embodied in a machine-readable medium, such as the storage unit 708. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 700 via the ROM 702 and / or the communication unit 709. When the computer program is loaded into the RAM 703 and executed by the computing unit 701, one or more steps of the method 200 described above can be executed. Alternatively, in other embodiments, the computing unit 701 can be configured to execute method 200 in any other suitable manner (e.g., by means of firmware).

[0096] The various embodiments of the systems and techniques described above in this specification can be implemented in digital electronic circuitry, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems-on-chip (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: being implemented in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which may be a special-purpose or general-purpose programmable processor that receives data and instructions from, and transmits data and instructions to, a storage system, at least one input device, and at least one output device.

[0097] The program code for implementing the methods of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the program codes, when executed by the processor or controller, cause the functions / operations specified in the flowchart and / or block diagram to be implemented. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine or entirely on the remote machine or server.

[0098] In the context of the present disclosure, a machine-readable medium may be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0099] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and a pointing device (e.g., a mouse or a trackball), by which the user can provide input to the computer. Other kinds of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and the input received from the user can be in any form (including acoustic input, voice input, or tactile input).

[0100] The systems and techniques described herein can be implemented in a computing system including backend components (e.g., as a data server), or a computing system including middleware components (e.g., an application server), or a computing system including frontend components (e.g., a user computer having a graphical user interface or a web browser through which the user can interact with an implementation of the systems and techniques described herein), or a computing system including any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected to each other by digital data communication in any form or medium (e.g., a communication network). Examples of communication networks include: local area network (LAN), wide area network (WAN), the Internet, and blockchain networks.

[0101] A computer system can include a client and a server. The client and the server are generally far from each other and usually interact through a communication network. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, or a server of a distributed system, or a server incorporating blockchain.

[0102] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps recited in this disclosure can be executed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and no limitation is made herein.

[0103] Although embodiments or examples of the present disclosure have been described with reference to the accompanying drawings, it should be understood that the above methods, systems, and devices are merely exemplary embodiments or examples, and the scope of the present invention is not limited by these embodiments or examples, but is only defined by the authorized claims and their equivalent scope. Various elements in the embodiments or examples may be omitted or replaced by their equivalent elements. In addition, the steps may be executed in an order different from that described in the present disclosure. Further, the various elements in the embodiments or examples may be combined in various ways. Importantly, with the evolution of technology, many of the elements described herein may be replaced by equivalent elements that emerge after the present disclosure.

Claims

1. A test case generation method based on artificial intelligence, comprising: Obtaining test requirement data related to the function of the product to be tested, wherein the function of the product to be tested includes multiple function modules, each of which includes at least one function point, and each function point corresponds to a minimum execution unit that completes a specific function; Based on the test requirement data, using a large language model, a first state diagram and a second state diagram are obtained, wherein the first state diagram includes a plurality of first state nodes, the first state node corresponds to a corresponding functional module among the plurality of functional modules, wherein the second state diagram includes a plurality of second state nodes, the second state node corresponds to a corresponding functional point of the function of the product to be tested, and the node information of the first state node includes node indexes of one or more second state nodes corresponding to the first state node; and Based on the first state diagram and the second state diagram, a first test case set corresponding to the test requirement data is obtained.

2. The test case generation method according to claim 1, wherein: The obtaining, based on the first state diagram and the second state diagram, a first test case set corresponding to the test requirement data comprises: For at least one first-state node among the plurality of first-state nodes, Based on the node index corresponding to the first state node and the second state graph, obtaining a first number of test cases corresponding to at least one second state node corresponding to the first state node; Based on the first number of test cases, obtaining a first test case for the functional module corresponding to the first state node; and Based on the first state diagram and a first test case of at least one functional module among the multiple functional modules, a first test case set corresponding to the test requirement data is obtained.

3. The test case generation method according to claim 2, wherein: The obtaining, based on the node index corresponding to the first state node and the second state graph, a first number of test cases corresponding to at least one second state node corresponding to the first state node comprises: For at least one second state node corresponding to the first state node, Based on the second state diagram and the first function description data of the function point corresponding to the second state node, construct a first test case template for the second state node, wherein the first test case template at least includes a test path and an expected test result of the second state node; Based on the second state diagram and the first constraint condition data of the function point corresponding to the second state node, using the test data generation model, obtain the first test data of the first test case template corresponding to the second state node, wherein the test data generation model is based on a test corpus in a specific field and is trained based on a generative large model, and the first constraint condition data indicates data describing the constraint conditions of the input data and output data of the function point; and Based on the first test case template of the second state node and the first test data corresponding to the first test case template of the second state node, a first number of test cases corresponding to the second state node are obtained.

4. The test case generation method according to claim 3, wherein: The method of generating a model based on the second state diagram using test data to obtain first test data of the first test case template corresponding to the second state node includes obtaining at least one of the following data: normal path test data, abnormal path test data, and boundary path test data.

5. The test case generation method according to claim 2, wherein: The obtaining of a first test case set corresponding to the test requirement data based on the first state diagram and a first test case of at least one functional module among the plurality of functional modules comprises: For a first state node corresponding to at least one functional module among the plurality of functional modules, Constructing a second test case template for the first state node based on the first state diagram and the second functional description data of the functional module corresponding to the first state node; Based on the first state diagram and second constraint condition data of the functional module corresponding to the first state node, using the test data generation model, obtain second test data of the second test case template corresponding to the first state node, wherein the second constraint condition data indicates data describing constraint conditions of input data and output data of the functional module; Obtaining a first test case for the first state node based on the second test case template for the first state node and second test data corresponding to the second test case template for the first state node; and Based on a first test case of a first state node corresponding to at least one functional module among the multiple functional modules, a first test case set corresponding to the test requirement data is obtained.

6. The test case generation method according to claim 3, wherein: The method further comprises: Based on historical test results of the first test case set, obtaining coverage of the first test case set; and In response to determining that the coverage rate does not meet a set coverage rate threshold, the first test case set is updated until the coverage rate meets the coverage rate threshold.

7. The test case generation method according to claim 6, wherein: The updating of the first test case set comprises: Based on the historical test results and the second state diagram, obtaining at least one uncovered test path; For the at least one uncovered test path, Acquire data features of first test data of a second state node corresponding to the test path; Based on the data feature, mutate the first test data to obtain second test data of a second state node corresponding to the test path; and The second test data is used as the first test data of the second state node corresponding to the test path.

8. The test case generation method according to claim 7, wherein: The mutating of the first test data includes mutating the first test data according to at least one of the following methods: expanding the numerical range of the first test data, changing the data type of the first test data, cross-combining the test fields corresponding to the first test data, and changing the semantic logic corresponding to the first test data.

9. The test case generation method according to claim 7, wherein: The method comprises: For the at least one uncovered test path, Generate third test data of the second state node corresponding to the test path by using a fuzzy test mechanism, wherein the third test data is randomly generated data; and The third test data is used as the first test data of the second state node corresponding to the test path.

10. The test case generation method according to claim 3, wherein: The method further comprises: Based on the historical test results, determining whether there are test cases that do not meet the expected test results; and In response to determining that there is at least one test case that does not satisfy the expected test result, the at least one test case that does not satisfy the expected test result is marked as a priority test case of the corresponding second state node.

11. The test case generation method according to claim 10, wherein: The method further comprises: In response to determining that there is the at least one test case that does not satisfy the expected test result, for the at least one test case that does not satisfy the expected test result: Get the number of times the test case has been called; and Based on the number of times the test case is called, the priority of the test case is marked.

12. The test case generation method according to claim 1, wherein: The method further includes performing at least one of the following operations on the first test case set: modifying the test cases in the first test case set and supplementing the test cases in the first test case set.

13. A test case generation device based on artificial intelligence, comprising: A test requirement data acquisition module, used to obtain test requirement data related to the function of the product to be tested, wherein the function of the product to be tested includes multiple function modules, and the multiple function modules include at least one function point, and the function point corresponds to the minimum execution unit that completes a specific function; a state diagram generation module, configured to obtain a first state diagram and a second state diagram based on the test requirement data and using a large language model, wherein the first state diagram includes a plurality of first state nodes, the first state node corresponds to a corresponding functional module among the plurality of functional modules, the second state diagram includes a plurality of second state nodes, the second state node corresponds to a corresponding functional point of the function of the product to be tested, and the node information of the first state node includes node indexes of one or more second state nodes corresponding to the first state node; and A test case set generation module is used to obtain a first test case set corresponding to the test requirement data based on the first state diagram and the second state diagram.

14. An electronic device, comprising: at least one processor; as well as a memory communicatively coupled to the at least one processor; in The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 12.

15. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-12.

16. A computer program product comprising a computer program, wherein: When the computer program is executed by a processor, the method according to any one of claims 1 to 12 is implemented.

Citation Information

Cited By

  • Function test method of information system based on artificial intelligence

    CN120353715A