Software automatic testing method and device

By introducing container virtualization, natural language processing, machine learning and pattern recognition technologies into software automation testing, the bottleneck problem of environmental construction and test data preparation in the face of diversified needs is solved, and efficient and intelligent software automation testing is achieved.

CN119883907AActive Publication Date: 2025-04-25BEIJING AIBEITONG TECHNOLOGY CO LTD

Patent Information

Application Number
CN202411942407.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-27
Publication Date
2025-04-25
Estimated Expiration
2044-12-27

AI Technical Summary

Technical Problem

When the existing automated testing methods face the diversified needs of different hardware platforms and operating systems, the environment construction and the preparation of test data are still bottlenecks, resulting in the reliability and accuracy of test results that cannot be guaranteed.

Method used

By using the operating environment parameters of the target software and combining the container virtualization method, a containerized test environment is created and container metadata information is generated; a natural language processing model is used to generate test cases; a machine learning model is used to optimize and prioritize test cases; a test script is executed in a containerized test environment, and the test results are analyzed through keyword matching and pattern recognition.

Benefits of technology

It realizes the intelligence and efficiency of software automation testing, ensures consistency and high reusability of the test environment, improves the generation efficiency and accuracy of test cases, ensures priority execution of important and high-risk use cases, and improves the efficiency and accuracy of problem positioning.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119883907A_ABST
    Figure CN119883907A_ABST
Patent Text Reader

Abstract

The invention discloses an automatic software testing method and device, and relates to the technical field of software testing, and the method comprises the steps: creating a containerized testing environment and generating container metadata information based on the operation environment parameters of target software in combination with a container virtualization method; generating a test case by using a natural language processing model in combination with the function demand description document of the target software; performing optimization and priority ranking on the test cases through a machine learning model, and outputting an optimized test case list; according to the optimized test case list, executing a test script in a containerized test environment, monitoring a test process, and generating a case test report; based on the use case test report, through keyword matching and pattern recognition, analyzing a test result and carrying out problem positioning; by combining a container virtualization method, natural language processing and a machine learning algorithm, the test efficiency is improved, the requirement of manual intervention is reduced, and the accuracy and timeliness of software quality assurance are improved.
Need to check novelty before this filing date? Find Prior Art

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] As the complexity of software development continues to increase, automated testing has become one of the key steps to ensure software quality. Traditional software testing methods usually rely on manually writing test scripts, manually executing test cases, and manually analyzing test results, which not only consumes a lot of time and human resources, but is also easily interfered by human factors, resulting in reduced accuracy and reliability of test results. In order to improve testing efficiency and quality, in recent years, containerized testing environments based on virtualization have gradually attracted attention. Container virtualization isolates the operating environment of the target software, making the testing process more standardized and repeatable, and effectively avoiding the impact of inconsistent environment configuration on test results. In addition, the introduction of machine learning and natural language processing algorithms has greatly improved the ability to automatically generate and optimize test cases, thereby further accelerating the software testing process.

[0003] However, existing automated testing methods still have some shortcomings in practical applications. Existing automated testing methods often rely on preset static environment configurations, and when faced with the diverse needs of different hardware platforms and operating systems, environment construction and test data preparation are still bottlenecks, resulting in the reliability and accuracy of test results cannot be guaranteed. Existing automated testing tools usually lack intelligent analysis and optimization mechanisms, and cannot be dynamically adjusted according to the complexity and priority of different test cases, resulting in waste of 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 requirement 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 case test report; based on the 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 operating environment parameters and configuration requirements of the target software 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, build a container image instance through instructions;

[0012] Start the built container image instance to 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 automation 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 automated 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 a 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, the test cases are optimized and prioritized by a machine learning model, and a list of optimized test cases is output. The specific steps are:

[0022] Model the test case optimization problem through reinforcement learning algorithm, 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 among all test cases, T t is the execution time of the t-th test case, E t is the probability of finding an error in the t-th test case, 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 capability 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 executed, 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 the use case test report parsing tool;

