A test code generation method, device and equipment and readable storage medium

By automatically generating test code, the problems of high cost, low efficiency, and missed defects in software testing are solved, achieving efficient and comprehensive defect testing.

CN115328790BActive Publication Date: 2026-05-12JINAN INSPUR DATA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
JINAN INSPUR DATA TECH CO LTD
Filing Date
2022-08-19
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

In existing technologies, software testing is costly, inefficient, and incomplete, resulting in omissions.

Method used

By obtaining summary information of target defect data, extracting keywords to generate scenario strategies, retrieving target function code from the function code database, automatically generating test code, and storing it in the scenario code database.

Benefits of technology

It reduced the test error rate, lowered costs, improved test efficiency, and enhanced the comprehensiveness of defect testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115328790B_ABST
    Figure CN115328790B_ABST
Patent Text Reader

Abstract

The application discloses a kind of test code generation methods, the method comprises the following steps: obtaining newly entered target defect data;Read the abstract information of target defect data;Extract each keyword of abstract information;According to each keyword, generate target scene strategy;According to target scene strategy, each target function code is called from function code database;According to each target function code, generate target test code, and store target test code to scene code database.The test code generation method provided in the application greatly reduces the error rate, reduces the test cost, improves the test efficiency, improves the comprehensiveness of defect test.The application also discloses a kind of test code generation device, equipment and storage medium, with corresponding technical effects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of software testing technology, and in particular to a test code generation method, apparatus, device, and computer-readable storage medium. Background Technology

[0002] As software systems become increasingly complex, software testing can no longer rely solely on manual testing, as manual testing consumes a significant amount of time. Therefore, it is essential to move towards automated testing.

[0003] Although automated testing has been introduced into current testing practices, it typically involves writing test code for individual modules. This is because some defects require interaction between modules or multiple functions within a single module to occur. This necessitates testers writing scenario test cases for multiple modules or functions. Therefore, while automated code for individual modules exists, once the defect to be tested is transformed into a test scenario, the corresponding scenario code still needs to be written manually by testers. This is error-prone, costly, and inefficient, resulting in some defects going undetected and being missed.

[0004] In summary, how to effectively solve the problems of high testing costs, low testing efficiency, incomplete defect detection, and omissions is an urgent issue that needs to be addressed by those skilled in the art. Summary of the Invention

[0005] The purpose of this invention is to provide a test code generation method that significantly reduces the error rate, lowers testing costs, improves testing efficiency, and enhances the comprehensiveness of defect testing. Another purpose of this invention is to provide a test code generation apparatus, device, and computer-readable storage medium.

[0006] To solve the above-mentioned technical problems, the present invention provides the following technical solution:

[0007] A test code generation method, comprising:

[0008] Acquire newly entered target defect data;

[0009] Read the summary information of the target defect data;

[0010] Extract the keywords from the summary information;

[0011] Generate target scenario strategies based on the keywords described;

[0012] Retrieve the target function codes from the function code database according to the target scenario strategy;

[0013] Target test code is generated based on each of the target function codes, and the target test code is stored in the scene code database.

[0014] In one specific embodiment of the present invention, retrieving target function codes from the function code database according to the target scenario strategy includes:

[0015] Find the method names of each functional file corresponding to the target scenario strategy from the mapping table;

[0016] Retrieve the target function code corresponding to each function file method name from the function code database.

[0017] In one specific embodiment of the present invention, acquiring newly entered target defect data includes:

[0018] The target defect data for newly entered defect management system is obtained through the preset first API interface.

[0019] In one specific embodiment of the present invention, it further includes:

[0020] By using a preset association algorithm, the error-prone scenario strategies among the existing defects in the defect management system are learned, and new scenario strategies are generated.

[0021] According to the new scenario strategy, retrieve each new function code from the function code database;

[0022] New test code is generated based on the newly added function code, and the new test code is stored in the scene code database.

[0023] In one specific embodiment of the present invention, a preset association algorithm is used to learn error-prone scenario strategies for the interrelationships between existing defects in the defect management system, including:

[0024] The Jaccard_index association algorithm is used to learn error-prone scenario strategies for the interrelationship between existing defects in the defect management system.

[0025] In one specific embodiment of the present invention, a preset association algorithm is used to learn error-prone scenario strategies for the interrelationships between existing defects in the defect management system, including:

