Software automatic testing method, model and equipment and storage medium
By parsing and automating the testing of software functional documents, standardized test cases are generated, solving the problem of high testing costs in existing software and achieving an efficient and low-cost testing process.
Patent Information
- Application Number
- CN202511146142.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-15
- Publication Date
- 2025-11-21
AI Technical Summary
Existing software testing methods require a significant investment of manpower, resources, and time, resulting in high testing costs.
By semantically parsing software function documents, test data and test cases are generated. A retrieval-enhanced generation engine is used for similarity matching to generate standardized test cases, automating the testing of software functions. Combined with boundary testing and programming style check, non-compliant code is located and fixed.
It has achieved automation and integration of software testing, improving testing efficiency and reducing testing costs.
Smart Images

Figure CN120994522A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of software testing technology, and more specifically, to an automated software testing method, model, device, and storage medium. Background Technology
[0002] During software development, numerous features need to be developed and tested. Software testing is a crucial step in ensuring the normal operation of software, primarily involving testing individual modules or functions to check whether their functionality meets expectations. Existing software testing methods require significant investment of manpower, resources, and time, resulting in high testing costs. Summary of the Invention
[0003] In view of this, the purpose of the present invention is to provide an automated software testing method, model, device and storage medium to solve the problem of high software testing costs in the prior art.
[0004] To achieve the above objectives, the technical solutions adopted in the embodiments of the present invention are as follows: In a first aspect, embodiments of the present invention provide an automated software testing method, comprising: Obtain the software function document corresponding to the software function, and perform semantic parsing on the software function document to obtain function type and function description information; Test data is generated based on the function description information, and corresponding test cases are retrieved from the case database according to the function type. Standardized test cases are generated using the test data and the test cases, and the software functions are tested using the standardized test cases to obtain test results.
[0005] In an optional implementation, the step of retrieving the corresponding test case from the test case database according to the function type includes: Convert the function type into the corresponding function vector; The test case vectors in the case database are matched with the function vectors by a retrieval enhancement generation engine based on similarity. Based on the similarity matching results, the target test case vector is obtained from the test case vector; The target test case vector is transformed to obtain the test case.
[0006] In an optional implementation, the step of converting the function type into a corresponding function vector includes: Identify multiple test points corresponding to the aforementioned function type; Based on each test point and its corresponding weight, the function type is converted into the function vector.
[0007] In an optional implementation, the step of generating standardized test cases using the test data and the test cases, and then testing the software function using the standardized test cases to obtain test results, includes: If there are multiple test cases, the test data and the test cases are called in a loop to generate multiple standardized test cases; Each of the standardized test cases is run sequentially to obtain preliminary test results for each standardized test case. The test results are obtained by analyzing the preliminary test results corresponding to each of the standardized test cases.
[0008] In an optional implementation, the test data includes standard test data and boundary test data, and the method further includes: If the standardized test case corresponding to the standard test data passes the test, then the boundary test data and the test case are used to generate the corresponding boundary test case; The boundary test cases are used to test the source code corresponding to the software function document to obtain the boundary test results.
[0009] In an optional implementation, the method further includes: If the standardized test cases pass the test, the source code corresponding to the software function document is converted into structured nodes by the abstract syntax tree parser. Node description information corresponding to the structured node is generated, and the structured node and the description information are input into the programming specification detection model to obtain the verification result.
[0010] In an optional implementation, the method further includes: Based on the boundary test results and the verification results, the illegal code segment in the source code can be located. Based on the violation code snippet, generate corresponding remediation suggestions.
[0011] Secondly, embodiments of the present invention provide an automated software testing model, including: The semantic parsing module is used to obtain software function documents corresponding to software functions, and to perform semantic parsing on the software function documents to obtain function type and function description information. The data generation module is used to generate test data based on the function description information and to retrieve corresponding test cases from the case database according to the function type. An automated testing module is used to generate standardized test cases using the test data and the test cases, and to test the software functions using the standardized test cases to obtain test results.
[0012] Thirdly, embodiments of the present invention provide an electronic device, including a processor and a memory, wherein the memory stores machine-executable instructions that can be executed by the processor, and the processor can execute the machine-executable instructions to implement the software automatic testing method described in the first aspect.
[0013] Fourthly, embodiments of the present invention provide a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the software automatic testing method as described in the first aspect.
[0014] The automated software testing method provided in this invention parses software function documents to obtain function types and descriptions, then generates test data based on the function descriptions, retrieves corresponding test cases from a test case database according to the function type, generates standardized test cases using the test data and test cases, and finally generates test results based on the standardized test cases. This invention achieves integrated and automated information extraction, test case generation, and testing, significantly improving software testing efficiency and reducing costs.
[0015] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0016] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 A block diagram of an electronic device provided by an embodiment of the present invention is shown; Figure 2 A flowchart illustrating an automatic software testing method provided by an embodiment of the present invention is shown. Figure 3 A flowchart illustrating a test case acquisition method provided by an embodiment of the present invention is shown; Figure 4 The diagram shows a functional module schematic of an automatic software testing model provided by an embodiment of the present invention.
[0018] Icons: 100 - Electronic device; 110 - Memory; 120 - Processor; 130 - Communication module; 400 - Software automatic testing model; 401 - Semantic parsing module; 402 - Data generation module; 403 - Automatic testing module. Detailed Implementation
[0019] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0020] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0021] It should be noted that relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0022] Please refer to Figure 1 This is a block diagram of an electronic device 100. The electronic device 100 includes a memory 110, a processor 120, and a communication module 130. The memory 110, processor 120, and communication module 130 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines.
[0023] The memory 110 is used to store programs or data. The memory 110 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.
[0024] The processor 120 is used to read / write data or programs stored in the memory 110 and to perform corresponding functions.
[0025] The communication module 130 is used to establish a communication connection between the electronic device 100 and other communication terminals through the network, and to send and receive data through the network.
[0026] It should be understood that, Figure 1 The structure shown is only a schematic diagram of the electronic device 100. The electronic device 100 may also include components that are larger than... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown. Figure 1 The components shown can be implemented using hardware, software, or a combination thereof.
[0027] Please refer to Figure 2 , Figure 2 This is a flowchart illustrating an automated software testing method provided in this embodiment. The method includes: S101. Obtain the software function document corresponding to the software function, and perform semantic parsing on the software function document to obtain the function type and function description information.
[0028] Software functional documentation is a formal record describing "what the software should do." It translates user / business requirements into functional details that the technical team can implement, and serves as a common basis for roles such as development, testing, and operations.
[0029] Software function documents are usually readable documents, such as JSON documents. Therefore, semantic parsing can be performed on software function documents using language processing models, such as common large language models, such as word segmentation and keyword extraction, to extract the function types and function type descriptions recorded in the software function documents.
[0030] For example, software function documents can be segmented into 500-word segments to avoid context overflow of long texts, and then keywords can be extracted from the segmented text based on a custom function thesaurus.
[0031] Each function type corresponds to at least one function description.
[0032] For example, for a game software that includes a lottery feature, the extracted function type would be: lottery feature. The corresponding function description for the lottery feature is: Activating a value pack supports two trigger methods: packs sold within a "specific time" period and unlocked packs obtained by reaching a "specific level".
[0033] S102. Generate test data based on the function description information, and obtain the corresponding test cases from the case database according to the function type.
[0034] For the lottery game mentioned above, the key information in its description is: a specific time or a specific level. Therefore, corresponding test data can be generated based on this key information, that is, various different times within a specific time period and various different levels within a specific level.
[0035] For example, if a specific time is the hour and a specific level is a multiple of ten, then the test data corresponding to the specific time can be one o'clock, two o'clock, three o'clock, etc., and the test data corresponding to the specific level can be level ten, level twenty, level thirty, etc.
[0036] Test cases are essentially a complete test specification, typically including: Testing objective: To verify which function or requirement of the software needs to be tested.
[0037] Prerequisites: Environment, data, role permissions, etc. before the test begins.
[0038] Input data: The data to be entered.
[0039] Operation steps: Detailed actions for interacting with the software.
[0040] Expected results: The output or status that the system should present at each step.
[0041] Actual results and judgment: Record, compare, and give a conclusion of success or failure after execution.
[0042] The case database stores historical successful test cases. Similar or related cases are selected from the case database as test cases based on the function type.
[0043] S103. Generate standardized test cases using the test data and the test cases, and test the software functions using the standardized test cases to obtain test results.
[0044] Test data and test cases are combined to generate standardized test cases. These standardized test cases are then run to test the software functionality, thereby obtaining test results.
[0045] This embodiment parses software function documents to obtain function types and descriptions, then generates test data based on the function descriptions, retrieves corresponding test cases from a case database according to the function type, generates standardized test cases using the test data and test cases, and finally generates test results based on the standardized test cases. This embodiment of the invention achieves integrated and automated information extraction, test case generation, and testing, significantly improving the efficiency and reducing the cost of software testing.
[0046] Please refer to Figure 3 Step S102 further includes: steps S1021-S1024.
[0047] S1021. Convert the function type into the corresponding function vector.
[0048] S1022. The test case vectors in the case database are matched with the function vectors by the retrieval enhancement generation engine based on similarity.
[0049] S1023. Based on the similarity matching result, obtain the target test case vector from the test case vector.
[0050] S1024. Perform data transformation on the target test case vector to obtain the test case.
[0051] A function type may correspond to multiple test points. For example, for the lottery function mentioned above, it is necessary to test the triggering logic of specific time and specific level at the same time. Therefore, a function type can be converted into a function vector based on the test points contained in a function type and the weight of each test point.
[0052] The test case database stores the test case vectors corresponding to the test cases. When building the test case database, historical successful test cases can be segmented into text blocks and vectorized to convert them into corresponding test case vectors.
[0053] After obtaining the function vectors corresponding to the function types, the Retrieval-augmented Generation (RAG) engine is used to query target test cases from the case database. RAG is a technical framework that combines information retrieval and large language model generation. Its principle is to first obtain the question information, transform the question information into a vector, retrieve the most relevant document fragments from the vector database, and then concatenate the retrieved document fragments with the question information to form enhanced hints. Based on the enhanced hints, the large oracle model generates more accurate and context-relevant answers.
[0054] Different test cases may correspond to different test points. Therefore, test cases that are similar to the test points of the software function under test can be selected from the test case database. For example, the cosine similarity between the function vector and each test case vector in the test case database can be calculated. Test case vectors with a cosine similarity greater than or equal to a preset similarity can be used as target test vectors. Then, the target test vectors can be transformed to obtain test cases.
[0055] This embodiment improves the efficiency of test case search and matching by using a search-enhanced generation engine.
[0056] In one implementation, the step of generating standardized test cases using the test data and the test cases, and testing the software function using the standardized test cases to obtain test results, includes: If there are multiple test cases, the test data and the test cases are called in a loop to generate multiple standardized test cases; Each of the standardized test cases is run sequentially to obtain preliminary test results for each standardized test case. The test results are obtained by analyzing the preliminary test results corresponding to each of the standardized test cases.
[0057] Testing with a single test case may not be able to detect all problems. Therefore, multiple test cases are usually selected for testing. Since the test data corresponding to the functional description information is fixed, the test data can be used to repeatedly fill each test case to obtain multiple test cases. Then, the software function is tested sequentially through multiple test cases. If each test case passes, it means that the software function is normal; otherwise, it means that the software function is abnormal.
[0058] This embodiment fills multiple test cases with test data to generate multiple standardized test cases, and then performs software function tests through multiple standardized test cases to obtain corresponding test results, making the testing process more comprehensive and the test results more accurate.
[0059] In one embodiment, the test data includes standard test data and boundary test data, and the method further includes: If the standardized test case corresponding to the standard test data passes the test, then the boundary test data and the test case are used to generate the corresponding boundary test case; The boundary test cases are used to test the source code corresponding to the software function document to obtain the boundary test results.
[0060] Boundary test data can be data other than standard test data. For example, if standard test data consists of multiples of ten, such as levels 10, 20, and 30, then boundary test data can be levels 7, 8, 13, etc. If the standard test data passes, corresponding boundary test cases are generated based on the boundary test data, and then the software functionality is tested using these boundary test cases.
[0061] This embodiment generates corresponding boundary test cases through boundary test data, and uses the boundary test cases to test the software functions, making the software testing more comprehensive and the test results more accurate.
[0062] In one embodiment, the method further includes: If the standardized test cases pass the test, the source code corresponding to the software function document is converted into structured nodes by the abstract syntax tree parser. Node description information corresponding to the structured node is generated, and the structured node and the description information are input into the programming specification detection model to obtain the verification result.
[0063] An Abstract Syntax Tree (AST) is an abstract representation of the syntactic structure of source code. Each node in the tree represents a structure in the source code.
[0064] In some scenarios, the code corresponding to a software function may be normal, but other code in the software may have anomalies, such as coding errors. In this case, a programming standard detection model can be used to perform a comprehensive detection and verification of the software code, and then output the corresponding verification results.
[0065] In one embodiment, the method further includes: Based on the boundary test results and the verification results, the illegal code segment in the source code can be located. Based on the violation code snippet, generate corresponding remediation suggestions.
[0066] During boundary testing and source code testing, corresponding test files, such as test logs, can be generated. These test files record test exceptions and the corresponding code. By using the test files, the abnormal code segment can be quickly located, and then corresponding repair suggestions can be generated based on information such as the type of abnormal code, thereby achieving rapid location and repair of exceptions.
[0067] To perform the corresponding steps in the above embodiments and various possible methods, an implementation method of an automated software testing model is given below. Please refer to [link / reference]. Figure 4 , Figure 4 This is a functional block diagram of an automated software testing model 400 provided in an embodiment of the present invention. It should be noted that the basic principle and technical effects of the automated software testing model 400 provided in this embodiment are the same as those in the above embodiments. For the sake of brevity, any parts not mentioned in this embodiment can be referred to the corresponding content in the above embodiments. The automated software testing model 400 includes: The semantic parsing module 401 is used to obtain the software function document corresponding to the software function, and to perform semantic parsing on the software function document to obtain function type and function description information. The data generation module 402 is used to generate test data based on the function description information and to obtain corresponding test cases from the case database according to the function type. The automatic testing module 403 is used to generate standardized test cases using the test data and the test cases, and to test the software functions using the standardized test cases to obtain test results.
[0068] Optionally, the above modules can be stored in the form of software or firmware. Figure 1 The memory shown is either stored in or embedded in the operating system (OS) of the electronic device, and can be used by... Figure 1 The processor executes the commands. Meanwhile, the data and program code required to execute these modules can be stored in memory.
[0069] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative; for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0070] In addition, the functional modules in the various embodiments of the present invention can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0071] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes 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.
[0072] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for automatic software testing, characterized in that, include: Obtain the software function document corresponding to the software function, and perform semantic parsing on the software function document to obtain function type and function description information; Test data is generated based on the function description information, and corresponding test cases are retrieved from the case database according to the function type. Standardized test cases are generated using the test data and the test cases, and the software functions are tested using the standardized test cases to obtain test results.
2. The software automatic testing method according to claim 1, characterized in that, The step of retrieving the corresponding test case from the case database according to the function type includes: Convert the function type into the corresponding function vector; The test case vectors in the case database are matched with the function vectors by a retrieval enhancement generation engine based on similarity. Based on the similarity matching results, the target test case vector is obtained from the test case vector; The target test case vector is transformed to obtain the test case.
3. The software automatic testing method according to claim 2, characterized in that, The step of converting the function type into a corresponding function vector includes: Identify multiple test points corresponding to the aforementioned function type; Based on each test point and the weight corresponding to each test point, the function type is converted into the function vector.
4. The software automatic testing method according to claim 1, characterized in that, The step of generating standardized test cases using the test data and the test cases, and testing the software function using the standardized test cases to obtain test results includes: If there are multiple test cases, the test data and the test cases are called in a loop to generate multiple standardized test cases; Each of the standardized test cases is run sequentially to obtain preliminary test results for each standardized test case. The test results are obtained by analyzing the preliminary test results corresponding to each of the standardized test cases.
5. The automatic software testing method according to claim 1, characterized in that, The test data includes standard test data and boundary test data, and the method further includes: If the standardized test case corresponding to the standard test data passes the test, then the boundary test data and the test case are used to generate the corresponding boundary test case; The boundary test cases are used to test the source code corresponding to the software function document to obtain the boundary test results.
6. The software automatic testing method according to claim 5, characterized in that, The method further includes: If the standardized test cases pass the test, the source code corresponding to the software function document is converted into structured nodes by the abstract syntax tree parser. Node description information corresponding to the structured node is generated, and the structured node and the description information are input into the programming specification detection model to obtain the verification result.
7. The software automatic testing method according to claim 5 or 6, characterized in that, The method further includes: Based on the boundary test results and the verification results, the illegal code segment in the source code can be located. Based on the violation code snippet, generate corresponding remediation suggestions.
8. An automated software testing model, characterized in that, include: The semantic parsing module is used to obtain software function documents corresponding to software functions, and to perform semantic parsing on the software function documents to obtain function type and function description information. The data generation module is used to generate test data based on the function description information and to retrieve corresponding test cases from the case database according to the function type. An automated testing module is used to generate standardized test cases using the test data and the test cases, and to test the software functions using the standardized test cases to obtain test results.
9. An electronic device, characterized in that, It includes a processor and a memory, the memory storing machine-executable instructions that can be executed by the processor, the processor executing the machine-executable instructions to implement the software automatic testing method according to any one of claims 1-7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the software automatic testing method as described in any one of claims 1-7.