Test case generation method and device, equipment, medium and product
Through deep learning and natural language processing technology, using big models to generate test cases, the problem that test cases in the existing technology is difficult to cover all test scenarios, and more efficient test coverage and efficiency improvement are achieved.
Patent Information
- Application Number
- CN202411981207.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-04-08
AI Technical Summary
In the prior art, test cases mainly rely on manual writing, making it difficult to cover all possible test scenarios, are inefficient and error-prone.
Through deep learning and natural language processing techniques, pre-trained large models generate test cases based on test documents, dictionary of business elements, and value ranges.
The generated test cases are more diverse and comprehensive, which can better cover business logic and exceptions, improve testing efficiency, and reduce dependence on tester capabilities.
Smart Images

Figure CN119782183A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a test case generation method, device, equipment, medium and product. Background Art
[0002] Test cases play a vital role in the software testing process. Good test case design can ensure comprehensive coverage of software functions, including normal processes, boundary conditions, and exception handling, thereby reducing the possibility of missing defects. Based on high-quality test cases, testers can carry out testing work in an orderly manner, avoid duplication of work or missing key test points, and greatly improve testing efficiency.
[0003] Currently, test cases are mainly written manually by testers, and their construction often depends on the experience and knowledge of testers. The number and types of businesses are numerous. Taking banking business as an example, the businesses that need to be tested involve various aspects such as remittance, risk control, self-service terminals, and third-party payment interface docking. The businesses that testers are familiar with are very limited, which makes it difficult for manually written test cases to cover all possible test scenarios, which is inefficient and prone to errors. Summary of the invention
[0004] The present invention provides a method, device, equipment, medium and product for generating a test case, so as to improve the test efficiency and reduce the dependence on the ability of the tester during the test process.
[0005] According to one aspect of the present invention, a method for generating a test case is provided, comprising:
[0006] Determine the business elements involved in this test based on the test documents related to the business to be tested;
[0007] Extracting a dictionary and a value range of the service element from a service element database;
[0008] Based on the test document, the dictionary and value range of the business elements, a test case for the business to be tested is generated by completing the pre-trained large model.
[0009] According to another aspect of the present invention, there is provided a test case generation device, comprising:
[0010] A determination module is used to determine the business elements involved in this test based on the test documents related to the business to be tested;
[0011] An extraction module, used to extract the dictionary and value range of the business element from the business element database;
[0012] A generation module is used to generate test cases for the business to be tested based on the test document, the dictionary and the value range of the business element by completing the pre-trained large model.
[0013] According to another aspect of the present invention, a computer program product is provided, comprising a computer program, wherein when the computer program is executed by a processor, the method for generating a test case according to any embodiment of the present invention is implemented.
[0014] According to another aspect of the present invention, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the test case generation method described in any embodiment of the present invention.
[0015] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the test case generation method described in any embodiment of the present invention when executed.
[0016] The embodiments of the present invention use deep learning and natural language processing technology to enable the large model to fully understand business requirements and design details, and the generated test cases are more diverse and comprehensive, which can better cover business logic and abnormal situations. This can solve the current problem that test cases cannot cover all business scenarios and abnormal scenarios due to differences in manual experience and skills, and improve testing efficiency.
[0017] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0019] Figure 1 is a flowchart of a method for generating a test case according to an embodiment of the present invention;
[0020] Figure 2 is a flowchart of a method for generating a test case according to another embodiment of the present invention;
[0021] Figure 3 is a structural schematic diagram of a test case generation device provided according to another embodiment of the present invention;
[0022] Figure 4 It is a schematic diagram of the structure of an electronic device implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0023] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0024] It should be noted that the terms "first", "second", etc. in the present invention are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product, or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or devices.
[0025] Figure 1 This is a flow chart of a method for generating a test case provided by an embodiment of the present invention. This embodiment can be applied to the case where test cases required for testing are generated before the service to be tested is tested. The method can be executed by a test case generation device, which can be implemented in the form of hardware and / or software, and can be configured in an electronic device with corresponding data processing capabilities. Figure 1 As shown, the method includes:
[0026] S110: Determine the business elements involved in this test according to the test documents related to the business to be tested.
[0027] S120: Extract the dictionary and value range of the service element from the service element database.
[0028] S130. Based on the test document, the dictionary and value range of the business element, generate a test case for the business to be tested by completing the pre-trained large model.
[0029] Among them, the test documents mainly include business requirements specifications and detailed design documents. Business Requirements Document (BRD) is a key document in project management, which describes the business requirements, objectives and scope of the project in detail. The main purpose of the business requirements specification is to ensure that all stakeholders have a consistent understanding of the goals and expected results of the project. Detailed Design Document (DDD) is a crucial document in software development and system engineering. It provides a comprehensive and detailed description of the system to ensure that developers and all relevant parties have a clear understanding of the structure, functions and operations of the system. The dictionary and value range of business elements refers to a set of standards defined for various business-related data items (i.e. business elements) in order to ensure data consistency and accuracy. These standard sets include the name, definition, data type and allowed value range of each business element.
[0030] Specifically, determine the test object of this test - the business to be tested, and obtain test documents related to the business to be tested, usually business requirements specifications and detailed design documents. Identify key business elements from test documents such as business requirements specifications and detailed design documents, such as business terms, system responses (error codes, normal return codes, etc.), data processing, etc., and use them as business elements involved in this test.
[0031] A business element database is pre-built, which records the dictionary information (such as type, format, constraints) and value range of each business element. After the business element database is built, it can be regularly maintained, such as adding the dictionary information and value range of a certain business element, or deleting the dictionary information and value range of a certain business element, and updating the dictionary information and value range of a certain business. After determining the business elements involved in this test, obtain the dictionary and value range of the corresponding business elements from the business element database.
[0032] The business requirement specification, detailed design and business element information (including dictionary and value range) are used as the input content of the big model, and the pre-trained big model is used to automatically generate test cases. The pre-trained big model has the ability to automatically generate reasonable test scenarios, test steps, test data and expected results according to the characteristics and value range of business elements.
[0033] The embodiments of the present invention use deep learning and natural language processing technology to enable the large model to fully understand business requirements and design details, and the generated test cases are more diverse and comprehensive, which can better cover business logic and abnormal situations. This can solve the current problem that test cases cannot cover all business scenarios and abnormal scenarios due to differences in manual experience and skills, and improve testing efficiency.
[0034] Figure 2 This is a flowchart of a method for generating a test case provided by another embodiment of the present invention. This embodiment is optimized and improved on the basis of the above embodiment. Figure 2 As shown, the method includes:
[0035] S210: Determine the business elements involved in this test according to the test documents related to the business to be tested.
[0036] S220: Extract the dictionary and value range of the service element from the service element database.
[0037] S230. Based on the test document, a framework of a test case is generated by completing a pre-trained large model.
[0038] S240: Based on the dictionary and value range of the business element, fill in the detailed information in the framework through the large model to obtain a test case.
[0039] Specifically, before generating test cases, the big model has been pre-trained with a large amount of historical data and test cases. When new business requirements specifications and design documents are input into the big model, the system will fine-tune the big model to adapt it to the specific needs of the current business. The fine-tuned big model will generate a test case framework based on the input test document, including key information such as test purpose, test scenario, and test steps. Based on the test case framework, the big model will automatically fill in detailed information such as specific test data and expected results in the framework based on the dictionary and value range of the input business elements, and output the filled test cases. By simplifying tasks and generating the framework and detailed information of test cases in batches, the difficulty of generating test cases through the big model is reduced.
[0040] Based on the above embodiment, optionally, the pre-training process of the large model is as follows:
[0041] Extract pre-trained training data from the business system's stock test case assets and business element assets;
[0042] The large model is pre-trained according to the training data.
[0043] Specifically, appropriate training data is extracted from the existing resources of the business system. These resources mainly include two aspects: one is the existing test case assets, including a large number of test cases that have been used; the other is the business element assets, which cover all business-related functional points, operating procedures and business rules. Pre-train the big model based on the sorted training data. The goal of this stage is to let the model learn the business-specific patterns and laws, and how to create effective test cases based on this knowledge. Through continuous iterative optimization, the model gradually has the ability to automatically generate high-quality test cases based on given business backgrounds or requirements. Ultimately, the fully trained model can be used to assist developers or test engineers to quickly generate new test cases, improve software testing efficiency and coverage, and ensure the quality of applications and services. By pre-training the big model in a targeted manner based on internal resources, the big model can fully learn the business-specific patterns and laws, ensuring that the test cases it generates are effective enough.
[0044] S250, verifying and optimizing the test case to obtain a target test case; and performing feedback optimization on the large model according to the test result of the target test case.
[0045] Specifically, the test cases generated by the large model are verified and optimized one by one, such as performing simple logic checks, syntax checks, or simulated executions, to verify the rationality and executability of the test cases. For each test case, if a problem is found during the verification and optimization process, the tester is prompted to make manual adjustments, and the manually adjusted test case is determined as an available target test case; if no problem is found during the verification and optimization process, it is directly determined as an available target test case. In addition, based on the test results of this batch of target test cases, the parameters and algorithms of the large model are optimized to improve the quality and efficiency of subsequent test case generation.
[0046] Based on the above embodiment, optionally, after performing feedback optimization on the large model according to the test result of the target test case, the method further includes:
[0047] Convert the target test case to a target format to obtain an output test case.
[0048] Import the output test cases into a test management tool.
[0049] Among them, test management tools are special software used to plan, organize, execute and track software testing activities. They can help the team effectively manage and optimize the entire testing process, ensure software quality, and improve work efficiency.
[0050] Specifically, according to the target format supported by the test management tool (such as text file, execl table), the available target test cases are converted to obtain output test cases. The output test cases matching the format are imported into the test management tool, and the subsequent testers use the test management tool to test the business to be tested. By converting the format of the target test cases, testers can easily import and use the generated test cases.
[0051] Based on the above embodiment, optionally, before extracting the dictionary and value range of the service element from the service element database, the method further includes:
[0052] Determine the extreme values of business elements based on historical business data;
[0053] The value range of the service element is determined according to the extreme value, and the value range is entered into a service element database.
[0054] Among them, extreme values include maximum values and minimum values.
[0055] Specifically, when constructing a business element database, the dictionary information and value range of the business elements can be manually entered one by one. However, when the number of business elements is large, the efficiency of manual entry is significantly low. For the value range of business elements, you can choose to determine it by analyzing historical business data without manual entry. Specifically: obtain historical business data from the historical database, perform statistical descriptions on the historical business data, and obtain the maximum and minimum values of each business element therein. After determining the maximum and minimum values, you can simply use them as the upper and lower limits of the value range; in order to cope with future changes, you can also set a certain buffer zone based on the maximum and minimum values, such as adding a certain proportion or a fixed value above the maximum value as a new upper limit, and reducing a certain proportion or a fixed value below the minimum value as a new lower limit, so as to obtain the upper and lower limits of the value range. By analyzing historical business data to determine the value range, reduce manual participation in the construction of the business element database and improve construction efficiency.
[0056] The embodiment of the present invention reduces the difficulty of generating test cases through a large model by simplifying tasks and generating the framework and detailed information of test cases in batches.
[0057] Figure 3 A schematic diagram of a test case generation device provided by another embodiment of the present invention. Figure 3 As shown, the device comprises:
[0058] A determination module 310 is used to determine the business elements involved in this test according to the test documents related to the business to be tested;
[0059] An extraction module 320, used to extract the dictionary and value range of the business element from the business element database;
[0060] The generation module 330 is used to generate a test case for the business to be tested based on the test document, the dictionary and the value range of the business element by completing the pre-trained large model.
[0061] The test case generation device provided in the embodiment of the present invention can execute the test case generation method provided in any embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method.
[0062] Optionally, the generating module 330 includes:
[0063] A first generating unit is used to generate a framework of a test case by completing a pre-trained large model based on the test document;
[0064] The second generating unit is used to obtain a test case by filling in detail information in the framework through the large model based on the dictionary and value range of the business element.
[0065] Optionally, the pre-training process of the large model is as follows:
[0066] Extract pre-trained training data from the business system's stock test case assets and business element assets;
[0067] The large model is pre-trained according to the training data.
[0068] Optionally, the device further comprises:
[0069] An extreme value determination module, used to determine the extreme value of a business element based on historical business data;
[0070] The value range of the service element is determined according to the extreme value, and the value range is entered into a service element database.
[0071] Optionally, the device further comprises:
[0072] A verification and optimization module, used to verify and optimize the test case to obtain a target test case;
[0073] The feedback optimization module is used to perform feedback optimization on the large model according to the test results of the target test case.
[0074] Optionally, the device further comprises:
[0075] A format conversion module, used to convert the format of the target test case to obtain an output test case in a target format;
[0076] The test case import module is used to import the output test case into the test management tool.
[0077] The test case generation device further described can also execute the test case generation method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0078] Figure 4 A schematic diagram of the structure of an electronic device 40 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) 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 invention described and / or required herein.
[0079] like Figure 4 As shown, the electronic device 40 includes at least one processor 41, and a memory connected to the at least one processor 41, such as a read-only memory (ROM) 42, a random access memory (RAM) 43, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 41 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 42 or the computer program loaded from the storage unit 48 to the random access memory (RAM) 43. In the RAM 43, various programs and data required for the operation of the electronic device 40 can also be stored. The processor 41, the ROM 42, and the RAM 43 are connected to each other through a bus 44. An input / output (I / O) interface 45 is also connected to the bus 44.
[0080] A number of components in the electronic device 40 are connected to the I / O interface 45, including: an input unit 46, such as a keyboard, a mouse, etc.; an output unit 47, such as various types of displays, speakers, etc.; a storage unit 48, such as a disk, an optical disk, etc.; and a communication unit 49, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 49 allows the electronic device 40 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0081] The processor 41 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 41 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The processor 41 executes the various methods and processes described above, such as a method for generating test cases.
[0082] In some embodiments, the test case generation method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 48. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 40 via the ROM 42 and / or the communication unit 49. When the computer program is loaded into the RAM 43 and executed by the processor 41, one or more steps of the test case generation method described above may be performed. Alternatively, in other embodiments, the processor 41 may be configured to execute the test case generation method in any other appropriate manner (e.g., by means of firmware).
[0083] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0084] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0085] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0086] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0087] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0088] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0089] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0090] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for generating a test case, characterized in that: The method comprises: Determine the business elements involved in this test based on the test documents related to the business to be tested; Extracting a dictionary and a value range of the service element from a service element database; Based on the test document, the dictionary and value range of the business elements, a test case for the business to be tested is generated by completing the pre-trained large model.
2. The method according to claim 1, characterized in that The step of generating a test case for the service to be tested by completing a pre-trained large model based on the test document, the dictionary and the value range of the service element includes: Based on the test document, a framework for generating test cases is generated by completing the pre-trained large model; Based on the dictionary and value range of the business element, the test case is obtained by filling the detailed information in the framework through the large model.
3. The method according to claim 2, characterized in that The pre-training process of the large model is as follows: Extract pre-trained training data from the business system's stock test case assets and business element assets; The large model is pre-trained according to the training data.
4. The method according to claim 1, characterized in that Before extracting the dictionary and value range of the service element from the service element database, the method further includes: Determine the extreme values of business elements based on historical business data; The value range of the service element is determined according to the extreme value, and the value range is entered into a service element database.
5. The method according to claim 1, characterized in that After generating the test case of the service to be tested based on the test document, the dictionary and the value range of the service element by completing the pre-trained large model, the method further includes: Verifying and optimizing the test case to obtain a target test case; According to the test results of the target test cases, feedback optimization is performed on the large model.
6. The method according to claim 5, characterized in that After the feedback optimization of the large model according to the test result of the target test case, the method further includes: Convert the target test case to a target format to obtain an output test case. Import the output test cases into a test management tool.
7. A test case generation device, characterized in that: The device comprises: A determination module is used to determine the business elements involved in this test based on the test documents related to the business to be tested; An extraction module, used to extract the dictionary and value range of the business element from the business element database; A generation module is used to generate test cases for the business to be tested based on the test document, the dictionary and the value range of the business element by completing the pre-trained large model.
8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the test case generation method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the test case generation method according to any one of claims 1 to 6 when executed.
10. A computer program product, characterized in that The invention comprises a computer program, which implements the test case generation method according to any one of claims 1 to 6 when being executed by a processor.
Citation Information
Cited By
Test method and device, computer equipment and computer readable storage medium
CN116049009A
Test method, device, computer equipment and computer readable storage medium
CN116049009B