[0026] The Apriori association algorithm is used to learn error-prone scenario strategies for the interrelationships between existing defects in the defect management system.

[0027] In one specific embodiment of the present invention, retrieving target function codes from the function code database according to the target scenario strategy includes:

[0028] The target function codes are retrieved from the function code database according to the target scenario strategy through a preset second API interface.

[0029] A test code generation device, comprising:

[0030] The defect data acquisition module is used to acquire newly entered target defect data;

[0031] The summary information reading module is used to read the summary information of the target defect data;

[0032] The keyword extraction module is used to extract the keywords from the summary information;

[0033] The target scenario strategy generation module is used to generate target scenario strategies based on the keywords mentioned above.

[0034] The target function code retrieval module is used to retrieve each target function code from the function code database according to the target scenario strategy.

[0035] The target test code generation module is used to generate target test code based on each of the target function codes and store the target test code in the scenario code database.

[0036] A test code generation device, comprising:

[0037] Memory, used to store computer programs;

[0038] A processor for implementing the steps of the test code generation method as described above when executing the computer program.

[0039] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the test code generation method described above.

[0040] The test code generation method provided by this invention obtains newly entered target defect data; reads the summary information of the target defect data; extracts each keyword from the summary information; generates a target scenario strategy based on each keyword; retrieves each target function code from the function code database based on the target scenario strategy; generates target test code based on each target function code; and stores the target test code in the scenario code database.

[0041] As described above, the technical solution involves reading the summary information of newly entered target defect data, extracting keywords from the summary information, and automatically generating target scenario strategies based on these keywords. A pre-set function code database stores the function codes corresponding to each function to be tested. Based on the target scenario strategy, the system retrieves the target function codes from the function code database, generates target test codes, and stores the target test codes in the scenario code database. Compared to manually writing scenario codes, this invention significantly reduces the error rate, lowers testing costs, improves testing efficiency, and enhances the comprehensiveness of defect testing.

[0042] Accordingly, the present invention also provides a test code generation apparatus, device, and computer-readable storage medium corresponding to the above-described test code generation method, which have the aforementioned technical effects, and will not be elaborated further here. Attached Figure Description

[0043] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0044] Figure 1 This is a flowchart illustrating one implementation of the test code generation method in this invention.

[0045] Figure 2 This is a flowchart illustrating another implementation of the test code generation method in this invention.

[0046] Figure 3 This is a structural block diagram of a test code generation device according to an embodiment of the present invention;

[0047] Figure 4 This is a structural block diagram of a test code generation device according to an embodiment of the present invention;

[0048] Figure 5 This is a schematic diagram of the specific structure of a test code generation device provided in this embodiment. Detailed Implementation

[0049] To enable those skilled in the art to better understand the present invention, the invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are merely some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0050] See Figure 1 , Figure 1 This is a flowchart illustrating one implementation of the test code generation method in this invention. The method may include the following steps:

[0051] S101: Obtain newly entered target defect data.

[0052] The system is pre-configured to monitor the defect management system. When newly entered target defect data is detected, the newly entered target defect data is retrieved.

[0053] The target defect data can be descriptive data for any task to be tested. It can involve testing a single functional module, such as creating a cloud host for the computing module. In this case, only the computing (nova) module is involved. It can also involve testing multiple functional modules, such as creating a cloud host and then cloning the storage hard drive. In this case, both the computing (nova) module and the storage (cinder) module are involved.

[0054] S102: Read the summary information of the target defect data.

[0055] After acquiring newly entered target defect data, since the target defect data may contain relatively a lot of information, the summary information of the target defect data is read. For example, when the target defect data is about creating a cloud host using a computing module on a specific physical machine, the summary information can be expressed as "the computing module created the cloud host".

[0056] S103: Extract keywords from the abstract information.

[0057] The summary information is a concise and complete description of the current test task, containing keywords related to the function under test. After reading the summary information of the target defect data, the keywords in the summary information are extracted.

[0058] Continuing with the example above, when the summary information of the target defect data read is "the computing module creates a cloud host", keyword extraction can be performed to extract three keywords: computing module, create, and cloud host.

[0059] S104: Generate target scenario strategy based on each keyword.

