Fault detection method, storage medium, electronic equipment and program product
By analyzing the failure stage and code of the automated test cases, and using the fault detection model to generate replacement code, the problem of inefficient detection when the automation test fails, achieving efficient failure cause analysis and resolution.
Patent Information
- Application Number
- CN202510502009.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-21
- Publication Date
- 2025-08-01
AI Technical Summary
When the automation test fails, the prior art requires testers to test the test cases in turn, resulting in low detection efficiency.
By obtaining test cases and generated test failure information, parsing the fault stage and fault code, and entering it into the fault detection model, determining the cause of the fault based on the fault information and stages, generating replacement codes for the fault code.
It enables accurate analysis of the causes of failures and provides solutions without human resources, improving the efficiency of fault detection.
Smart Images

Figure CN120407411A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular, to a fault detection method, a storage medium, an electronic device, and a program product. Background Art
[0002] Automated testing is a process of executing predefined test cases by using specialized software tools, aiming to verify whether the functions of the software work as expected. It can help the team improve testing efficiency, reduce human errors, and support the continuous integration and continuous delivery (CI / CD) process.
[0003] Currently, in the related art, in the case of automated test failure, testers need to detect test cases one by one, and then analyze the reasons for the test failure, resulting in low detection efficiency. Summary of the Invention
[0004] The present disclosure provides a fault detection method, a storage medium, an electronic device, and a program product. Its main purpose is to solve the problem that in the related art, in the case of automated test failure, testers need to detect test cases one by one, and then analyze the reasons for the test failure, resulting in low detection efficiency.
[0005] In a first aspect, the present application provides a fault detection method, including:
[0006] In response to an automated test failure, obtaining the used test cases and the generated test fault information;
[0007] Parsing the test cases to obtain the fault stage and fault code corresponding to the test cases;
[0008] Inputting the test fault information, the fault stage, and the fault code into a fault detection model, and determining the fault cause corresponding to the test cases based on the test fault information and the fault stage in the fault detection model, and generating a replacement code for the fault code based on the fault cause;
[0009] Generating a fault detection result of the test cases based on the fault cause and the replacement code.
[0010] In a second aspect, the present application provides a fault detection device, including:
[0011] An obtaining module, configured to obtain the used test cases and the generated test fault information in response to an automated test failure;
[0012] A parsing module, configured to parse the test cases to obtain the fault stage and fault code corresponding to the test cases;
[0013] A detection module, configured to input test fault information, a fault stage, and a fault code into a fault detection model, determine a fault cause corresponding to a test case based on the test fault information and the fault stage in the fault detection model, and generate a replacement code for the fault code based on the fault cause;
[0014] A generation module, configured to generate a fault detection result of a test case based on the fault cause and the replacement code.
[0015] In a third aspect, the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the method of the first aspect is implemented.
[0016] In a fourth aspect, the present application provides an electronic device, including a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, and when the processor executes the computer program, the method of the first aspect is implemented.
[0017] In a fifth aspect, the present application provides a computer program product, on which a computer program is stored, and when the computer program is executed by a processor, the method of the first aspect is implemented.
[0018] The fault detection method, storage medium, electronic device, and program product provided by the present disclosure, wherein the method includes: in response to an automated test failure, obtaining the used test case and the generated test fault information; parsing the test case to obtain the fault stage and the fault code corresponding to the test case; inputting the test fault information, the fault stage, and the fault code into a fault detection model, determining the fault cause corresponding to the test case based on the test fault information and the fault stage in the fault detection model, and generating a replacement code for the fault code based on the fault cause; generating a fault detection result of the test case based on the fault cause and the replacement code. Compared with the related art, the present application can, in the case of an automated test failure, obtain the used test case and the generated test fault information, parse the test case to obtain the fault stage and the fault code corresponding to the test case, input the test fault information, the fault stage, and the fault code into the fault detection model, determine the fault cause corresponding to the test case based on the test fault information and the fault stage, and generate a replacement code for the fault code based on the fault cause, so that the present application can accurately analyze the fault cause based on the fault detection large model, and can also provide corresponding solutions, and can complete the analysis of the test failure reason without consuming human resources, thereby improving the fault detection efficiency of the test case.
[0019] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present application, nor is it used to limit the scope of the present application. Other features of the present application will become easily understood through the following description. Description of the Drawings
[0020] To more clearly illustrate the embodiments of the present application, the following will briefly introduce the accompanying drawings required for the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can also be obtained based on these drawings.
[0021] Figure 1 It shows a schematic flowchart of a fault detection method provided by an embodiment of the present application;
[0022] Figure 2 It shows a schematic flowchart of another fault detection method provided by an embodiment of the present application;
[0023] Figure 3 It shows a schematic diagram of an example provided by an embodiment of the present application;
[0024] Figure 4 It shows a schematic structural diagram of a fault detection device provided by an embodiment of the present application. Detailed implementation manners
[0025] The following will clearly and completely describe the technical solutions in the embodiments of the present application in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only some, rather than all, embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the protection scope of the present application.
[0026] It should be noted that in the description of the present application, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or further includes elements inherent to such process, method, article or device. The terms "first", "second", etc. in the present application are used to distinguish similar objects and are not used to describe a specific order or sequence.
[0027] Automated testing of hyper-converged infrastructure (HCI) is a crucial step in ensuring system stability, performance, and functional integrity. Automated tests can be executed on idle devices during evenings or idle time to make full use of resources. At the same time, automation can free up the time and energy of testers, allowing them to focus on designing more and better test cases, improving the efficiency of manual testing and the motivation of testers. The main advantages of automated testing include improving test efficiency, ensuring test consistency and repeatability, enhancing software trust, saving costs, accelerating development and delivery speed, increasing productivity, improving test accuracy and quality, obtaining immediate feedback, and supporting continuous integration / continuous delivery (CI / CD) and DevOps practices.
[0028] However, the analysis of automated test results and code maintenance require manual intervention to analyze the reasons for code execution failures step by step for each test case. Once the function changes, even very minor test points may cause test cases to fail to execute. Moreover, after each automated test is triggered, manual intervention is required to analyze the results and maintain the code, consuming a large amount of human resources for repetitive work. If the operations of automated result analysis and code maintenance can be performed automatically, this will greatly free up human resources.
[0029] To address the technical problem of low detection efficiency caused by the need for testers to sequentially detect test cases and then analyze the reasons for test failures in the case of automated test failures in related technologies, this embodiment provides a fault detection method, as Figure 1 shown, the method includes the following steps:
[0030] Step 101, in response to an automated test failure, obtain the used test cases and the generated test failure information.
[0031] In the embodiments of the present application, automated testing is a process of executing predefined test cases by using specialized software tools, aiming to verify whether the functions of the software work as expected. It can help the team improve test efficiency, reduce human errors, and support continuous integration and continuous delivery (CI / CD) processes; correspondingly, test cases are the core components of software testing. They are a set of inputs, operation steps, and expected results designed to verify whether a specific function or behavior meets the expectations. The goal of test cases is to ensure that all aspects of software functions, performance, and security meet the requirements and can discover potential defects.
[0032] In some examples, test failure information can be error messages generated when automated testing using test cases fails. Specifically, during automated testing, when a test case fails, an error message is typically generated. This error message is an important basis for troubleshooting and can help testers or developers quickly locate the root cause of the problem.
[0033] Step 102: parse the test case to obtain the fault stage and fault code corresponding to the test case.
[0034] In the embodiment of the present application, the fault phase corresponding to the test case may include but is not limited to the environment preparation phase, the pre-resource preparation phase, the function execution phase, and the environment cleanup phase. Among them, the environment preparation phase is to prepare the hyper-converged test environment; the pre-resource preparation phase refers to the storage resources (storage pools in the hyper-converged environment), computing resources (virtual machines in the hyper-converged environment), etc. that need to be prepared when the test case is executed; the function execution phase refers to the process of verifying the test points of the test case; and the environment cleanup phase refers to the process of restoring the environment to the pre-resource preparation phase after the function execution phase is completed.
[0035] In some examples, the fault code may specifically be the code in the line of code where the problem is located after parsing the test case; for example, if the test case contains 100 lines of code, the test case can be parsed to determine the lines of code where the fault exists, such as lines 44 and 57, then the codes corresponding to lines 44 and 57 are the fault codes of the test case.
[0036] Step 103: Input the test fault information, fault stage and fault code into the fault detection model, determine the fault cause corresponding to the test case based on the test fault information and fault stage in the fault detection model, and generate a replacement code for the fault code based on the fault cause.
[0037] In an embodiment of the present application, the fault detection model is obtained by taking the test process information of the automated use case and the error information of each process as a data set and training based on these data sets. The fault detection model in the embodiment of the present application can identify the cause of the error at each stage with high accuracy, output the error stage and error information of the test case, and accurately match the corresponding solution.
[0038] In some examples, if fault detection is performed on test case A, after the test fault information, fault stage and fault code corresponding to test case A are input into the fault detection model, the fault cause corresponding to test case A is determined in the fault detection model through the test fault information and fault stage, and a replacement code for the fault code in test case A is generated based on the fault cause.
[0039] For this embodiment, the replacement code is the code generated by the fault detection model based on the error cause for replacing the fault code, and it is also the solution given by the fault detection model in the embodiments of the present application based on the error cause, that is, using the replacement code to replace the fault code.
[0040] For example, if the fault detection model performs fault detection on test case A, after determining the fault cause of test case A, a replacement code for the fault code of test case A can be generated based on the fault cause to solve the fault problem of test case A.
[0041] Step 104, generate the fault detection result of the test case based on the fault cause and the replacement code.
[0042] In the embodiments of the present application, the fault detection result of the fault detection model may specifically include the fault cause and the replacement code. Among them, the replacement code may be the specific method given by the fault detection model for solving the bone fault, that is, replacing the fault code with the replacement code.
[0043] Compared with the related art, in this embodiment, in the case of automated test failure, by obtaining the used test case and the generated test fault information, parsing the test case to obtain the fault stage and fault code corresponding to the test case, and inputting the test fault information, fault stage and fault code into the fault detection model, determining the fault cause corresponding to the test case based on the test fault information and fault stage, and generating a replacement code for the fault code based on the fault cause, so that this embodiment can accurately analyze the fault cause based on the fault detection large model, and can also provide corresponding solutions, without consuming human resources to complete the analysis of the test failure reason, so as to improve the fault detection efficiency of the test case.
[0044] Further, as a refinement and extension of the above embodiment, the embodiments of the present application provide a fault detection method, as Figure 2 shown, the method includes:
[0045] Step 201, in response to the failure of the automated test, obtain the used test case and the generated test fault information.
[0046] In some examples, the fault information may include, but is not limited to: 1. Element not found: The page loading is not completed and the element has not been rendered yet; the ID, CSS selector, or XPath path of the element has changed; the page structure has changed (such as refactoring). 2. Assertion failure: The actual result is inconsistent with the expected result; it may be that a system bug has caused an incorrect result to be returned. 3. Timeout error: The page loading time is too long; there is network latency or slow server response. 4. Execution error of the object- and event-driven client-side scripting language (JavaScript): An error occurs when the JavaScript code is executed, which may be due to the non-existence of DOM elements or incorrect script logic. 5. Database connection failure: The database file path is incorrect; the database service is not started. 6. Application programming interface (API) call failure: The API address is incorrect or the service is unavailable; the network connection is interrupted.
[0047] Step 202: Parse the test case and determine the fault stage from the test phases.
[0048] Among them, the test phases include at least one or more of the environment preparation phase, the precondition resource preparation phase, the function execution phase, and the environment cleanup phase.
[0049] In some examples, the environment preparation phase is to prepare the hyper-converged test environment; the precondition resource preparation phase refers to the storage resources (storage pool in the hyper-converged environment), computing resources (virtual machines in the hyper-converged environment), etc. that need to be prepared when this test case is executed; the function execution phase refers to the process of verifying the test points of the test case; the environment cleanup phase refers to the process of restoring the environment to the precondition resource preparation phase after the function execution phase is completed.
[0050] Exemplarily, if test case B is parsed, the fault stage in test case B can be determined, for example, it can be one or more of the environment preparation phase, the precondition resource preparation phase, the function execution phase, and the environment cleanup phase.
[0051] Step 203: Determine the faulty code line in the fault stage and determine the code corresponding to the faulty code line as the fault code.
[0052] Exemplarily, if test case B contains 50 lines of code, test case B can be parsed to determine the faulty code line, for example, it is the 11th line, then the code corresponding to the 11th line is the fault code of this test case.
[0053] Step 204: Input the test fault information, the fault stage, and the fault code into the fault detection model, and in the fault detection model, determine the fault cause corresponding to the test case based on the test fault information and the fault stage, and generate a replacement code for the fault code based on the fault cause.
[0054] Optionally, step 204 may specifically include: inputting the test failure information, failure stage, and failure code into a failure detection model; determining, in the failure detection model, the failure categories corresponding to the failure stage from at least one failure category; determining the failure cause based on the at least one failure category and the test failure information; and generating a replacement code based on the failure cause.
[0055] Exemplarily, the failure categories may include, but are not limited to: 1) error messages printed when certain tasks fail in the hyper-converged platform, such as failure to create a virtual machine; 2) abnormal error reports caused by code design problems, such as code format problems; 3) environmental problems, such as error messages printed when the platform access is abnormal during use case execution; 4) error messages printed when use case execution fails due to product function changes, such as expected successful creation of a virtual machine but actual failure; 5) interface problems, such as error messages indicating that a method does not exist when calling a certain method.
[0056] It should be noted that each failure stage in the embodiments of the present application corresponds to the same or different failure categories, and each failure category corresponds to different failure causes. For example, failure stage 1 in the present application includes failure category 1, failure category 2, failure category 3, and failure category 4. Among them, failure category 1 may correspond to failure causes 1A, 1B, 1C, 1D, 1E; failure category 2 may correspond to failure causes 2A, 2B, 2C; failure category 3 may correspond to failure causes 3A, 3B, 3C, 3D, 3E, 3F; failure category 4 may correspond to failure causes 4A, 4B, 4C, 4D; and so on. Examples are not given one by one here.
[0057] Exemplarily, if test case B has a failure, it is necessary to determine the failure stage corresponding to test case B. If it is failure stage 3, it is necessary to further analyze the failure category corresponding to test case B in the failure categories corresponding to failure stage 3. If it is failure category 2, it is also necessary to determine the specific failure cause corresponding to test case B in failure category 2. If it is failure cause 2C, it is also necessary to generate a replacement code for the failure code of test case B based on failure cause 2C.
[0058] Optionally, the training process of the failure detection model includes: collecting a historical test case set of automated test failures; training an initial failure detection model based on the historical test failure information, historical failure stage, historical failure code, and historical replacement code corresponding to the historical test case set, and outputting the failure detection model when it is determined that the detection accuracy rate of the initial failure detection model reaches a predetermined accuracy threshold.
[0059] Exemplarily, during the training of the fault detection model, some typical error messages and the locations where the code goes wrong can be used as a dataset to train the large model, and the test set is used for verification until the accuracy rate of the code error types recognized by the large model reaches over 95%; corresponding processing methods are designed according to the corresponding error messages, and then corresponding code maintenance is carried out. For example, when a code format problem is prompted during use case execution, locate the line where the code goes wrong, and detect the lines with code format problems from the line where the code goes wrong until the end of the use case, and format them.
[0060] Step 205, generate the fault detection result of the test case based on the fault cause and the replacement code.
[0061] Optionally, after step 205, the method of this embodiment further includes: obtaining the feedback information of the user on the fault detection result; based on the feedback information, when it is determined that the fault detection result is correct, replace the fault code with the replacement code to obtain the replaced test case, and perform automated testing again based on the replaced test case.
[0062] Exemplarily, when the automated testing of this round is completed, the embodiments of the present application will notify the user of the test results and analysis, and the code maintenance process. The user can distinguish which are faults and which are code problems based on the test results. For the test cases with code problems, the embodiments of the present application will provide solutions to the user. After the user confirms that there is no problem, the code modification and maintenance can be completed, and the code maintenance result can be verified in the next round of automated testing.
[0063] Optionally, the method of this embodiment further includes: based on the feedback information, when it is determined that the fault detection result is incorrect, obtaining the target fault cause and the target test case input by the user; determining the target fault stage, the target fault code, and the target replacement code according to the target test case to update the fault detection model, and performing automated testing again based on the target test case.
[0064] Among them, the updated fault detection model is used for the next fault detection of the test case.
[0065] Exemplarily, after generating the fault detection result, it can be confirmed by the user whether the solution provided by the large model is effective. If it is considered effective, it is adopted, and whether the solution is effective is verified in the next automated testing; if it is considered ineffective, the solution provided by the large model is questioned, and an effective solution is provided. Then, the provided solution is entered into the large model library as the solution to this type of problem. Then, when the correct solution is entered, the large model is retrained to improve the accuracy rate of the large model in identifying errors and providing solutions.
[0066] It should be noted that in the embodiments of the present application, the fault detection model is continuously trained until it can confirm problems based on the stages of different test cases and different error messages, and give corresponding solutions. Then, the user intervenes to confirm whether the solutions provided by the large model can solve the corresponding problems. If they can solve the problems, the solutions are adopted, and the repair results are verified by the next round of automated testing. If they cannot solve the problems, the user gives the solutions, and these solutions are used as a dataset to train the large model to provide more effective solutions for subsequent code analysis.
[0067] Compared with the related technologies, in this embodiment, in the case of automated test failure, by obtaining the used test cases and the generated test fault information, the test cases are parsed to obtain the fault stages and fault codes corresponding to the test cases, and the test fault information, fault stages, and fault codes are input into the fault detection model. Based on the test fault information and fault stages, the fault causes corresponding to the test cases are determined, and replacement codes for the fault codes are generated based on the fault causes. This enables this embodiment to accurately analyze the fault causes based on the fault detection large model, and can also provide corresponding solutions, completing the analysis of the test failure reasons without consuming human resources, thereby improving the fault detection efficiency of the test cases.
[0068] To illustrate the specific implementation process of this embodiment, the following specific application examples are given, such as Figure 3 shown, but not limited thereto:
[0069] The first step: Divide the use case testing process into: environment preparation stage, pre - resource preparation stage, function execution stage, and environment cleanup stage. The environment preparation stage is to prepare the hyper - converged test environment; the pre - resource preparation stage refers to the storage resources (storage pools in the hyper - converged environment), computing resources (virtual machines in the hyper - converged environment), etc. that need to be prepared when this use case is executed; the function execution stage is the process of verifying the test points of the use case; the environment cleanup stage is the process of restoring the environment to the pre - resource preparation stage after the function execution stage is completed.
[0070] The second step: Divide the error messages into the following types, including: 1) Error messages printed when certain tasks fail in the hyper - converged platform, such as failure to create a virtual machine; 2) Exception error reports caused by code design problems, such as code format problems; 3) Environment problems, such as error messages printed when the platform access is abnormal during use case execution; 4) Error messages printed when use case execution fails due to product function changes, such as expected successful creation of a virtual machine but actual failure; 5) Interface problems, such as error messages indicating that a method does not exist when calling a certain method
[0071] Step 3: Use some typical error messages and code error locations as data sets to train the large model, and verify it with the test set until the accuracy of the code error type identified by the large model reaches more than 95%.
[0072] Step 4: Design a corresponding handling method based on the corresponding error message, and then perform corresponding code maintenance. For example, if a code formatting issue is prompted during the use case execution, locate the line of code with the error, and detect the lines with code formatting issues from the error line to the end of the use case, and format them.
[0073] Step 5: The user intervenes to confirm the effectiveness of the solution provided by the large model. If deemed effective, it is adopted and the next automated test verifies its effectiveness. If deemed ineffective, the user questions the large model's solution and provides a valid solution. This solution is then entered into the large model library as a solution to this type of problem. The large model is then retrained with the correct solution entered, improving its accuracy in identifying errors and providing solutions.
[0074] Compared with related technologies, this embodiment can, when an automated test fails, obtain the test case used and the generated test fault information, parse the test case to obtain the fault stage and fault code corresponding to the test case, and input the test fault information, fault stage and fault code into the fault detection model, determine the fault cause corresponding to the test case based on the test fault information and fault stage, and generate a replacement code for the fault code based on the fault cause, so that this embodiment can accurately analyze the fault cause based on the fault detection large model, and can also provide corresponding solutions, so that the analysis of the test failure cause can be completed without consuming human resources, thereby improving the fault detection efficiency for the test case.
[0075] The embodiment of the present application also provides a fault detection device, such as Figure 4 As shown, the device includes: an acquisition module 31, a parsing module 32, a detection module 33, and a generation module 34.
[0076] an acquisition module 31 configured to acquire used test cases and generated test failure information in response to an automated test failure;
[0077] The parsing module 32 is configured to parse the test case to obtain the fault stage and fault code corresponding to the test case;
[0078] The detection module 33 is configured to input the test fault information, fault stage and fault code into a fault detection model, determine the fault cause corresponding to the test case based on the test fault information and fault stage in the fault detection model, and generate a replacement code for the fault code based on the fault cause;
[0079] A generation module 34, configured to generate a fault detection result of a test case based on a fault cause and a replacement code.
[0080] In some examples of this embodiment, the parsing module 32 is specifically configured to parse the test case, determine a fault stage from the test stages, where the test stages include at least one or more of an environment preparation stage, a pre - resource preparation stage, a function execution stage, and an environment cleanup stage; determine the fault code line in the fault stage, and determine the code corresponding to the fault code line as the fault code.
[0081] In some examples of this embodiment, the detection module 33 is specifically configured to input test fault information, a fault stage, and a fault code into a fault detection model; determine at least one fault category corresponding to the fault stage in the fault detection model; determine a fault cause based on the at least one fault category and the test fault information; and generate a replacement code based on the fault cause.
[0082] In some examples of this embodiment, the detection module 33 is further specifically configured to determine a target fault category corresponding to the test fault information in the at least one fault category; match the test fault information with at least one candidate fault cause in the target fault category to match out the fault cause corresponding to the test fault information in the at least one candidate fault cause.
[0083] In some examples of this embodiment, the training process of the fault detection model is specifically configured to collect a set of historical test cases where automated tests fail; train an initial fault detection model based on the historical test fault information, historical fault stages, historical fault codes, and historical replacement codes corresponding to the set of historical test cases, and output a fault detection model when it is determined that the detection accuracy rate of the initial fault detection model reaches a predetermined accuracy rate threshold.
[0084] In some examples of this embodiment, the generation module 34 is further configured to obtain feedback information of the user on the fault detection result; based on the feedback information, when it is determined that the fault detection result is correct, replace the fault code with the replacement code to obtain a replaced test case, and perform an automated test again according to the replaced test case.
[0085] In some examples of this embodiment, the generation module 34 is further configured to, when it is determined that the fault detection result is incorrect based on the feedback information, obtain a target fault cause and a target test case input by the user; determine a target fault stage, a target fault code, and a target replacement code based on the target test case to update the fault detection model, and perform an automated test again based on the target test case, where the updated fault detection model is used for the next fault detection of the test case.
[0086] It should be noted that for other corresponding descriptions of the functional units involved in the fault detection device provided in this embodiment, reference can be made to Figure 1 the corresponding description in
[0087] Based on the method as shown in Figure 1 above, correspondingly, this embodiment also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the method as shown in Figure 1 above is implemented.
[0088] Based on the method as shown in Figure 1 above, correspondingly, this embodiment also provides a computer program product, on which a computer program is stored, and when the computer program is executed by a processor, the method as shown in Figure 1 above is implemented.
[0089] Based on such an understanding, the technical solution of this application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.), and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods in various implementation scenarios of this application.
[0090] Based on the method as shown in Figure 1 above, and Figure 4 the virtual device embodiment as shown above, in order to achieve the above object, this embodiment of the application also provides an electronic device, such as a personal computer or a server, and the device includes a storage medium and a processor; the storage medium is used to store a computer program; the processor is used to execute the computer program to implement the method as shown in Figure 1 above.
[0091] In some embodiments, the above-mentioned physical device may further include a user interface, a network interface, a camera, a radio frequency (RF) circuit, sensors, an audio circuit, a WI-FI module, etc. The user interface may include a display screen and an input unit such as a keyboard, etc. Optionally, the user interface may further include a USB interface, a card reader interface, etc. The network interface may include a standard wired interface, a wireless interface (such as a WI-FI interface), etc. in some embodiments.
[0092] Those skilled in the art can understand that the above-mentioned physical device structure provided in this embodiment does not limit the physical device, and it may include more or fewer components, or a combination of components, or different component arrangements.
[0093] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the above-mentioned physical devices, and supports the operation of information processing programs and other software and / or programs. The network communication module is used to implement communication between components inside the storage medium, as well as communication with other hardware and software in the information processing physical device.
[0094] Through the description of the above embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus a necessary general hardware platform, or can also be implemented by hardware. By applying the solution of this embodiment, compared with the related art, in the case of an automated test failure, this embodiment can, by obtaining the used test cases and the generated test failure information, parse the test cases to obtain the failure stage and failure code corresponding to the test cases, and input the test failure information, failure stage, and failure code into the failure detection model, determine the failure cause corresponding to the test cases based on the test failure information and the failure stage, and generate a replacement code for the failure code based on the failure cause, so that this embodiment can accurately analyze the failure cause based on the failure detection large model, and can also provide corresponding solutions, and can complete the analysis of the test failure reason without consuming human resources, thereby improving the failure detection efficiency of the test cases.
[0095] It should be noted that in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover a non-exclusive inclusion, such that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising one..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the element.
[0096] The above are only specific embodiments of this application, enabling those skilled in the art to understand or implement this application. Various modifications to these embodiments will be obvious to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application will not be limited to these embodiments herein, but will be accorded the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A fault detection method, characterized in that, including: In response to an automated test failure, obtain the used test case and the generated test failure information; Parse the test case to obtain the failure stage and failure code corresponding to the test case; Input the test failure information, the failure stage, and the failure code into a failure detection model, and in the failure detection model, determine the failure cause corresponding to the test case based on the test failure information and the failure stage, and generate a replacement code for the failure code based on the failure cause; Generate a failure detection result for the test case based on the failure cause and the replacement code.
2. The method according to claim 1, characterized in that, The parsing the test case to obtain the failure stage and failure code corresponding to the test case includes: Parse the test case, and determine the failure stage from the test stages, where the test stages include at least one or more of an environment preparation stage, a pre-resource preparation stage, a function execution stage, and an environment cleanup stage; Determine the failure code line in the failure stage, and determine the code corresponding to the failure code line as the failure code.
3. The method according to claim 1, characterized in that The inputting the test failure information, the failure stage, and the failure code into a failure detection model, and in the failure detection model, determining the failure cause corresponding to the test case based on the test failure information and the failure stage, and generating a replacement code for the failure code based on the failure cause includes: Input the test failure information, the failure stage, and the failure code into a failure detection model; Determine at least one failure category corresponding to the failure stage in the failure detection model; Determine the failure cause based on the at least one failure category and the test failure information; Generate the replacement code based on the failure cause.
4. The method according to claim 3, wherein The determining the failure cause based on the at least one failure category and the test failure information includes: Determine the target failure category corresponding to the test failure information in the at least one failure category; Match the test failure information with at least one candidate failure cause in the target failure category to match the failure cause corresponding to the test failure information in the at least one candidate failure cause.
5. The method according to claim 1, wherein The training process of the failure detection model includes: Collect a historical test case set of automated test failures; Train an initial failure detection model based on the historical test failure information, historical failure stages, historical failure codes, and historical replacement codes corresponding to the historical test case set, and output the failure detection model when it is determined that the detection accuracy rate of the initial failure detection model reaches a predetermined accuracy rate threshold.
6. The method according to claim 1, wherein After generating the failure detection result for the test case based on the failure cause and the replacement code, the method further includes: Obtain feedback information from the user on the failure detection result; Based on the feedback information, when it is determined that the failure detection result is correct, replace the failure code with the replacement code to obtain a replaced test case, and perform an automated test again according to the replaced test case.
7. The method according to claim 6, characterized in that, The method further includes: When it is determined that the fault detection result is incorrect based on the feedback information, obtain the target fault cause and the target test case input by the user; Determine the target fault stage, the target fault code, and the target replacement code according to the target test case, update the fault detection model, and perform automated testing again based on the target test case. The updated fault detection model is used for the next fault detection of the test case.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method according to any one of claims 1 to 7.
9. An electronic device, comprising a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method according to any one of claims 1 to 7.
10. A computer program product having a computer program stored thereon, characterized in that, When the computer program product is executed by a processor, it implements the method according to any one of claims 1 to 7.