Automatic software testing method and device based on artificial intelligence
Through the software automatic testing method based on artificial intelligence, test cases are automatically generated and tests are automatically executed, which solves the problem of high manual maintenance costs in the existing technology and realizes an efficient and automated software testing process.
Patent Information
- Application Number
- CN202510250627.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-04
- Publication Date
- 2025-04-15
AI Technical Summary
The existing software testing methods rely on manual selection of test methods and design cases, resulting in high maintenance costs and low efficiency, and requires frequent manual maintenance in different scenarios.
Using an artificial intelligence-based software automatic testing method, we analyze test requests through natural language processing technology, automatically generate test cases, and use an automated test framework driven by artificial intelligence to perform tests, monitor the software status in real time and provide repair suggestions.
Eliminates the tedious process of traditional manual writing and updating test scripts, improves the degree of test automation, reduces the need for manual intervention, reduces maintenance costs, and improves the efficiency, accuracy and sustainability of software testing.
Smart Images

Figure CN119829467A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of artificial intelligence, and in particular relates to an artificial intelligence-based software automatic testing method and device. Background Art
[0002] Software testing is the process of running or measuring a software system using manual or automatic means, with the aim of verifying whether it meets the specified requirements or clarifying the difference between expected results and actual results.
[0003] The usual software testing process is that after the test cases are designed and reviewed, the testers will perform the test step by step according to the procedures described in the test cases to compare the actual results with the expected results. Automated testing is a process that converts human-driven test behavior into machine execution. When encountering tasks that cannot be completed by manual testing, automated testing can take advantage of the machine's fearlessness of fatigue to complete the established test goals, such as stress testing that simulates a large number of user scenarios. The execution of automated testing requires writing a large number of test scripts to support simple and repetitive testing work. Each test script is a test case, and it is difficult to connect large-scale application scenarios in a procedural manner. The current software testing methods rely on manual selection of test methods or manual selection of case design methods, and then case maintenance. This maintenance method has high manual maintenance costs and low efficiency. Some existing case design methods are universal, but in different scenarios, they need to be manually maintained and the cases designed again, which increases the cost of software testing projects.
[0004] Therefore, it is necessary to propose an artificial intelligence-based software automatic testing method and device to solve the problem in the prior art that manual maintenance and modification are relatively frequent, resulting in high labor costs.
[0005] The above information disclosed in this background technology is only used to increase the understanding of the background technology of the present invention and therefore, it may include information that does not constitute the prior art known to a person of ordinary skill in the art. Summary of the invention
[0006] The purpose of the present invention is to provide a software automatic testing method and device based on artificial intelligence to solve the problems raised in the above background technology.
[0007] To achieve the above object, the present invention provides the following technical solutions:
[0008] An artificial intelligence-based software automatic testing method, comprising:
[0009] Step 1: Determine the test type according to the received software test request, parse the software test request and extract the test scenario through natural language processing technology;
[0010] Step 2: Search the preset script library according to the test type and test scenario, extract the test execution script associated with the software test request, and automatically generate test cases using artificial intelligence technology;
[0011] Step 3: Automatically select test resources according to the test case and fine-tune the test scenario to automatically configure the test environment;
[0012] Step 4: Execute the test case through an artificial intelligence-driven automated testing framework based on the test environment, monitor the status of the software in real time and record relevant logs;
[0013] Step 5: When a defect is found, use artificial intelligence technology to locate and analyze the root cause of the defect, obtain historical repair data corresponding to the defect for analysis, and provide repair suggestions;
[0014] Step 6: After the test is completed, the test results are generated, and artificial intelligence technology is used to analyze the test results and provide optimization suggestions.
[0015] Preferably, the natural language processing technology is used to perform entity recognition to extract key entities from the software test request; the BERT model is used to mine the relationships between the entities to distinguish operation types, object types, and expected behaviors or results; dependency syntax analysis or syntax tree construction is performed on the entities to decompose complex descriptions and integrate the entities and relationships into the executable test scenario.
[0016] Preferably, the test processes of the multiple test types and test scenarios are recorded in the form of the test execution script through a visual script editor to generate the test execution scripts corresponding to the multiple test types and test scenarios; the test execution scripts of historical software testing applications are collected, classified according to the test types and test scenarios, and a preset script library is constructed in combination with the generated test execution scripts.
[0017] Preferably, the deep learning model is used to analyze the existing code based on the extracted test execution script to automatically generate the test case; the natural language processing technology is combined with the deep learning model to predict possible defects in the software and generate the corresponding test case.
[0018] Preferably, the test equipment or virtual machine environment is automatically selected according to the type of the test case; the test scenario is adjusted and optimized based on the selected test resources; and the test environment is automatically configured through containerization technology or a cloud testing platform.
[0019] Preferably, the automated testing tool Selenium is called to run the test cases in the test environment; the test strategy optimization based on reinforcement learning is used to select the optimal test execution order and dynamically adjust the test plan according to the actual situation; artificial intelligence technology is used to monitor the test behavior, user operation, and performance indicators in real time to identify potential anomalies; a machine learning algorithm is used to analyze the above anomalies, predict possible failure points, automatically generate a test report and record the log.
[0020] Preferably, the artificial intelligence technology is used to perform static code analysis, dynamic code analysis, and log analysis to determine the root cause of the problem; based on the above defects and logs combined with the historical test data of the test type collected, artificial intelligence technology is used to perform a comprehensive analysis to determine the defect priority and evaluate its impact range.
[0021] Preferably, the test cases corresponding to the affected software modules are automatically selected and regression tests are performed to generate regression test results; and the coverage of the regression tests is optimized through adaptive learning according to the regression test results.
[0022] Preferably, the test case generation strategy is learned and adjusted through a machine learning algorithm based on the above analysis, and the automated testing process is updated; for the specific test scenario, the boundary value analysis and path coverage of the test case are updated in an adaptive adjustment manner.
[0023] An artificial intelligence-based software automatic testing device, comprising:
[0024] A memory, the memory comprising at least one set of instructions, the instructions being constructed to complete a testing process of software automatic testing;
[0025] a processor, in a working state, reading the at least one set of instructions from the memory, and generating corresponding decision information based on the test process according to the at least one set of instructions;
[0026] An execution instruction is issued for the automatic testing of the software according to the decision information.
[0027] Compared with the prior art, the present invention has the following beneficial effects:
[0028] The present invention parses test requests through natural language processing technology, and uses artificial intelligence technology to automatically generate test cases and configure the test environment, eliminating the tedious process of traditional manual writing and updating of test scripts; artificial intelligence monitors software status and records logs in real time during the test execution process, and can automatically locate and analyze the root cause when defects occur, thereby improving the degree of automation of the test process; after the test is completed, artificial intelligence technology conducts in-depth analysis of the results and provides optimization suggestions, helping the development team to promptly discover and fix potential problems.
[0029] The present invention reduces the need for manual intervention and the cost of frequent maintenance through intelligent testing processes, automated resource allocation and optimization suggestions, improves the efficiency, accuracy and sustainability of software testing, and meets the needs of high efficiency and low cost in modern software development.
[0030] The above summary is for illustrative purposes only and is not intended to be limiting in any way. In addition to the illustrative aspects, embodiments and features described above, further aspects, embodiments and features of the present invention will be readily apparent by reference to the accompanying drawings and the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 The figure is a flow chart of the automatic software testing method based on artificial intelligence of the present invention. DETAILED DESCRIPTION
[0032] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions 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 are within the scope of protection of the present invention.
[0033] Embodiment 1:
[0034] See also Figure 1 As shown, a software automatic testing method based on artificial intelligence includes:
[0035] Step 1: Determine the test type according to the received software test request, parse the software test request and extract the test scenario through natural language processing technology;
[0036] Step 2: Search the preset script library according to the test type and test scenario, extract the test execution script associated with the software test request, and automatically generate test cases using artificial intelligence technology;
[0037] Step 3: Automatically select test resources according to test cases, fine-tune test scenarios, and automatically configure the test environment;
[0038] Step 4: Execute test cases based on the test environment through an AI-driven automated testing framework, monitor the software status in real time, and record relevant logs;
[0039] Step 5: When a defect is found, use artificial intelligence technology to locate and analyze the root cause of the defect, obtain historical repair data corresponding to the defect for analysis, and provide repair suggestions;
[0040] Step 6: Generate test results after the test is completed, use artificial intelligence technology to analyze the test results, and provide optimization suggestions.
[0041] Use natural language processing technology to perform entity recognition and extract key entities from software test requests; use the BERT model to mine the relationships between entities, distinguish operation types, object types, and expected behaviors or results; perform dependency syntax analysis or syntax tree construction on entities, decompose complex descriptions, and integrate entities and relationships into executable test scenarios.
[0042] By using natural language processing technology, software requirement documents can be automatically analyzed, key entity information can be extracted, and this information can be used for test case generation. For example, if the requirement document describes a function as "users should be able to enter usernames and passwords on the login page", natural language processing technology can automatically identify this requirement and extract the corresponding entity information, such as "login page", "enter username", "enter password", etc.
[0043] In addition to software requirement documents, natural language processing technology can also be used to analyze user feedback and comments, identify problems and suggestions, and adjust the test case generation and execution process based on this information.
[0044] BERT is a pre-trained language model based on the Transformer architecture. Its innovation lies in significantly improving the performance of natural language processing tasks through bidirectional context modeling. The BERT model has set new records in multiple natural language processing benchmarks and is currently one of the most influential natural language processing models.
[0045] Through a visual script editor, the test processes of multiple test types and test scenarios are recorded in the form of test execution scripts, and test execution scripts corresponding to multiple test types and test scenarios are generated; test execution scripts of historical software testing applications are collected, classified according to test types and test scenarios, and a preset script library is built in combination with the generated test execution scripts.
[0046] The visual script editor uses Node-RED or Grasshopper to write executable test execution scripts. Node-RED is a browser-based streaming programming tool that is commonly used in Internet of Things (IoT) and automation applications. It supports the graphical creation of applications and workflows by dragging and dropping, supports visual design and control of data flows, and is suitable for automation and device control. Grasshopper is a mobile programming learning tool launched by Google, designed for beginners. It helps users learn JavaScript through graphical programming tasks and gamified tutorials. It is suitable for learning and practicing JavaScript, and focuses on understanding programming logic.
[0047] According to the extracted test execution script, the deep learning model is used to analyze the existing code and automatically generate test cases. Natural language processing technology is combined with the deep learning model to predict possible defects in the software and generate corresponding test cases.
[0048] Use deep learning models to analyze existing code and automatically generate test cases, including: first preprocessing and analyzing the code, using code parsing tools to structure the code, performing static analysis on the code, and extracting the code's structural information as well as the code's control flow and data flow; then train the deep learning model, prepare a data set containing annotated code and corresponding test cases, and train a deep learning model to identify potential vulnerabilities, paths, and input-output patterns in the code; then generate test scenarios and test data, use the trained deep learning model to analyze the existing code structure and control flow information, automatically derive multiple possible execution paths, branches, and conditions, and determine the functional points that need to be tested; finally, automatically generate test cases, based on the code analysis results and the above test scenarios, combined with the model's predictive ability, and use the predicted paths, branches, data flows and other information to automatically generate specific test cases.
[0049] Automatically select test equipment or virtual machine environment according to the type of test case; adjust and optimize test scenarios based on selected test resources; automatically configure test environment through containerization technology or cloud testing platform.
[0050] Call the automated testing tool Selenium to run test cases in the test environment; use reinforcement learning-based test strategy optimization according to actual conditions, select the optimal test execution sequence, and dynamically adjust the test plan;
[0051] Reinforcement learning is an important branch of artificial intelligence that focuses on how to enable machines to learn and make decisions by interacting with the environment. In the field of software testing, reinforcement learning is used to optimize test strategies to make the testing process more efficient and intelligent. In the test strategy optimization based on reinforcement learning, the testing process is regarded as a decision-making problem. In this way, the system can learn how to select and execute test cases to maximize the probability of discovering defects.
[0052] Selenium is an open source automated testing tool, mainly used for automated testing of Web applications. It provides a flexible platform that supports multiple browsers and operating systems, helping developers and testers to automatically perform functional verification of Web interfaces. Selenium supports multiple programming languages, such as Java, Python, C#, JavaScript, Ruby, etc., so it is widely used in functional testing and regression testing of Web applications.
[0053] Use artificial intelligence technology to monitor test behaviors, user operations, and performance indicators in real time to identify potential anomalies. Use machine learning algorithms to analyze the above anomalies, predict possible failure points, automatically generate test reports, and record logs.
[0054] Embodiment 2:
[0055] See also Figure 1 As shown, this embodiment is basically the same as the above embodiment, except that artificial intelligence technology is used to perform static code analysis, dynamic code analysis, and log analysis to determine the root cause of the problem; based on the above defects and logs combined with historical test data of the test type collected, artificial intelligence technology is used to perform comprehensive analysis to determine the defect priority and evaluate its impact range.
[0056] Automatically select test cases corresponding to the affected software modules and perform regression testing to generate regression testing results; optimize the coverage of regression testing through adaptive learning based on the regression testing results.
[0057] Use machine learning models to analyze historical test data, intelligently optimize generated test scenarios, and increase testing for common defect types. Leverage failure patterns in historical data to predict which test scenarios may cause failures and prioritize execution.
[0058] Based on the above analysis, the test case generation strategy is learned and adjusted through machine learning algorithms to update the automated testing process; for specific test scenarios, an adaptive adjustment method is used to update the boundary value analysis and path coverage of the test cases.
[0059] As can be seen from the above, the present invention parses test requests through natural language processing technology, uses artificial intelligence technology to automatically generate test cases and configure the test environment, eliminating the tedious process of traditional manual writing and updating of test scripts; artificial intelligence monitors the software status and records logs in real time during the test execution process, and can automatically locate and analyze the root cause when defects occur, thereby improving the degree of automation of the test process; after the test is completed, artificial intelligence technology conducts in-depth analysis of the results and provides optimization suggestions to help the development team discover and fix potential problems in a timely manner.
[0060] The present invention reduces the need for manual intervention and the cost of frequent maintenance through intelligent testing processes, automated resource allocation and optimization suggestions, improves the efficiency, accuracy and sustainability of software testing, and meets the needs of high efficiency and low cost in modern software development.
[0061] Embodiment 3:
[0062] An artificial intelligence-based software automatic testing device, comprising:
[0063] A memory, the memory including at least one set of instructions, the instructions being constructed to complete a test process for automatic software testing;
[0064] The processor reads at least one set of instructions from the memory in a working state, and generates corresponding decision information based on the test process according to the at least one set of instructions;
[0065] Issue execution instructions for automatic software testing based on decision information.
[0066] The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process of the above-mentioned software automatic testing method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. Among them, the computer-readable storage medium, such as a read-only memory (Read-Only Memory, referred to as ROM), a random access memory (Random Access Memory, referred to as RAM), a magnetic disk or an optical disk, etc.
[0067] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples" or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine different embodiments or examples described in this specification and the features of different embodiments or examples, unless they are contradictory.
[0068] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems) and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to generate a program, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A way to specify functions in one or more boxes.
[0069] In the drawings of the embodiments disclosed in the present invention, only the structures involved in the embodiments disclosed in the present invention are involved, and other structures can refer to the general design. In the absence of conflict, the same embodiment and different embodiments of the present invention can be combined with each other.
[0070] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may also be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.
[0071] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A software automatic testing method based on artificial intelligence, characterized in that: include: Step 1: Determine the test type according to the received software test request, parse the software test request and extract the test scenario through natural language processing technology; Step 2: Search the preset script library according to the test type and test scenario, extract the test execution script associated with the software test request, and automatically generate test cases using artificial intelligence technology; Step 3: Automatically select test resources according to the test case and fine-tune the test scenario to automatically configure the test environment; Step 4: Execute the test case through an artificial intelligence-driven automated testing framework based on the test environment, monitor the status of the software in real time and record relevant logs; Step 5: When a defect is found, use artificial intelligence technology to locate and analyze the root cause of the defect, obtain historical repair data corresponding to the defect for analysis, and provide repair suggestions; Step 6: After the test is completed, the test results are generated, and artificial intelligence technology is used to analyze the test results and provide optimization suggestions.
2. The method for automatic software testing based on artificial intelligence according to claim 1, characterized in that: The step of parsing the software test request and extracting the test scenario by using natural language processing technology includes: Using the natural language processing technology to perform entity recognition, extracting key entities from the software testing request; Use the BERT model to mine the relationships between the entities, distinguishing the operation type, object type, and expected behavior or results; Dependency syntactic analysis or syntactic tree construction is performed on the entities to decompose complex descriptions and integrate the entities and relationships into the executable test scenario.
3. The method for automatic software testing based on artificial intelligence according to claim 2, characterized in that: Before searching the preset script library according to the test type and the test scenario and extracting the test execution script associated with the software test request, the method further includes: By means of a visual script editor, the test processes of the plurality of test types and test scenarios are recorded in the form of the test execution script, and the test execution scripts corresponding to the plurality of test types and test scenarios are generated; The test execution scripts of historical software test applications are collected, categorized according to the test types and test scenarios, and a preset script library is constructed in combination with the generated test execution scripts.
4. The method for automatic software testing based on artificial intelligence according to claim 3, characterized in that: The method of automatically generating test cases using artificial intelligence technology includes: Analyze the existing code using a deep learning model according to the extracted test execution script to automatically generate the test case; The natural language processing technology is combined with the deep learning model to predict possible defects in the software and generate the corresponding test cases.
5. The method for automatic software testing based on artificial intelligence according to claim 4, characterized in that: The automatically selecting test resources according to the test case and fine-tuning the test scenario to automatically configure the test environment includes: Automatically select a test device or a virtual machine environment according to the type of the test case; Adjusting and optimizing the test scenario based on the selected test resources; The test environment is automatically configured through containerization technology or a cloud testing platform.
6. The method for automatic software testing based on artificial intelligence according to claim 5, characterized in that: The test environment is based on the test case, the test case is executed by the artificial intelligence driven automated test framework, the software status is monitored in real time and relevant logs are recorded, including: Calling the automated testing tool Selenium to run the test case in the test environment; Use reinforcement learning-based test strategy optimization according to actual conditions, select the optimal test execution sequence, and dynamically adjust the test plan; Use artificial intelligence technology to monitor test behaviors, user operations, and performance indicators in real time to identify potential anomalies; Use machine learning algorithms to analyze the above anomalies, predict possible failure points, automatically generate test reports and record the above logs.
7. The method for automatic software testing based on artificial intelligence according to claim 6, characterized in that: The use of artificial intelligence technology to locate and analyze the root causes of defects includes: Use artificial intelligence technology to perform static code analysis, dynamic code analysis, and log analysis to determine the root cause of the problem; Based on the above defects and logs combined with the historical test data of the test type collected, artificial intelligence technology is used to perform comprehensive analysis to determine the defect priority and assess its impact scope.
8. The method for automatic software testing based on artificial intelligence according to claim 7, characterized in that: The obtaining of historical repair data corresponding to the defect for analysis and providing repair suggestions includes: Automatically select the test cases corresponding to the affected software modules and perform regression testing to generate regression testing results; The coverage of the regression test is optimized through adaptive learning according to the regression test result.
9. The method for automatic software testing based on artificial intelligence according to claim 8, characterized in that: After the test is completed, the test results are generated, and the test results are analyzed using artificial intelligence technology, and optimization suggestions are provided, including: Based on the above analysis, the test case generation strategy is learned and adjusted through a machine learning algorithm to update the automated testing process; For the specific test scenario, an adaptive adjustment method is used to update the boundary value analysis and path coverage of the test case.
10. An artificial intelligence-based software automatic testing device, characterized in that: include: A memory, the memory comprising at least one set of instructions, the instructions being constructed to complete a testing process of software automatic testing; a processor, in a working state, reading the at least one set of instructions from the memory, and generating corresponding decision information based on the test process according to the at least one set of instructions; An execution instruction is issued for the automatic testing of the software according to the decision information.
Citation Information
Cited By
An artificial intelligence-based method for automatic detection and repair of code defects
CN120407371B
Computer software automatic test analysis method and test platform
CN120743784A