[0060] After extracting the keywords from the summary information, a target scenario strategy is generated based on each keyword. For example, if a scenario is needed where a cloud server is created, a cloud disk is mounted, and then the cloud server is migrated online and hot-scaled, this scenario is considered a strategy. Some common and easily conceived test scenarios can be pre-entered into the automated code strategy module. Keywords in Chinese can be converted into terms recognizable by the automated test code generation system. For instance, when the extracted keywords include "computing module," "create," and "cloud server," "computing module" corresponds to "nova," "cloud server" to "vm," and "create operation" to "build," thus obtaining a target scenario strategy recognizable by the automated test code generation system.

[0061] S105: Retrieve the target function codes from the function code database according to the target scenario strategy.

[0062] A pre-created functional code database is used to pre-enter automated test code for individual functional modules, such as the code for the compute (nova) module, storage (cinder) module, and network (neutron) module. The functions within a single module are not coupled. The functional code database stores the functional code corresponding to each function to be tested. For example, the functional code for the compute module includes the code for creating a cloud host, mounting a cloud disk on a cloud host, unmounting a cloud disk from a cloud host, online migration, and online expansion. The target scenario strategy contains the functional codes to be tested for the current test scenario. After generating the target scenario strategy based on keywords, the target functional codes are retrieved from the functional code database according to the target scenario strategy.

[0063] In one specific embodiment of the present invention, step S105 may include the following steps:

[0064] The system retrieves the target function codes from the function code database based on the target scenario strategy through a pre-defined second API interface.

[0065] A second API (Application Programming Interface) is pre-configured for accessing the function code database. After generating target scenario strategies based on each keyword, the target function codes are retrieved from the function code database through the pre-configured second API according to the target scenario strategies.

[0066] Application Programming Interfaces (APIs) are predefined functions designed to provide applications and developers with the ability to access a set of routines based on certain software or hardware, without needing to access the source code or understand the details of the internal workings.

[0067] S106: Generate target test code based on each target function code, and store the target test code in the scenario code database.

[0068] After retrieving the target function codes from the function code database according to the target scenario strategy, target test codes are generated based on these target function codes and stored in the scenario code database. In other words, the target function codes are combined into scenario test case codes, which are then stored in the scenario code database, thus achieving automatic generation of scenario codes. Compared to manually writing scenario codes, this embodiment of the invention can automatically obtain summaries from defect data, automatically extract keywords from the summaries, automatically generate target scenario strategies based on the extracted keywords, retrieve the target function codes from the function code database according to the target scenario strategy, and combine the target function codes into scenario test case codes. This significantly reduces the error rate, lowers testing costs, improves testing efficiency, and enhances the comprehensiveness of defect testing.

[0069] As described above, the technical solution involves reading the summary information of newly entered target defect data, extracting keywords from the summary information, and automatically generating target scenario strategies based on these keywords. A pre-set function code database stores the function codes corresponding to each function to be tested. Based on the target scenario strategy, the system retrieves the target function codes from the function code database, generates target test codes, and stores the target test codes in the scenario code database. Compared to manually writing scenario codes, this invention significantly reduces the error rate, lowers testing costs, improves testing efficiency, and enhances the comprehensiveness of defect testing.

[0070] It should be noted that, based on the above embodiments, the present invention also provides corresponding improvements. In subsequent embodiments, steps identical or corresponding to those in the above embodiments can be referenced interchangeably, and their respective beneficial effects can also be referred to each other. These improvements will not be elaborated upon in the following improved embodiments.

[0071] See Figure 2 , Figure 2 This is a flowchart illustrating another implementation of the test code generation method in this invention. The method may include the following steps:

[0072] S201: Obtain newly entered target defect data.

[0073] In one specific embodiment of the present invention, step S201 may include the following steps:

[0074] The target defect data for newly entered defect management system is obtained through the preset first API interface.

[0075] A first API interface is pre-configured for access to the defect management system. When newly entered target defect data is detected, the newly entered target defect data is obtained through the pre-configured first API interface.

[0076] It should be noted that the terms "first" and "second" in "first API interface" and "second API interface" are only used to distinguish between the API interface for accessing the defect management system and the API interface for accessing the functional code database; there is no order between the two.

[0077] S202: Read the summary information of the target defect data.

[0078] S203: Extract keywords from the abstract information.

[0079] S204: Generate target scenario strategy based on each keyword.