[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 by category;

[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 ith error, f key (K i ) is the scoring function for the ith wrong keyword match, f pat (P i ) is the scoring function for the i-th wrong pattern match, β1 is the keyword match score weight coefficient, β2 is the pattern match score weight coefficient, K iis the set of keywords for the ith error, key k is the known kth 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 sorted 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, including 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 a functional requirement 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 case test report; the test problem location module is used to analyze test results and locate problems based on the 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 as follows: 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 test cases that match the requirement documents are automatically generated using a natural language processing model, 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 the 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 accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying 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 implementation methods of the present invention are described in detail below in conjunction with the accompanying drawings.

[0054] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and 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" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The term "in one embodiment" that appears in different places in this specification does not necessarily refer to the same embodiment, nor does it refer to a separate or selective embodiment that is mutually exclusive with other embodiments.

[0056] Example 1, reference Figure 1 and Figure 2, is the first embodiment of the present invention, which 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 save 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 Dockerfile. Dockerfile is a script used to build a Docker image, which contains a series of instructions to create the image step by step. The detailed steps include:

[0069] Select a base image: Select 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 select python:3.8-slim as the base image.

[0070] Install dependent software and tools: According to the environmental 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 the environment variables in the container (such as database connection, application key, etc.) through Dockerfile, and copy the configuration files from the local file to the container through the COPY instruction.

[0073] Install testing tools: Install the required automated testing tools (such as Selenium, JUnit, Appium, etc.) as required.

[0074] Expose ports and start 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, use the build instruction to read the configuration from the Dockerfile and start building the container image. The build process will automatically execute all the steps in image creation and ultimately generate a container image file.

[0077] S1.4: Start the built container image instance to 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: record 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 configuration: 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] Preferably, 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 starting and verifying the container instance, the correctness and stability of the environment configuration are ensured, and detailed container metadata information is generated, which improves the transparency and traceability of the test environment. The containerization method improves the flexibility and scalability of the test environment, can quickly adapt to different test requirements, realize automated testing, and reduce manual intervention. This method not only improves the accuracy and efficiency of software testing, but also provides reliable support for continuous integration and delivery, optimizes the test process, reduces configuration errors, and improves the overall test quality and speed.

[0088] S2: Generate test cases using a natural language processing model based on the container metadata information and the functional requirements document of the target software.

[0089] Specifically, the following steps are included:

[0090] S2.1: Communicate with software developers to obtain the functional requirements document of 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 to identify and mark various functional requirements in the document (such as user login and data retrieval, etc.), and the configuration and resource requirements of the container (such as memory and network ports, etc.) are associated. These annotated data will be used as model training data.

[0093] S2.3: Preprocess the model training data to obtain a preprocessed data set.

[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, used the description of the test case as a label, and the paragraph of the functional requirements document as input to train the BERT model. We selected cross entropy as the loss function and used the Adam optimizer for gradient updates so that the model can generate corresponding test cases more accurately.

[0097] S2.5: Use the trained natural language processing model to generate automated test cases from the functional requirements document.

[0098] Preferably, the functional requirements document of the target software is input through the trained BERT model. The model will automatically identify the functional description in the document and generate test cases related to it. Each generated test case should include test steps, expected results, and necessary preconditions. The accuracy and coverage of the test cases are further optimized through continuous feedback mechanisms (such as manual verification and subsequent model iterations). In the generated test cases, ensure that all important scenarios in the functional requirements are covered to avoid missing potential critical paths or boundary conditions.

[0099] Preferably, the BERT model is used to automatically generate test cases consistent with the requirements by combining container metadata information and functional requirement description documents, ensuring coverage of key functions and boundary conditions of the software and avoiding missing potential test scenarios. The natural language processing model improves the efficiency of test case generation, and can continuously optimize its accuracy and coverage, enhancing the reliability and repeatability of the test. This method not only improves test coverage, but also can seamlessly connect with the automated testing framework, accelerate software development and testing cycles, and improve 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: historical results of test case execution (states are generated by executing feedback information); dependencies between test cases (for example, some test cases need to execute other test cases first); and information such as test case execution time, coverage, and boundary conditions.

[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 relative 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 among all test cases, T t is the execution time of the t-th test case, E t is the probability of finding an error in the t-th test case, 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 capability 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, and the Q value is trained through the back propagation algorithm to obtain the test case optimization model.

[0111] Specifically, DQN is a deep reinforcement learning method that combines deep neural networks and Q-learning algorithms to effectively handle complex state spaces and dynamically adjust strategies in practical 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 the Q value of each possible action, that is, the priority score of each test case. By learning the optimization of the Q value, the model is able to deduce how to sort the test cases.

[0112] The training process of DQN includes 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-values ​​of all actions (i.e. possible test case arrangements) through the current state.

[0115] Strategy optimization: Select the action with the maximum 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 the test cases through the test case optimization model and generate an optimized test case list.

[0118] Specifically, after each test case is executed, the state information is updated and a new reward signal is calculated to guide the sorting of subsequent test cases. The model will automatically adjust the execution order of test cases based on the learned strategy, giving priority to those test cases 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 through 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 global optimal solutions. In the test case sorting problem, PSO dynamically optimizes the execution order of test cases through multiple iterations to avoid over-reliance on a single strategy.

[0121] The best one combines reinforcement learning and particle swarm optimization, which can dynamically adjust the test case priority according to test feedback, taking into account factors such as coverage, execution time and error detection ability, and avoid the local optimality problem of traditional sorting methods. Through the DQN model, the sorting strategy can adaptively optimize the execution order of test cases, and the PSO algorithm provides global search optimization when the sorting does not meet expectations, ensuring the global optimality of the strategy. It improves the test efficiency, quality and intelligence level, reduces manual intervention, enhances the test coverage and defect detection ability, and realizes efficient and accurate automated testing.

[0122] S4: According to 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 started from the container image. The test service is started and basic health checks are performed to ensure that the test environment is correct and all dependencies and environment configurations are correct. External services such as network connections, storage, and database connections are working 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, according to the development language and framework of the target software, select the appropriate automated testing tool. For example, Web applications can use Selenium, and backend services can use JUnit or PyTest to ensure execution efficiency and accuracy. Through parameterization support for test case scripts, multiple sets of different data sets 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 the execution status of test cases such as success, failure, running time, resource consumption, etc. The monitored data includes the container's CPU, memory, network and other resource usage.

[0130] S4.4: After the test is executed, a case test report is generated based on the execution results of each test case.

[0131] Specifically, the use case test report includes the following:

[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 functionality are tested and which are not covered.

[0136] The generated report is saved in JSON format.

[0137] Preferably, new container instances are started through container metadata information to ensure 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, especially improving test coverage through data injection. Using monitoring tools to track the execution status of test cases and container resource consumption in real time can ensure the transparency and performance optimization of the test process. The generated test report provides detailed execution results, error location information, and resource consumption, providing developers with effective debugging support, while helping to evaluate 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 to remove 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 set of common error keyword libraries are created. For example, for Java applications, it may include NullPointerException, ClassNotFoundException, etc.; for Python programs, it may include IndexError, TypeError, etc. The error keywords are quickly located by a string matching algorithm (such as the KMP algorithm).

[0145] S5.4: For the matched errors, extract the context information and store them by category.

[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 use natural language processing technology to build an error pattern recognition model based on the BERT model. We build a classification model by training the annotations of historical test reports to automatically identify the type and location of errors. When training the model, we use annotated data containing error logs and expected outputs to generate a context-based error classification model. We apply this model to the test report and use the BERT model to further accurately locate the type and cause of the error based on the error context.

[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 ith error, f key (K i ) is the scoring function for the ith wrong keyword match, f pat (P i ) is the scoring function for the i-th wrong pattern match, β1 is the keyword match score weight coefficient, β2 is the pattern match score weight coefficient, K i is the set of keywords for the ith error, key k is the known kth 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 according to the calculated comprehensive score of each error issue and generate a problem location report.

[0155] Specifically, the problem location report includes the following contents:

[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 running time are extracted through the use case test report parsing tool to ensure a comprehensive grasp of the test process. By cleaning and standardizing error logs, irrelevant information is removed to improve the accuracy of subsequent analysis. In terms of error location, by building a keyword library of common errors and using 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 then 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 to 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 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.

[0166] 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.

[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, and the computer device includes 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 includes 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 can 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 screen 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 key, trackball or touchpad provided on the housing of the computer device, or an external keyboard, touchpad or mouse, etc.

[0169] The present embodiment also provides a storage medium on which a computer program is stored. When the program is executed by a processor, the software automation testing method proposed in the above embodiment is implemented; 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 (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read Only Memory, referred to as EPROM), programmable read-only memory (Programmable Red-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic storage, 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 by the automatic generation of containerized test environments; the test cases that match the requirements documents are automatically generated using natural language processing models, 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.

[0171] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. 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 automated testing method, characterized in that: include, Based on the operating environment parameters of the target software and in combination with the container virtualization method, 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 information 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; According to the optimized test case list, execute the test script 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.

2. The software automation testing method according to claim 1, characterized in that: The specific steps of creating a containerized test environment and generating container metadata information based on the target software's operating environment parameters and in combination with a container virtualization method are as follows: Collect the operating environment parameters and configuration requirements of the target software and build an environmental requirements list; Write virtualization container configuration files based on the environmental requirements list; Based on the virtualized container configuration file, build a container image instance through instructions; Start the built container image instance to 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, characterized in that: The container metadata information includes container basic information, environment variable configuration, service configuration and dependency, resource configuration and running status information.

4. The software automation testing method according to claim 3, characterized in that: 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 a 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 automation testing method according to claim 4, characterized in that: 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 through reinforcement learning algorithm, 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 the tth step, 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 among all test cases, T t is the execution time of the t-th test case, E t is the probability of finding an error in the t-th test case, 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 capability 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 automation testing method according to claim 5, characterized in that: 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 executed, a case test report is generated based on the execution results of each test case.

7. The software automated testing method according to claim 6, characterized in that: 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: Extract test case information through the use case test report parsing tool; 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 by category; 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 ith error, f key (K i ) is the scoring function for the ith wrong keyword match, f pat (P i ) is the scoring function for the i-th wrong pattern match, β1 is the keyword match score weight coefficient, β2 is the pattern match score weight coefficient, K i is the set of keywords for the ith error, key k is the known kth 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 sorted according to the calculated comprehensive score of each error problem and a problem location report is generated.

8. A software automated testing system, based on the software automated testing method according to any one of claims 1 to 7, 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 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 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 the problem based on the use case test report through keyword matching and pattern recognition.

9. 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 7 are implemented.

10. 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 7 are implemented.

Citation Information

Patent Citations

  • Method and device for locating software defect, terminal and computer readable storage medium

    CN108920364A

  • Software integration evaluation method based on machine learning and static analysis

    CN114490344A

  • 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

Cited By

  • Automatic software test case generation system and method based on artificial intelligence

    CN121070802A