CN-115328790-B - Test code generation method, device, equipment and readable storage medium
Abstract
The invention discloses a test code generation method which comprises the following steps of obtaining newly input target defect data, reading abstract information of the target defect data, extracting keywords of the abstract information, generating target scene strategies according to the keywords, calling target function codes from a function code database according to the target scene strategies, generating target test codes according to the target function codes, and storing the target test codes into the scene code database. By applying the test code generation method provided by the invention, the error rate is greatly reduced, the test cost is reduced, the test efficiency is improved, and the comprehensiveness of defect test is improved. The invention also discloses a test code generation device, equipment and a storage medium, which have corresponding technical effects.
Inventors
- LI YADUAN
Assignees
- 济南浪潮数据技术有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20220819
Claims (9)
- 1. A test code generation method, comprising: acquiring newly recorded target defect data which is any task description data to be tested; reading abstract information of the target defect data; Extracting each keyword of the abstract information; generating a target scene strategy according to the keywords, wherein the target scene strategy comprises functions to be tested related to the current test scene test; According to the target scene strategy, each target function code is called from a function code database; Generating target test codes according to the target function codes, and storing the target test codes into a scene code database; Further comprises: Learning scene strategies which are associated with each other among existing defects and are prone to errors in the defect management system through a preset association relation algorithm, and generating a newly added scene strategy; Calling each newly added function code from the function code database according to the newly added scene strategy; generating a new test code according to each new function code, and storing the new test code into the scene code database.
- 2. The test code generation method of claim 1, wherein retrieving each target function code from a function code database according to the target scenario policy comprises: searching the method names of the functional files corresponding to the target scene strategy from a corresponding relation mapping table; and calling the target function codes corresponding to the method names of the function files from the function code database.
- 3. The test code generation method according to claim 1, wherein acquiring the newly entered target defect data comprises: And acquiring target defect data newly input into the defect management system through a preset first API interface.
- 4. The test code generation method according to claim 1, wherein learning, by a preset association algorithm, a scene policy that is prone to error and associated with each other among existing defects in the defect management system includes: And learning scene policies which are related with each other among all existing defects and are prone to error in the defect management system through a Jaccard_index association relation algorithm.
- 5. The test code generation method according to claim 1, wherein learning, by a preset association algorithm, a scene policy that is prone to error and associated with each other among existing defects in the defect management system includes: And learning scene strategies which are related with each other among all existing defects and are easy to make mistakes in the defect management system through an apriori association relation algorithm.
- 6. The test code generation method of claim 1, wherein retrieving each target function code from a function code database according to the target scenario policy comprises: And calling each target function code from the function code database according to the target scene strategy through a preset second API interface.
- 7. A test code generation apparatus, comprising: The system comprises a defect data acquisition module, a summary information reading module, a summary information processing module and a data processing module, wherein the defect data acquisition module is used for acquiring newly recorded target defect data, and the target defect data is any task description data to be tested; The keyword extraction module is used for extracting each keyword of the abstract information; the target scene strategy generation module is used for generating a target scene strategy according to the keywords, wherein the target scene strategy comprises functions to be tested related to the current test scene test; The target function code calling module is used for calling each target function code from the function code database according to the target scene strategy; The target test code generation module is used for generating target test codes according to the target function codes and storing the target test codes into a scene code database; Further comprises: the new scene strategy generation module is used for learning scene strategies which are associated with each other and are prone to errors among all existing defects in the defect management system through a preset association relation algorithm to generate new scene strategies; The newly added function code calling module is used for calling each newly added function code from the function code database according to the newly added scene strategy; And the new test code generation module is used for generating new test codes according to the new function codes and storing the new test codes into the scene code database.
- 8. A test code generation apparatus, comprising: A memory for storing a computer program; A processor for implementing the steps of the test code generation method according to 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 has stored thereon a computer program which, when executed by a processor, implements the steps of the test code generation method according to any of claims 1 to 6.
Description
Test code generation method, device, equipment and readable storage medium Technical Field The present invention relates to the field of software testing technologies, and in particular, to a method, an apparatus, a device, and a computer readable storage medium for generating a test code. Background As software systems become more complex, software testing has not been able to be performed only manually, which consumes a significant amount of time, so automated testing must be entered. Although automated testing is currently introduced in the testing effort, only test code for a single module is written for testing. As there are drawbacks that arise from the need for interaction between modules or between multiple functions of a module. This requires the tester to write some scenario case code between multiple modules or functions. Therefore, although the automatic code of a single module exists, after the defect to be tested is converted into a test scene, the scene code corresponding to the test scene still needs to be written manually by a tester, and is easy to make mistakes, high in test cost and low in test efficiency. Resulting in some defects that are not tested and that are missing. In summary, how to effectively solve the problems of high test cost, low test efficiency, insufficient defect test, missing and the like is a urgent need of those skilled in the art at present. Disclosure of Invention The invention aims to provide a test code generation method, which greatly reduces error rate, lowers test cost, improves test efficiency and improves comprehensiveness of defect test, and the invention also aims to provide a test code generation device, equipment and a computer readable storage medium. In order to solve the technical problems, the invention provides the following technical scheme: a test code generation method, comprising: acquiring newly entered target defect data; reading abstract information of the target defect data; Extracting each keyword of the abstract information; Generating a target scene strategy according to each keyword; According to the target scene strategy, each target function code is called from a function code database; And generating target test codes according to the target function codes, and storing the target test codes into a scene code database. In one embodiment of the present invention, retrieving each target function code from a function code database according to the target scene policy includes: searching the method names of the functional files corresponding to the target scene strategy from a corresponding relation mapping table; and calling the target function codes corresponding to the method names of the function files from the function code database. In one embodiment of the present invention, obtaining newly entered target defect data includes: And acquiring target defect data newly input into the defect management system through a preset first API interface. In one embodiment of the present invention, the method further comprises: Learning scene strategies which are associated with each other among all existing defects and are prone to errors in the defect management system through a preset association relation algorithm, and generating a newly added scene strategy; Calling each newly added function code from the function code database according to the newly added scene strategy; generating a new test code according to each new function code, and storing the new test code into the scene code database. In a specific embodiment of the present invention, learning, by a preset association algorithm, a scene policy that is easy to make mistakes and related to each other among existing defects in the defect management system includes: And learning scene policies which are related with each other among all existing defects and are prone to error in the defect management system through a Jaccard_index association relation algorithm. In a specific embodiment of the present invention, learning, by a preset association algorithm, a scene policy that is easy to make mistakes and related to each other among existing defects in the defect management system includes: And learning scene strategies which are related with each other among all existing defects and are easy to make mistakes in the defect management system through an apriori association relation algorithm. In one embodiment of the present invention, retrieving each target function code from a function code database according to the target scene policy includes: And calling each target function code from the function code database according to the target scene strategy through a preset second API interface. A test code generation apparatus comprising: The defect data acquisition module is used for acquiring newly recorded target defect data; The abstract information reading module is used for reading abstract information of the target defect data; The keyword extraction module is used for extracting each