[0080] S205: Find the method names of each functional file corresponding to the target scenario strategy from the mapping table.

[0081] The code for each function to be tested is pre-defined and placed in a separate file, with each file labeled with the function file method name. A mapping table is also pre-defined to store the correspondence between each scenario strategy and each function file method name; for example, comparing the build operation with the method name of a single function file. After generating the target scenario strategy based on each keyword, the corresponding function file method name is looked up from the mapping table.

[0082] S206: Retrieve the target function code corresponding to the method name of each function file from the function code database.

[0083] The function code database pre-sets a mapping between function file method names and function codes. After finding the function file method names corresponding to the target scenario strategy in the mapping table, the target function codes corresponding to each function file method name are retrieved from the function code database. By pre-setting the mapping between function file method names and scenario strategies and function codes, and using the function file method names as an intermediary, the accurate and orderly acquisition of target function codes is achieved.

[0084] A mapping table can be pre-set in the automated code strategy module. For example, it can list the mappings between module names and their English equivalents, resource names and their English equivalents, and operation names and their English equivalents. For instance, the compute module corresponds to "nova," the cloud host to "vm," and the create operation to "build." Keywords are read from the defect description, such as "compute module creates cloud host." Then, based on the mapping table, compute is converted to nova, cloud host to vm, and create to build. This strategy only involves one module. Then, the second API interface calls the function code database, reading only the nova module. Based on the file for creating the cloud host in the function code database (by comparing the operation "build" with the method name of a single function file to find the corresponding file and obtain the code), the corresponding code is retrieved and passed to the scenario code database.

[0085] S207: Generate target test code based on each target function code, and store the target test code in the scenario code database.

[0086] In one specific embodiment of the present invention, the method may further include the following steps:

[0087] Step 1: Learn the error-prone scenario strategies among the existing defects in the defect management system through a preset association algorithm, and generate new scenario strategies.

[0088] Step 2: Retrieve the code for each new function from the function code database according to the new scenario strategy;

[0089] Step 3: Generate new test code based on the code for each new function, and store the new test code in the scene code database.

[0090] For ease of description, the three steps above can be combined for explanation.

[0091] While accumulating strategies, it also provides a self-learning function. Based on the scenarios of defects in the defect management system, it learns and generates strategies for error-prone scenarios in the interrelationships between functional modules in the defect management system through an association algorithm. The generated strategies then call the functional code database through a second API interface to generate scenario codes and save them to the scenario code database. By learning the error-prone scenario strategies in the existing defect management system through a preset association algorithm, it generates new scenario strategies. Based on the new scenario strategies, it retrieves the new functional codes from the functional code database, generates new test codes, and stores the new test codes in the scenario code database. This supplements defect testing and further improves the comprehensiveness of defect testing.

[0092] In one specific embodiment of the present invention, learning error-prone scenario strategies for the interrelationships between existing defects in the defect management system through a preset association algorithm may include the following steps:

[0093] The Jaccard_index association algorithm is used to learn error-prone scenario strategies for inter-defect relationships in the defect management system.

[0094] The Jaccard_index association algorithm is pre-configured to learn error-prone scenario strategies for inter-defect relationships within the defect management system. This algorithm is then used to learn these error-prone scenario strategies.

[0095] The Jaccard index is an association algorithm used to compare the similarity and differences between finite sample sets. Comparing whether two sets are similar is equivalent to comparing the proportion of elements they share. Because sets are distinct, any two elements in a set are different objects. Any element in set A has only two states in set B: existence or non-existence (or, in other words, whether its value is equal; if equal, it exists). However, it cannot measure the magnitude of the difference; it only provides the result of "whether they are the same." Therefore, the Jaccard index only concerns whether the shared features between individuals are consistent. Thus, the Jaccard index can be used to calculate the similarity of asymmetric binary attribute objects.

[0096] In one specific embodiment of the present invention, learning error-prone scenario strategies for the interrelationships between existing defects in the defect management system through a preset association algorithm may include the following steps:

[0097] The Apriori association algorithm is used to learn error-prone scenarios and strategies for interrelationships among existing defects in the defect management system.

[0098] An Apriori association algorithm is pre-set to learn error-prone scenario strategies for the interrelationships between existing defects in the defect management system. The Apriori association algorithm is then used to learn these error-prone scenario strategies for the interrelationships between existing defects in the defect management system.

