Software automated testing method and device
Through an automated testing method combining container virtualization and machine learning, the problems of environment construction and test data preparation are solved, and an efficient and intelligent test process is realized, ensuring the reliability and coverage of test results, and improving software quality and efficiency.
Patent Information
- Application Number
- CN202411942407.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-27
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2044-12-27
AI Technical Summary
When the existing automated testing methods face the diversified needs of different hardware platforms and operating systems, environmental construction and test data preparation are still bottlenecks, resulting in the inability to guarantee the reliability and accuracy of test results, and lack of intelligent analysis and optimization mechanisms, and waste of resources and inefficient testing.
Create a test environment in combination with container virtualization methods, use natural language processing models to generate test cases, and optimize and sort test cases through machine learning model, combine keyword matching and pattern recognition analysis test results to achieve an intelligent and efficient test process.
By automatically generating a consistent test environment, we ensure test coverage and accuracy, optimize the execution order of test cases, improve problem positioning efficiency and accuracy, reduce manual intervention needs, and improve testing efficiency and software quality.
Smart Images

Figure CN119883907B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software testing, and in particular to a method and device for automated software testing. Background Art
[0002] With the increasing complexity of software development, automated testing has become a critical step in ensuring software quality. Traditional software testing methods typically rely on manually writing test scripts, manually executing test cases, and manually analyzing test results. This not only consumes significant time and resources but is also susceptible to human interference, resulting in reduced accuracy and reliability of test results. To improve testing efficiency and quality, containerized testing environments based on virtualization have gained increasing attention in recent years. Container virtualization isolates the target software's runtime environment, making the testing process more standardized and repeatable, effectively preventing the impact of inconsistent environment configurations on test results. Furthermore, the introduction of machine learning and natural language processing algorithms has greatly improved the ability to automatically generate and optimize test cases, further accelerating the software testing process.
[0003] However, existing automated testing methods still have some shortcomings in practical applications. They often rely on static, pre-set environment configurations. Furthermore, when faced with the diverse requirements of different hardware platforms and operating systems, environment setup and test data preparation remain bottlenecks, leading to uncertainties in the reliability and accuracy of test results. Existing automated testing tools often lack intelligent analysis and optimization mechanisms, making them unable to dynamically adjust to the complexity and priority of different test cases, resulting in wasted resources and low testing efficiency. Summary of the Invention
[0004] In view of the above existing problems, the present invention is proposed.
[0005] Therefore, the present invention provides a software automation testing method to solve the problems of insufficient efficiency and quality of traditional software testing methods.
[0006] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0007] In a first aspect, the present invention provides a software automation testing method, which includes, based on the operating environment parameters of the target software, combined with a container virtualization method, creating a containerized test environment and generating container metadata information; based on the container metadata information, combined with the functional requirements description document of the target software, using a natural language processing model to generate test cases; through a machine learning model, optimizing and prioritizing the test cases, and outputting an optimized test case list; according to the optimized test case list, executing the test script in the containerized test environment, monitoring the test process, and generating a use case test report; based on the use case test report, analyzing the test results and locating the problem through keyword matching and pattern recognition.
[0008] As a preferred solution of the software automation testing method of the present invention, wherein: based on the operating environment parameters of the target software, combined with the container virtualization method, a containerized test environment is created and container metadata information is generated. The specific steps are:
[0009] Collect the target software's operating environment parameters and configuration requirements, and build an environmental requirements list;
[0010] Write virtualization container configuration files based on the environmental requirements list;
[0011] Based on the virtualized container configuration file, the container image instance is constructed through instructions;
[0012] Start the built container image instance and verify the dependencies and environment configuration;
[0013] Create container metadata information based on the verified container image.
[0014] As a preferred solution of the software automated testing method described in the present invention, the container metadata information includes container basic information, environment variable configuration, service configuration and dependency, resource configuration and operation status information.
[0015] As a preferred solution of the software automation testing method of the present invention, wherein: the test cases are generated using a natural language processing model based on the container metadata information and the functional requirements document of the target software, and the specific steps are:
[0016] Communicate with software developers to obtain functional requirements documentation for the target software;
[0017] Parse and extract container metadata information and the functional requirements document of the target software to obtain model training data;
[0018] Preprocess the model training data to obtain the preprocessed data set;
[0019] By preprocessing the dataset and combining it with historical test cases, we built a BERT-based natural language processing model.
[0020] Use the trained natural language processing model to generate automated test cases from functional requirement documents.
[0021] As a preferred solution of the software automation testing method of the present invention, wherein: the test cases are optimized and prioritized by the machine learning model, and an optimized test case list is output, the specific steps are:
[0022] Model the test case optimization problem using reinforcement learning algorithms to define the state space, action space, and reward function;
[0023] The expression of the reward function is:
[0024]
[0025] Among them, R t is the reward value of step t, C t is the number of functional modules covered by the test case in step t, C max is the maximum number of covered functional modules in all test cases, T t is the execution time of the test case in step t, E t is the probability of finding an error in the test case at step t, E max is the maximum probability of finding errors among all test cases, α1 is the control coverage weight coefficient, α2 is the execution time weight coefficient, and α3 is the error detection ability weight coefficient;
[0026] Based on the test case optimization problem modeling, the Deep Q-Network algorithm is selected to optimize the order of test cases. The Q value is trained through the back-propagation algorithm to obtain the test case optimization model.
[0027] Through the test case optimization model, test cases are prioritized and an optimized test case list is generated;
[0028] When the priority sorting of the optimized test case list is wrong, a global search is performed through the particle swarm optimization algorithm to further optimize the sorting strategy.
[0029] As a preferred solution of the software automation testing method of the present invention, wherein: the test script is executed in a containerized test environment according to the optimized test case list, the test process is monitored, and a test case test report is generated. The specific steps are:
[0030] Start a new container instance from the container image based on the container metadata information;
[0031] Based on the optimized test case list, create an execution script for each test case in the container instance and use the automated testing tool to execute the test case.
[0032] Use data monitoring tools to collect the execution status of test cases and monitor container resource usage;
[0033] After the test is completed, a case test report is generated based on the execution results of each test case.
[0034] As a preferred solution of the software automation testing method of the present invention, wherein: based on the use case test report, the test results are analyzed and the problem is located through keyword matching and pattern recognition. The specific steps are:
[0035] Extract test case information through use case test report parsing tools;
[0036] Clean and standardize the error logs and execution records in the test case information, removing timestamps and log identifiers;
[0037] Create an error keyword library and use string matching algorithms to locate the specific location of errors in the cleaned and standardized test case information;
[0038] For the matched errors, extract the context information and store them in categories;
[0039] Using natural language processing methods, we built a contextual error classification model based on the BERT model to deeply locate and classify errors.
[0040] Define a comprehensive scoring function to quantify the importance of the error problem, the expression is:
[0041] S i =β1·f key (K i )+β2·f pat (P i );
[0042]
[0043]
[0044] Among them, S i is the comprehensive score of the i-th error, f key (K i ) is the scoring function for the i-th wrong keyword match, f pat (P i ) is the pattern matching score function of the i-th error, β1 is the keyword matching score weight coefficient, β2 is the pattern matching score weight coefficient, K iis the set of keywords for the i-th error, key k is the known k-th keyword, is a Boolean indicator function, n is the size of the known keyword library, k is the keyword index coefficient, P i is the pattern information set of the i-th error, pat m is the mth error pattern, γ is the matching sensitivity parameter, and m is the error pattern index coefficient;
[0045] The problems are ranked according to the calculated comprehensive score of each error problem, and a problem location report is generated.
[0046] In a second aspect, the present invention provides a software automation testing system, comprising a virtual container creation module, a test case generation module, a test case optimization module, a test script execution module and a test problem location module; the virtual container creation module is used to create a containerized test environment and generate container metadata information based on the operating environment parameters of the target software in combination with a container virtualization method; the test case generation module is used to generate test cases using a natural language processing model based on the container metadata information in combination with the functional requirements description document of the target software; the test case optimization module is used to optimize and prioritize test cases through a machine learning model, and output an optimized test case list; the test script execution module is used to execute test scripts in a containerized test environment according to the optimized test case list, monitor the test process, and generate a use case test report; the test problem location module is used to analyze test results and locate problems based on the use case test report through keyword matching and pattern recognition.
[0047] In a third aspect, the present invention provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: when the computer program is executed by the processor, any step of the software automation testing method described in the first aspect of the present invention is implemented.
[0048] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein: when the computer program is executed by a processor, any step of the software automation testing method described in the first aspect of the present invention is implemented.
[0049] The beneficial effects of the present invention are: by combining container virtualization methods, natural language processing, machine learning and pattern recognition, the intelligence and efficiency of software automated testing are achieved. The consistency and high reusability of the test environment are ensured by the automatic generation of a containerized test environment; the natural language processing model is used to automatically generate test cases that match the requirement documents, avoiding the tediousness and errors of manual writing; the priority sorting of test cases is optimized based on machine learning to ensure that important and high-risk cases are executed first; during the execution process, the efficiency of problem location is effectively improved through real-time monitoring and automatically generated test reports; the speed and accuracy of problem location and troubleshooting are further optimized by analyzing test results through keyword matching and pattern recognition. The overall solution improves testing efficiency, reduces the need for manual intervention, and improves the accuracy and timeliness of software quality assurance. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0051] Figure 1 This is a flowchart of the software automation testing method in Example 1.
[0052] Figure 2 Schematic diagram of the software automation testing system in Example 1. DETAILED DESCRIPTION
[0053] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0054] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0055] Secondly, the term "one embodiment" or "embodiment" herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in various places throughout this specification does not necessarily refer to the same embodiment, nor does it refer to a separate or selective embodiment that is mutually exclusive of other embodiments.
[0056] Example 1, reference Figure 1 and Figure 2, which is the first embodiment of the present invention, provides a software automation testing method, comprising the following steps:
[0057] S1: Based on the operating environment parameters of the target software and combined with the container virtualization method, a containerized test environment is created and container metadata information is generated.
[0058] Specifically, the following steps are included:
[0059] S1.1: Collect the operating environment parameters and configuration requirements of the target software and build an environmental requirements list.
[0060] Specifically, the environmental requirements list includes:
[0061] Operating environment parameters: including operating system version, hardware requirements, CPU architecture, memory size, storage requirements, and other infrastructure-related parameters.
[0062] Software dependencies: third-party libraries, database versions, API interfaces, etc. that the target software depends on, including other dependent packages required for runtime (such as Java environment, Python package, Node.js, etc.).
[0063] Configuration file requirements: including application environment variables (such as database connection information, API keys, cache service addresses, etc.), configuration file path and content, log file storage location, etc.
[0064] Service port configuration: The target software may need to expose network ports, listening addresses, and other network configurations (such as Web services, database services, message queues, etc.).
[0065] Security and permission requirements: such as access rights, user authentication configuration, key management, etc., to ensure that the test environment can simulate the actual production environment.
[0066] The environment requirements list is saved in formats such as JSON, YAML, and .env files.
[0067] S1.2: Write a virtualization container configuration file based on the environmental requirements list.
[0068] It should be understood that the virtualization container configuration file refers to the Dockerfile. The Dockerfile is a script used to build a Docker image. It contains a series of instructions that are followed step by step to create the image. The detailed steps include:
[0069] Select a base image: Choose an appropriate base image based on the target software's operating environment. For example, if the target software is based on the Python environment, you can choose python:3.8-slim as the base image.
[0070] Install dependent software and tools: Based on the environment requirements list, gradually install all necessary software and dependent libraries in the Dockerfile. For example, install certain operating system dependencies, development tools, database clients, etc.
[0071] Install the target software: Execute relevant commands through Dockerfile to install the necessary components of the target software or directly pull the target software code from the local or Git repository into the container.
[0072] Set environment variables and configuration files: Set environment variables (such as database connections, application keys, etc.) in the container through Dockerfile, and copy configuration files from local files to the container through the COPY instruction.
[0073] Install testing tools: Install the required automated testing tools (such as Selenium, JUnit, Appium, etc.) as needed.
[0074] Expose ports and startup commands: Expose the required ports for the container and specify the command to be executed when the container starts.
[0075] S1.3: Based on the virtualized container configuration file, build a container image instance through instructions.
[0076] Specifically, the build instruction reads the configuration from the Dockerfile and starts building the container image. The build process automatically executes all the steps in image creation and ultimately generates a container image file.
[0077] S1.4: Start the built container image instance and verify the dependencies and environment configuration.
[0078] Specifically, start and enter the container through the run command, and check whether the environment variables, installed software version, configuration file path, etc. are correct.
[0079] S1.5: Create container metadata information based on the verified container image.
[0080] Specifically, use the inspect command to obtain detailed metadata information of the container and save it as a JSON format file.
[0081] S1.5.1: Container metadata information includes basic container information, environment variable configuration, service configuration and dependencies, resource configuration, and operating status information.
[0082] Specifically, container basic information: records the name, version, base image, startup command, and other information of the container image.
[0083] Environment variable configuration: Record all environment variable settings to ensure the repeatability of subsequent tests.
[0084] Service configuration and dependencies: Record the service configuration related to the operation of the target software (such as database connection, API interface, etc.), as well as external dependencies.
[0085] Resource allocation: records the container's CPU, memory, storage and other resource allocations.
[0086] Running status information: records the current running status of the container, such as whether it is running normally, whether it is connected to external services, etc.
[0087] Ideally, the test environment is automatically built based on the environment requirements list and Dockerfile to ensure that the environment is consistent with the target software and avoid manual configuration errors. By launching and verifying container instances, the correctness and stability of the environment configuration are ensured, and detailed container metadata is generated, improving the transparency and traceability of the test environment. The containerization approach improves the flexibility and scalability of the test environment, enabling rapid adaptation to different testing requirements, enabling automated testing, and reducing manual intervention. This approach not only improves the accuracy and efficiency of software testing, but also provides reliable support for continuous integration and delivery, optimizes the testing process, reduces configuration errors, and improves overall testing quality and speed.
[0088] S2: Based on the container metadata information and the functional requirements document of the target software, a natural language processing model is used to generate test cases.
[0089] Specifically, the following steps are included:
[0090] S2.1: Communicate with software developers to obtain functional requirements documentation for the target software;
[0091] S2.2: Parse and extract container metadata information and the functional requirements document of the target software to obtain model training data.
[0092] Specifically, data annotation is performed based on the extracted document content, identifying and marking various functional requirements in the document (such as user login and data retrieval), and at the same time associating container configuration and resource requirements (such as memory and network ports). This annotated data will be used as model training data.
[0093] S2.3: Preprocess the model training data to obtain a preprocessed dataset.
[0094] It should be noted that preprocessing methods include text cleaning, vocabulary vectorization and data segmentation.
[0095] S2.4: Build a BERT-based natural language processing model by preprocessing the dataset and combining it with historical test cases.
[0096] Specifically, we selected a pre-trained BERT model and fine-tuned it. We combined the content of historical test cases with the functional requirements document, using the test case descriptions as labels and paragraphs from the functional requirements document as input for training the BERT model. We selected cross entropy as the loss function and used the Adam optimizer for gradient updates to ensure that the model could more accurately generate corresponding test cases.
[0097] S2.5: Use the trained natural language processing model to generate automated test cases from functional requirements documents.
[0098] Preferably, the functional requirements document of the target software is input through the trained BERT model. The model automatically recognizes the functional descriptions in the document and generates relevant test cases. Each generated test case should include test steps, expected results, and necessary preconditions. Through continuous feedback mechanisms (such as manual verification and subsequent model iterations), the accuracy and coverage of the test cases are further optimized. In the generated test cases, ensure that all important scenarios in the functional requirements are covered to avoid missing potential critical paths or edge cases.
[0099] Optimally, the BERT model is used to automatically generate test cases aligned with the requirements, combining container metadata with functional requirements documentation. This ensures coverage of key software functions and boundary conditions, avoiding missed test scenarios. Natural language processing models improve test case generation efficiency and continuously optimize accuracy and coverage, enhancing test reliability and repeatability. This approach not only improves test coverage but also seamlessly integrates with automated testing frameworks, accelerating software development and testing cycles and improving software quality.
[0100] S3: Optimize and prioritize test cases through machine learning models, and output a list of optimized test cases.
[0101] Specifically, the following steps are included:
[0102] S3.1: Model the test case optimization problem using reinforcement learning algorithms and define the state space, action space, and reward function.
[0103] Specifically, in the state space, each state represents a configuration of the current test case set, which is defined according to the following characteristics: the historical results of test case execution (states are generated through execution feedback information); dependencies between test cases (for example, some test cases need to execute other test cases first); and information such as the execution time, coverage, and boundary conditions of the test cases.
[0104] The action space represents the optimization operations that can be selected in each state, such as: sorting the priority of the current test case; dynamically adjusting the execution order of certain test cases; selecting certain test cases to skip execution to save time.
[0105] The reward function measures the effectiveness of an action, i.e., how superior the optimized set of use cases is to the original set.
[0106] S3.2: The expression of the reward function is:
[0107]
[0108] Among them, R t is the reward value of step t, C t is the number of functional modules covered by the test case in step t, C max is the maximum number of covered functional modules in all test cases, T t is the execution time of the test case in step t, E t is the probability of finding an error in the test case at step t, E max is the maximum probability of finding errors among all test cases, α1 is the control coverage weight coefficient, α2 is the execution time weight coefficient, and α3 is the error detection ability weight coefficient;
[0109] By continuously interacting with the environment (i.e., executing test cases), the reinforcement learning model will learn to optimize the policy through reward signals.
[0110] S3.3: Based on the test case optimization problem modeling, the Deep Q-Network algorithm is selected to optimize the order of test cases. The Q value is trained through the backpropagation algorithm to obtain the test case optimization model.
[0111] Specifically, DQN is a deep reinforcement learning method that combines deep neural networks with the Q-learning algorithm. It can effectively handle complex state spaces and dynamically adjust policies in real-world applications. The DQN model consists of a deep neural network that receives the current state (the state information of the test case) as input and outputs a Q value for each possible action, that is, a priority score for each test case. By learning to optimize the Q value, the model is able to infer how to rank the test cases.
[0112] The DQN training process consists of the following steps:
[0113] State representation: The state of each test case is represented by a feature vector, such as the test case's execution history, module coverage, expected running time, etc.
[0114] Q-value calculation: The neural network calculates the Q-value of all actions (i.e. possible test case arrangements) through the current state.
[0115] Strategy optimization: Select the action with the largest Q value, that is, select the optimal test case sequence for execution.
[0116] During the training process, the experience replay mechanism is used to avoid correlation interference during the training process, ensuring the stability of the test case optimization model training.
[0117] S3.4: Prioritize test cases using the test case optimization model and generate an optimized test case list.
[0118] Specifically, after each test case execution, the state information is updated and a new reward signal is calculated to guide the sequencing of subsequent test cases. Based on the learned strategy, the model automatically adjusts the execution order of test cases, prioritizing those that are more likely to expose defects or those that can be completed within the time limit.
[0119] S3.5: When the priority sorting of the optimized test case list is wrong, a global search is performed using the particle swarm optimization algorithm to further optimize the sorting strategy.
[0120] It should be understood that the particle swarm optimization (PSO) algorithm can effectively avoid local optimal solutions and explore the global optimal solution. In the test case sorting problem, PSO dynamically optimizes the execution order of test cases through multiple iterations, avoiding over-reliance on a single strategy.
[0121] The optimal approach combines reinforcement learning and particle swarm optimization to dynamically adjust test case priorities based on test feedback, taking into account factors such as coverage, execution time, and error detection capabilities, thus avoiding the local optimality issues of traditional sorting methods. Using the DQN model, the sorting strategy adaptively optimizes the execution order of test cases, and the PSO algorithm provides global search optimization when the sorting does not meet expectations, ensuring the strategy's global optimality. This improves test efficiency, quality, and intelligence, while reducing manual intervention, enhancing test coverage and defect detection capabilities, and achieving efficient and accurate automated testing.
[0122] S4: Based on the optimized test case list, execute the test script in the containerized test environment, monitor the test process, and generate a test case report.
[0123] Specifically, the following steps are included:
[0124] S4.1: Start a new container instance from the container image based on the container metadata information.
[0125] Specifically, based on the container metadata, a new container instance is launched from the container image. The test service is started and basic health checks are performed to ensure the test environment is correct and all dependencies and environment configurations are correct. External services such as network connectivity, storage, and database connections are also verified to be functioning properly.
[0126] S4.2: Based on the optimized test case list, create an execution script for each test case in the container instance and use the automated testing tool to execute the test case.
[0127] Specifically, select the appropriate automated testing tool based on the target software's development language and framework. For example, Selenium can be used for web applications, while JUnit or PyTest can be used for backend services to ensure execution efficiency and accuracy. By supporting parameterized test case scripts, multiple different datasets can be automatically injected to execute the same test case, thereby improving test coverage and efficiency.
[0128] S4.3: Use data monitoring tools to collect the execution status of test cases and monitor the resource usage of containers.
[0129] Specifically, data monitoring tools include software such as Prometheus and Grafana. They collect test case execution status, such as success, failure, runtime, and resource consumption. The monitored data includes container resource usage, such as CPU, memory, and network.
[0130] S4.4: After the test is completed, a test case report is generated based on the execution results of each test case.
[0131] Specifically, the use case test report includes the following contents:
[0132] Test case execution results: Lists the execution status of each test case, such as passed, failed, suspended, etc.
[0133] Error location and stack information: For failed test cases, detailed error logs and stack information are output to help developers locate the problem.
[0134] Resource consumption: Displays the CPU, memory, network and other resources used by the container during the test.
[0135] Coverage analysis: Count the coverage of each test case to see which parts of the functions are tested and which are not covered.
[0136] The generated report is saved in JSON format.
[0137] Optimally, launching new container instances using container metadata ensures the correct configuration and stable operation of the test environment, avoiding test deviations caused by environmental configuration errors. The combination of automated testing tools and scripts enables efficient test case execution, particularly improving test coverage through data injection. Using monitoring tools to track the execution status of test cases and container resource consumption in real time ensures transparency and performance optimization of the testing process. Generated test reports provide detailed execution results, error location information, and resource consumption, providing developers with effective debugging support while helping to assess test coverage and ensure software quality.
[0138] S5: Based on the use case test report, analyze the test results and locate the problem through keyword matching and pattern recognition.
[0139] Specifically, the following steps are included:
[0140] S5.1: Extract test case information through the use case test report parsing tool.
[0141] Specifically, the parsing tool is Python's JSON processing library. The extracted test case information includes execution status, error information, running time, and other data.
[0142] S5.2: Clean and standardize the error logs and execution records in the test case information, removing timestamps and log identifiers.
[0143] S5.3: Create an error keyword library and use string matching algorithms to locate the specific location of errors in the cleaned and standardized test case information.
[0144] Preferably, a keyword library of common errors is created. For example, for Java applications, this may include NullPointerException, ClassNotFoundException, etc.; for Python programs, this may include IndexError, TypeError, etc. A string matching algorithm (such as the KMP algorithm) is used to quickly locate the error keywords.
[0145] S5.4: For the matched errors, extract the context information and store them in categories.
[0146] Specifically, the context information includes the error line number, stack information, specific error location, etc. Classification storage refers to the preliminary classification of errors by matching keywords, such as memory errors, IO errors, and network errors.
[0147] S5.5: Use natural language processing methods to build a contextual error classification model based on the BERT model to deeply locate and classify errors.
[0148] Specifically, we leverage natural language processing technology to build an error pattern recognition model based on the BERT model. By training on annotated historical test reports, we construct a classification model that automatically identifies the type and location of errors. During model training, we use annotated data containing error logs and expected outputs to generate a context-based error classification model. This model is then applied to test reports, and based on the error context, the BERT model is used to further pinpoint the error type and cause.
[0149] Define a comprehensive scoring function to quantify the importance of the error problem, the expression is:
[0150] S i =β1·f key (K i )+β2·f pat (P i );
[0151]
[0152]
[0153] Among them, S i is the comprehensive score of the i-th error, f key (K i ) is the scoring function for the i-th wrong keyword match, f pat (P i ) is the pattern matching score function of the i-th error, β1 is the keyword matching score weight coefficient, β2 is the pattern matching score weight coefficient, K i is the set of keywords for the i-th error, key k is the known k-th keyword, is a Boolean indicator function, n is the size of the known keyword library, k is the keyword index coefficient, P i is the pattern information set of the i-th error, pat m is the mth error pattern, γ is the matching sensitivity parameter, and m is the error pattern index coefficient;
[0154] S5.7: Sort the issues based on the calculated comprehensive score for each error issue and generate a problem location report.
[0155] Specifically, the problem location report includes the following:
[0156] The error type and its description;
[0157] The test case and execution environment where the error occurred;
[0158] The urgency and scope of the error;
[0159] Suggested repair solutions based on pattern recognition.
[0160] Preferably, key data such as execution status, error information, and runtime are extracted through use case test report parsing tools to ensure a comprehensive understanding of the testing process. By cleaning and standardizing error logs, irrelevant information is removed, and the accuracy of subsequent analysis is improved. In terms of error location, by building a keyword library for common errors and utilizing a string matching algorithm, the specific location of the error can be quickly identified and located. Through the contextual error classification method based on the BERT model, errors can be deeply identified and classified, and the type of problem and the cause of occurrence can be accurately located. This process effectively improves the automation and accuracy of error location while reducing the need for manual intervention. The comprehensive scoring function quantifies the importance of the error, making it easier to sort and handle problems by priority, ensuring that high-priority errors are fixed in a timely manner. The generated detailed problem location report not only clearly lists the error type, description, urgency, and repair suggestions, but also provides developers with a clear repair direction, which helps improve software quality and development efficiency.
[0161] This embodiment also provides a software automation testing system, including:
[0162] The virtual container creation module is used to create a containerized test environment and generate container metadata information based on the operating environment parameters of the target software and in combination with the container virtualization method.
[0163] The test case generation module is used to generate test cases using a natural language processing model based on the container metadata information and the functional requirements document of the target software.
[0164] The test case optimization module is used to optimize and prioritize test cases through machine learning models and output a list of optimized test cases.
[0165] The test script execution module is used to execute test scripts in a containerized test environment based on the optimized test case list, monitor the test process, and generate a test case test report.
[0166] The test problem location module is used to analyze test results and locate problems based on use case test reports through keyword matching and pattern recognition.
[0167] This embodiment also provides a computer device suitable for the software automation testing method, including: a memory and a processor; the memory is used to store computer-executable instructions, and the processor is used to execute computer-executable instructions to implement the software automation testing method proposed in the above embodiment.
[0168] The computer device may be a terminal, comprising a processor, a memory, a communication interface, a display screen and an input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device comprises a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner may be achieved through WIFI, an operator network, NFC (near field communication) or other technologies. The display screen of the computer device may be a liquid crystal display or an electronic ink display screen, and the input device of the computer device may be a touch layer covering the display screen, or a button, trackball or touchpad provided on the housing of the computer device, or an external keyboard, touchpad or mouse.
[0169] This embodiment also provides a storage medium having a computer program stored thereon, which, when executed by a processor, implements the software automation testing method proposed in the above embodiment; the storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0170] In summary, the present invention realizes the intelligence and efficiency of software automation testing by: combining container virtualization methods, natural language processing, machine learning and pattern recognition. The consistency and high reusability of the test environment are ensured through the automatic generation of containerized test environments; the natural language processing model is used to automatically generate test cases that match the requirement documents, avoiding the tediousness and errors of manual writing; the priority sorting of test cases is optimized based on machine learning to ensure that important and high-risk cases are executed first; during the execution process, the efficiency of problem location is effectively improved through real-time monitoring and automatically generated test reports; the speed and accuracy of problem location and troubleshooting are further optimized through keyword matching and pattern recognition analysis of test results. The overall solution improves testing efficiency, reduces the need for manual intervention, and improves the accuracy and timeliness of software quality assurance.
[0171] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.
Claims
1. A software automation testing method, characterized by: include, Based on the target software's operating environment parameters and container virtualization methods, a containerized test environment is created and container metadata information is generated. Generate test cases using a natural language processing model based on container metadata and the functional requirements document of the target software. Through machine learning models, test cases are optimized and prioritized, and a list of optimized test cases is output; Based on the optimized test case list, execute the test scripts in the containerized test environment, monitor the test process, and generate a test case report. Based on the use case test report, analyze the test results and locate the problem through keyword matching and pattern recognition. The specific steps are as follows: Extract test case information through use case test report parsing tools; Clean and standardize the error logs and execution records in the test case information, removing timestamps and log identifiers; Create an error keyword library and use string matching algorithms to locate the specific location of errors in the cleaned and standardized test case information; For the matched errors, extract the context information and store them in categories; Using natural language processing methods, we built a contextual error classification model based on the BERT model to deeply locate and classify errors. Define a comprehensive scoring function to quantify the importance of the error problem, the expression is: S i =β1·f Key (K i )+β2·f pat (P i ); Among them, S i is the comprehensive score of the i-th error, f key (K i ) is the scoring function for the i-th wrong keyword match, f pat (P i ) is the pattern matching score function of the i-th error, β1 is the keyword matching score weight coefficient, β2 is the pattern matching score weight coefficient, K i is the set of keywords for the i-th error, key k is the known k-th keyword, is a Boolean indicator function, n is the size of the known keyword library, k is the keyword index coefficient, P i is the pattern information set of the i-th error, pat m is the mth error pattern, γ is the matching sensitivity parameter, and m is the error pattern index coefficient; The problems are ranked according to the calculated comprehensive score of each error problem, and a problem location report is generated.
2. The software automation testing method according to claim 1, wherein: The specific steps of creating a containerized test environment and generating container metadata information based on the target software's operating environment parameters and container virtualization methods are as follows: Collect the target software's operating environment parameters and configuration requirements, and build an environmental requirements list; Write virtualization container configuration files based on the environmental requirements list; Based on the virtualized container configuration file, the container image instance is constructed through instructions; Start the built container image instance and verify the dependencies and environment configuration; Create container metadata information based on the verified container image.
3. The software automation testing method according to claim 2, wherein: The container metadata information includes basic container information, environment variable configuration, service configuration and dependency, resource configuration and running status information.
4. The software automation testing method according to claim 3, wherein: The test cases are generated using a natural language processing model based on the container metadata information and the functional requirements document of the target software. The specific steps are: Communicate with software developers to obtain functional requirements documentation for the target software; Parse and extract container metadata information and the functional requirements document of the target software to obtain model training data; Preprocess the model training data to obtain the preprocessed data set; By preprocessing the dataset and combining it with historical test cases, we built a BERT-based natural language processing model. Use the trained natural language processing model to generate automated test cases from functional requirement documents.
5. The software automated testing method according to claim 4, wherein: The test cases are optimized and prioritized by the machine learning model, and a list of optimized test cases is output. The specific steps are: Model the test case optimization problem using reinforcement learning algorithms to define the state space, action space, and reward function; The expression of the reward function is: Among them, R t is the reward value of step t, C t is the number of functional modules covered by the test case in step t, C max is the maximum number of covered functional modules in all test cases, T t is the execution time of the test case in step t, E t is the probability of finding an error in the test case at step t, E max is the maximum probability of finding errors among all test cases, α1 is the control coverage weight coefficient, α2 is the execution time weight coefficient, and α3 is the error detection ability weight coefficient; Based on the test case optimization problem modeling, the Deep Q-Network algorithm is selected to optimize the order of test cases. The Q value is trained through the back-propagation algorithm to obtain the test case optimization model. Through the test case optimization model, test cases are prioritized and an optimized test case list is generated; When the priority sorting of the optimized test case list is wrong, a global search is performed through the particle swarm optimization algorithm to further optimize the sorting strategy.
6. The software automated testing method according to claim 5, wherein: The specific steps of executing the test script in the containerized test environment according to the optimized test case list, monitoring the test process, and generating a test case test report are as follows: Start a new container instance from the container image based on the container metadata information; Based on the optimized test case list, create an execution script for each test case in the container instance and use the automated testing tool to execute the test case. Use data monitoring tools to collect the execution status of test cases and monitor container resource usage; After the test is completed, a case test report is generated based on the execution results of each test case.
7. A software automated testing system based on the software automated testing method according to any one of claims 1 to 6, characterized in that: Including, virtual container creation module, test case generation module, test case optimization module, test script execution module and test problem location module; The virtual container creation module is used to create a containerized test environment and generate container metadata information based on the operating environment parameters of the target software in combination with the container virtualization method; The test case generation module is used to generate test cases using a natural language processing model based on the container metadata information and the functional requirements document of the target software; The test case optimization module is used to optimize and prioritize test cases through a machine learning model and output an optimized test case list; The test script execution module is used to execute the test script in the containerized test environment according to the optimized test case list, monitor the test process, and generate a test case test report; The test problem location module is used to analyze the test results and locate problems based on the use case test report through keyword matching and pattern recognition.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the software automation testing method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the software automation testing method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Software function automatic test method and system, terminal and medium
CN117421217A
Test case priority ranking method and system
CN117435516A
Automatic test method for reducing test technical threshold of intelligent terminal system
CN117931620A
Software test case automatic generation method and system
CN118860883A