[0099] The Apriori association algorithm is a frequent itemset mining algorithm that mines association rules. Its core idea is to mine frequent itemsets through two stages: candidate set generation and downward closure detection of scenarios. The Apriori algorithm has wide applications, including consumer market price analysis to predict customer spending habits; intrusion detection technology in network security; university management, where the mined rules can effectively assist school management in targeted poverty alleviation efforts; and mobile communications, guiding operators' business operations and assisting service providers in decision-making.

[0100] Corresponding to the above method embodiments, the present invention also provides a test code generation apparatus, and the test code generation apparatus described below can be referred to in correspondence with the test code generation method described above.

[0101] See Figure 3 , Figure 3 This is a structural block diagram of a test code generation device according to an embodiment of the present invention. The device may include:

[0102] Defect data acquisition module 31 is used to acquire newly entered target defect data;

[0103] Summary information reading module 32 is used to read summary information of target defect data;

[0104] Keyword extraction module 33 is used to extract keywords from the abstract information;

[0105] The target scenario strategy generation module 34 is used to generate target scenario strategies based on each keyword.

[0106] The target function code retrieval module 35 is used to retrieve each target function code from the function code database according to the target scenario strategy.

[0107] The target test code generation module 36 is used to generate target test code based on the target function code and store the target test code in the scenario code database.

[0108] As described above, the technical solution involves reading the summary information of newly entered target defect data, extracting keywords from the summary information, and automatically generating target scenario strategies based on these keywords. A pre-set function code database stores the function codes corresponding to each function to be tested. Based on the target scenario strategy, the system retrieves the target function codes from the function code database, generates target test codes, and stores the target test codes in the scenario code database. Compared to manually writing scenario codes, this invention significantly reduces the error rate, lowers testing costs, improves testing efficiency, and enhances the comprehensiveness of defect testing.

[0109] In one specific embodiment of the present invention, the target function code retrieval module 35 may include:

[0110] The File Method Name Lookup Submodule is used to look up the file method names of each function corresponding to the target scenario strategy from the mapping table.

[0111] The function code retrieval submodule is used to retrieve the target function code corresponding to the method name of each function file from the function code database.

[0112] In one specific embodiment of the present invention, the defect data acquisition module 31 is specifically a module that acquires the target defect data newly entered into the defect management system through a preset first API interface.

[0113] In one specific embodiment of the present invention, the device may further include:

[0114] A new scenario strategy generation module has been added, which is used to learn the error-prone scenario strategies among the existing defects in the defect management system through a preset correlation algorithm, and generate new scenario strategies.

[0115] The new feature code retrieval module is used to retrieve the new feature codes from the feature code database according to the new scenario strategy;

[0116] A new test code generation module has been added, which is used to generate new test code based on the code of each new function and store the new test code in the scenario code database.

[0117] In one specific embodiment of the present invention, the newly added scenario strategy generation module is specifically a module that learns the scenario strategies that are prone to errors in the interrelationship between existing defects in the defect management system through the Jaccard_index association algorithm.

[0118] In one specific embodiment of the present invention, the newly added scenario strategy generation module is specifically a module that learns the scenario strategies that are prone to errors due to the mutual association between existing defects in the defect management system through the apriori association algorithm.

[0119] In one specific embodiment of the present invention, the target function code retrieval module 35 is specifically a module that retrieves each target function code from the function code database according to the target scenario strategy through a preset second API interface.

[0120] For the method embodiments described above, see [link to relevant documentation]. Figure 4 , Figure 4 This is a schematic diagram of the test code generation device provided by the present invention, which may include:

[0121] Memory 332 is used to store computer programs;

[0122] The processor 322 is used to implement the steps of the test code generation method in the above method embodiments when executing a computer program.

[0123] For details, please refer to Figure 5 , Figure 5 This is a schematic diagram illustrating the specific structure of a test code generation device provided in this embodiment. The test code generation device can vary significantly due to different configurations or performance. It may include a processor (central processing unit, CPU) 322 (e.g., one or more processors) and a memory 332. The memory 332 stores one or more computer application programs 342 or data 344. The memory 332 can be temporary or persistent storage. The program stored in the memory 332 may include one or more modules (not shown in the diagram), each module including a series of instruction operations on the data processing device. Furthermore, the processor 322 may be configured to communicate with the memory 332 and execute the series of instruction operations stored in the memory 332 on the test code generation device 301.

[0124] The test code generation device 301 may also include one or more power supplies 326, one or more wired or wireless network interfaces 350, one or more input / output interfaces 358, and / or one or more operating systems 341.

[0125] The steps in the test code generation method described above can be implemented by the structure of the test code generation device.

[0126] Corresponding to the above method embodiments, the present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, can perform the following steps:

[0127] Acquire newly entered target defect data; read the summary information of the target defect data; extract each keyword from the summary information; generate target scenario strategies based on each keyword; retrieve each target function code from the function code database based on the target scenario strategies; generate target test code based on each target function code, and store the target test code in the scenario code database.

[0128] The computer-readable storage medium may include various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0129] For a description of the computer-readable storage medium provided by the present invention, please refer to the above method embodiments; the present invention will not be described in detail here.

[0130] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatuses, devices, and computer-readable storage media disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to the method section.

[0131] This article uses specific examples to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the technical solutions and core ideas of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made to the present invention without departing from the principles of the present invention, and these improvements and modifications also fall within the protection scope of the claims of the present invention.

Claims

1. A test code generation method, characterized in that, include: Acquire newly entered target defect data; The target defect data is the description data of any task to be tested; Read the summary information of the target defect data; Extract the keywords from the summary information; Generate target scenario strategies based on the keywords described; The target scenario strategy includes all the functions to be tested in the current test scenario; Retrieve the target function codes from the function code database according to the target scenario strategy; Target test code is generated based on each of the target function codes, and the target test code is stored in the scenario code database; Also includes: By using a pre-defined correlation algorithm, we can learn the error-prone scenario strategies among the existing defects in the defect management system and generate new scenario strategies. According to the new scenario strategy, retrieve each new function code from the function code database; New test code is generated based on the newly added function code, and the new test code is stored in the scene code database.

2. The test code generation method according to claim 1, characterized in that, According to the target scenario strategy, retrieve each target function code from the function code database, including: Find the method names of each functional file corresponding to the target scenario strategy from the mapping table; Retrieve the target function code corresponding to each function file method name from the function code database.

3. The test code generation method according to claim 1, characterized in that, Retrieve newly entered target defect data, including: The target defect data for newly entered defect management system is obtained through the preset first API interface.

4. The test code generation method according to claim 1, characterized in that, The defect management system learns error-prone scenario strategies based on pre-defined association algorithms, including: The Jaccard_index association algorithm is used to learn error-prone scenario strategies for the interrelationship between existing defects in the defect management system.

5. The test code generation method according to claim 1, characterized in that, The defect management system learns error-prone scenario strategies based on pre-defined association algorithms, including: The Apriori association algorithm is used to learn error-prone scenario strategies for the interrelationships between existing defects in the defect management system.

6. The test code generation method according to claim 1, characterized in that, According to the target scenario strategy, retrieve each target function code from the function code database, including: The target function codes are retrieved from the function code database according to the target scenario strategy through a preset second API interface.

7. A test code generation device, characterized in that, include: The defect data acquisition module is used to acquire newly entered target defect data; The target defect data is the description data of any task to be tested; The summary information reading module is used to read the summary information of the target defect data; The keyword extraction module is used to extract the keywords from the summary information; The target scenario strategy generation module is used to generate target scenario strategies based on the keywords mentioned above. The target scenario strategy includes all the functions to be tested in the current test scenario; The target function code retrieval module is used to retrieve each target function code from the function code database according to the target scenario strategy. The target test code generation module is used to generate target test code based on each of the target function codes, and store the target test code in the scenario code database; Also includes: A new scenario strategy generation module has been added, which is used to learn the error-prone scenario strategies among the existing defects in the defect management system through a preset correlation algorithm, and generate new scenario strategies. The new feature code retrieval module is used to retrieve the new feature codes from the feature code database according to the new scenario strategy. A new test code generation module has been added, which is used to generate new test code based on the code of each new function and store the new test code in the scenario code database.

8. A test code generation device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the test code generation method as described in any one of claims 1 to 6 when executing the computer program.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the test code generation method as described in any one of claims 1 to 6.