Automated testing method, device, electronic device and storage medium

By recording and reverse restoring the operation behavior of test cases in automated tests, the problem of mutual influence between use cases is solved, the efficiency of automated tests is improved, and the accuracy and efficiency of test results are ensured.

CN113568780BActive Publication Date: 2024-11-22SHENZHEN TCL NEW-TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110753590.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-07-02
Publication Date
2024-11-22
Estimated Expiration
2041-07-02

AI Technical Summary

Technical Problem

During the automated testing process, there are mutual influences between each test case, resulting in inaccurate test results. Traditional methods avoid impacts through independent development of test environments or overall backup and restore, but are inefficient.

Method used

By obtaining the automated test case set of items to be tested, recording and reverse restoring the test case operation behavior, we ensure that subsequent use cases are restored before execution after the data of the test result of the use case is reduced, and the mutual interference between use cases is improved and data restoration efficiency is improved.

Benefits of technology

It effectively reduces the mutual interference between automated tests between use cases, improves data restoration efficiency, and speeds up the automated testing process of the entire project to be tested.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113568780B_ABST
    Figure CN113568780B_ABST
Patent Text Reader

Abstract

The embodiments of the present application disclose an automated testing method, device, electronic device and storage medium, including: obtaining an automated test case set corresponding to multiple test cases to be tested associated with a database table, selecting a first automated test case from the automated test case set and executing it, and obtaining test result data corresponding to the database table; recording the test case operation behavior during the execution of the first automated test case; restoring the test result data of the test case according to the test case operation behavior; when the test result data of the test case is successfully restored, obtaining a second automated test case from the automated test case set and executing the second automated test case; restoring the test result data according to the test case operation behavior, thereby improving the efficiency of restoring the test result data and accelerating the entire automated testing process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of automated testing technology, and in particular to an automated testing method, device, electronic device and storage medium. Background Art

[0002] Automated testing is a type of testing that outsources all or part of the test execution to a machine. This type of testing does not require real-time human involvement and has the advantages of controlling costs and improving efficiency.

[0003] However, during the automated testing process, the various test cases may sometimes affect each other. For example, the results of the previous test case after the test may affect the test of the subsequent test case, making the test result inaccurate. In order to avoid such mutual influence, the traditional method is generally to develop a separate test environment for multiple test cases so that each test environment is independent of each other, or to back up the source project as a whole, and then restore the entire source project after testing the previous test case, and then test the subsequent test case, and then cycle through the tests until all test cases are tested. However, the above test method has the defect of low test efficiency. Summary of the invention

[0004] The embodiments of the present application provide an automated testing method, device, electronic device, and storage medium, which can improve the efficiency of automated testing.

[0005] The present application provides an automated testing method, including:

[0006] Obtaining an automated test case set corresponding to a function module to be tested in the project to be tested, the automated test case set including automated test cases of multiple test cases, and database tables corresponding to the multiple test cases to be tested are associated;

[0007] Selecting a first automated test case from the automated test case set;

[0008] Execute the first automated test case to obtain test result data corresponding to the database table;

[0009] Recording the test case operation behavior during the execution of the first automated test case;

[0010] Restore the test result data according to the test case operation behavior;

[0011] When the case test result data is restored successfully, a second automated test case is obtained from the automated test case set and the second automated test case is executed, wherein the second automated test case is any automated test case in the automated test case set except the first automated test case.

[0012] Accordingly, the embodiment of the present application also provides an automated testing device, including:

[0013] An acquisition module is used to acquire an automated test case set corresponding to a function module to be tested in a project to be tested, wherein the automated test case set includes automated test cases of multiple test cases to be tested, and database tables corresponding to the multiple test cases to be tested are associated;

[0014] A selection module, used for selecting a first automated test case from an automated test case set;

[0015] The test module is used to execute the first automated test case and obtain the test result data corresponding to the database table;

[0016] A recording module, used to record the test case operation behavior during the execution of the first automated test case;

[0017] A restoration module is used to restore the test result data according to the test case operation behavior;

[0018] The decision module is used to obtain a second automated test case from the automated test case set and execute the second automated test case when the case test result data is restored successfully, wherein the second automated test case is any automated test case in the automated test case set except the first automated test case.

[0019] Optionally, in some embodiments of the present application, the restoration module includes:

[0020] A determination unit, used to determine a reverse operation behavior of a test case operation behavior, where the reverse operation behavior and the test case operation behavior operate in opposite ways on the record data recorded in the database table;

[0021] The restoration unit is used to perform reverse operation and restore the test result data.

[0022] Optionally, in some embodiments of the present application, the determining unit includes:

[0023] A first determining subunit is used to determine an execution process of the test case to be tested, where the execution process includes at least one process node;

[0024] An identification subunit, used to identify the type of operation on each process node of the execution process;

[0025] A second determining subunit is used to determine a relative operation type of the operation type, where the relative operation type and the operation type have opposite operation modes on the record data recorded in the database table;

[0026] A sorting subunit is used to sort the execution process in reverse order to obtain a reverse execution process;

[0027] The replacement subunit is used to replace the operation type on each process node in the reverse execution process by using the relative operation type.

[0028] Optionally, in some embodiments of the present application, the second determining subunit is specifically used to:

[0029] Determine the keyword of the operation type operation record data;

[0030] According to the corresponding relationship between the keywords, determine the relative keywords that are opposite to the keywords in data operation;

[0031] Determine the relative operation type based on the relative keyword.

[0032] Optionally, in some embodiments of the present application, the device further includes a first backup module, and the first backup module includes:

[0033] A configuration backup unit is used to back up a configuration file associated with the configuration environment of the functional module to be tested to obtain a backup configuration file;

[0034] The configuration restoration unit is used to restore the configuration data of the configuration environment of the function module to be tested according to the backup configuration file when the test case test result data is restored successfully;

[0035] The decision-making modules include:

[0036] The first decision subunit is used to obtain a second automated test case from the automated test case set and execute the second automated test case when the configuration data is restored successfully.

[0037] Optionally, in some embodiments of the present application, the configuration restoration unit is specifically used to:

[0038] Regenerate the containerized object of the functional module to be tested according to the backup configuration file;

[0039] Replace the configuration environment of the functional module to be tested according to the containerized object.

[0040] Optionally, in some embodiments of the present application, the device further includes a second backup module, and the second backup module includes:

[0041] The architecture data backup unit backs up the basic architecture data corresponding to the project to be tested to obtain backup architecture data;

[0042] The acquisition unit obtains the architecture test result data corresponding to the project to be tested after the automated test case corresponding to the test case to be tested is executed;

[0043] The architecture data replacement unit replaces the architecture test result data with the infrastructure architecture data according to the backup architecture data when the configuration data is restored successfully;

[0044] The decision-making modules include:

[0045] The second decision subunit obtains a second automated test case from the automated test case set and executes the second automated test case when the infrastructure data is replaced successfully.

[0046] The embodiment of the present application performs automated testing on use cases associated with a database table in sequence, and the subsequent use case is automated testing performed only after the prior use case has been tested and the test result data has been restored, so that the automated testing of the subsequent use case is not affected by the prior test results, that is, the mutual interference of automated testing between use cases is reduced. In addition, the embodiment of the present application restores the test result data according to the test case operation behavior, thereby improving the efficiency of data restoration and accelerating the process of automated testing of the entire project to be tested. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the technical solutions in the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0048] Figure 1 It is a scenario diagram of the automated testing method provided by this application;

[0049] Figure 2 It is a flowchart of the automated testing method provided by this application;

[0050] Figure 3 It is a schematic diagram of the use case tree structure in the automated testing method provided by this application;

[0051] Figure 4 It is another flow chart of the automated testing method provided by the present application;

[0052] Figure 5 It is a structural schematic diagram of the automated testing device provided in this application.

[0053] Figure 6 It is a structural schematic diagram of the electronic device provided by this application. DETAILED DESCRIPTION

[0054] The following will be combined with the drawings in this application to clearly and completely describe the technical solutions in this application. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments in the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0055] The embodiments of the present application provide an automated testing method, device, electronic device and storage medium. Specifically, the automated testing method provided in the embodiments of the present application can be performed by an electronic device, wherein the electronic device can be a terminal or a server, etc.; wherein the terminal can be a notebook, a desktop or a tablet computer, etc.; the server can be an independent physical server, or a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution networks (CDN, Content Delivery Network), and big data and artificial intelligence platforms, and the server can be directly or indirectly connected via wired or wireless communication.

[0056] Specifically, see Figure 1 As shown, the embodiment of the present application takes the automated test method running on the terminal as an example, and running on the server can be understood by referring to the automated test method running on the terminal;

[0057] Among them, the specific operation of the automated testing method on the terminal is: the test terminal A obtains the automated test cases corresponding to the multiple test cases to be tested associated with the database table. The automated test cases can be obtained by receiving the sending of the development terminal B, or downloaded by the test terminal A from the cloud server, or directly configured by the relevant testing technicians on the test terminal A. This application takes the acceptance of automated test cases from the development terminal B as an example, and then the test terminal A selects one of the automated test cases for execution to obtain the test result data after the automated test of the case (for example, the data recorded in the database table corresponding to the test case after the automated test). During the execution process, the test terminal A records the test case operation behavior, and after the execution of the automated case is completed, the test terminal A restores the test result data according to the test case operation behavior. When the above test result data is restored successfully, the test terminal A selects another automated test case for execution. In the embodiment of the present application, the above scheme can be used in a loop until the automated test cases corresponding to all the test cases to be tested are executed. Subsequently, the test terminal A can send the test results to the development terminal B, and the code corresponding to the case can be adjusted on the development terminal B according to the automated test results of the test terminal A.

[0058] The embodiment of the present application performs automated testing on use cases associated with database tables in sequence, and the subsequent use case is automated testing performed only after the previous use case is tested and the test result data is restored, so that the automated testing of the subsequent use case is not affected by the previous test results, that is, mutual interference between automated tests of use cases is prevented. In addition, the embodiment of the present application restores the test result data according to the test case operation behavior, thereby improving the efficiency of data restoration and accelerating the process of automated testing of the entire project to be tested.

[0059] It should be noted that the order of description of the following embodiments is not intended to limit the priority order of the embodiments.

[0060] See also Figure 2 , Figure 2 A schematic diagram of the process flow of the automated testing method provided in the embodiment of the present application. The specific process flow of the automated testing method may be as follows:

[0061] 101. Obtain an automated test case set corresponding to a function module to be tested in a project to be tested, wherein the automated test case set includes automated test cases of multiple test cases to be tested, and database tables corresponding to the multiple test cases to be tested are associated with each other.

[0062] Among them, the items to be tested are the items that need to be automatically tested in the embodiments of the present application. These items may include software systems or application programs such as control systems, management systems, and operating systems.

[0063] Among them, the functional module to be tested is a functional module in the project to be tested, each functional module corresponds to a sub-function, and these functional modules are aggregated to form an overall project, for example, a user information management module in a management system or a search module or a personal information management module in an application.

[0064] Among them, the use case to be tested refers to a small functional test point in the functional module to be tested, for example, the login function, registration function, addition function, deletion function, modification function, query function, etc. in the user information management module.

[0065] Among them, the automated test case is a script used for automated testing of the test case to be tested. Automated testing of the test case can be achieved by executing the automated test script using an automated testing tool. The script can be converted from a test case document established for the test case to be tested. For example, the type of automated test script is selected according to the characteristics of the automated testing tool, and the attribute information in the test case document is converted into the automated test script.

[0066] In order to overcome the problem of mutual interference among the test cases under test during the automated testing process, the embodiment of the present application obtains the automated test cases corresponding to the test cases under test based on whether the database tables corresponding to the test cases under test are associated, and manages the automated testing of the test cases under test associated with the database tables. In the embodiment of the present application, each test case under test corresponds to an automated test case.

[0067] 102. Select a first automated test case from the automated test case set.

[0068] Among them, the first automated test case can select any automated test case from the automated test case set, or select an automated test case with a higher test priority as the first automated test case according to actual needs. In an embodiment of the present application, the first automated test case is associated with the database table corresponding to other automated test cases in the automated test case set, and there is no other difference or special selection criteria.

[0069] 103. Execute the first automated test case to obtain test result data corresponding to the database table.

[0070] Among them, the test of the use case is often a test of a certain function in the functional module to be tested, and this function will bring changes to the corresponding database table data during the execution process. Therefore, after executing the automated test case, the database table data corresponding to the use case will also change, and the change of the current database table data may affect the subsequent testing of other use cases. Therefore, in order to prevent the use cases from interfering with each other during the testing process, this part of the data needs to be restored. In the embodiment of the present application, the test result data obtained after the execution of the automated test case is the data that needs to be restored.

[0071] 104. Record the test case operation behavior during the execution of the first automated test case.

[0072] Among them, the data restoration method can be to back up the original data, and then replace the modified data with the backup data to achieve the effect of data restoration. However, this data restoration method is inefficient and requires backing up the database data of the entire project or determining the database table to be backed up. In addition, after the backup, the operation of overwriting or replacing is required, which will reduce the efficiency of the entire automated test.

[0073] Therefore, the embodiment of the present application does not adopt the method of backing up data. Instead, the operation behavior of the data during the execution of the automated test case is obtained through the recording of the test case operation behavior. For example, the operation behavior can be an addition operation, subtraction operation, multiplication operation, etc. on the data. Through the recording of these operation behaviors, the specific process of data change can be obtained, and the data can be restored according to these changes.

[0074] Among them, the record of test case operation behavior can be recorded according to the signal feedback in the automated test case, for example, the changes in database table data can be recorded in real time, and the test case operation behavior can be obtained according to the changes. It can also be obtained according to the operation process of the test case to be tested, for example, the execution process of the code corresponding to the test case to be tested, and the keywords of the operation data in each process, etc.

[0075] 105. Restore the test result data according to the test case operation behavior.

[0076] Among them, the execution process corresponding to the test case can be obtained from the test case operation behavior, and the restoration of the database table data can be achieved according to the execution of the reverse execution process. That is, optionally, in some embodiments, the step of "restoring the test result data of the test case according to the test case operation behavior" can specifically include:

[0077] Determine the reverse operation behavior of the test case operation behavior, where the reverse operation behavior and the test case operation behavior operate in opposite ways on the record data recorded in the database table;

[0078] Perform reverse operations to restore the test result data.

[0079] Data can be restored according to the reverse operation behavior. There is no need to back up the database data before the automated test. Data can be restored after the reverse operation behavior is executed. It is convenient, fast and efficient.

[0080] The reverse operation behavior can be obtained according to the forward operation behavior. The forward operation behavior includes the forward execution process. The reverse operation process can be obtained by reversely sorting the forward execution process. That is, optionally, in some embodiments, the step of "determining the reverse operation behavior of the test case operation behavior" can specifically include:

[0081] Determine the execution process of the test case to be tested, where the execution process includes at least one process node;

[0082] Identify the type of operation at each process node of the execution process;

[0083] Determine the relative operation type of the operation type, the relative operation type and the operation type have opposite operation modes on the record data recorded in the database table;

[0084] Reversely sort the execution process to obtain the reverse execution process;

[0085] The operation type on each process node in the reverse execution process is replaced by the relative operation type.

[0086] Among them, by obtaining the execution process in the test case operation behavior, after the execution process is reversed, the reverse execution process corresponding to the reverse operation behavior can be obtained. By obtaining the operation type on each process node in the execution process, after determining the opposite operation type of the operation type, the operation type of the corresponding process node is replaced in the reverse execution process, and the entire reverse operation behavior can be obtained.

[0087] In an embodiment of the present application, the execution process can be the various steps of code execution, and the keywords on the process nodes can be the keywords for data operations in each step, for example, keywords such as add, delete, modify, and check in each step. The order of the steps can be adjusted, that is, sorted in reverse, and then the keywords in each step are replaced with opposite operation keywords to achieve the reverse operation behavior of the test case operation behavior.

[0088] There is a mapping relationship between the operation type and the keyword. The keyword of each execution step data operation can be determined according to the operation type. Conversely, the operation type of each step can also be determined according to the keyword. There is a corresponding relationship between the keywords. Therefore, the relative operation type of the operation type can be determined according to the keyword. That is, optionally, in some embodiments, the step of "determining the relative operation type of the operation type" can specifically include:

[0089] Determine the keyword of the operation type operation record data;

[0090] According to the corresponding relationship between the keywords, determine the relative keywords that are opposite to the keywords in data operation;

[0091] Determine the relative operation type based on the relative keyword.

[0092] Among them, the operation types include adding operation, deleting operation, modifying operation and querying operation, etc. Through the keywords corresponding to adding operation, deleting operation, modifying operation and querying operation, the relative operation type corresponding to each operation type can be determined, for example, the relative operation type of adding operation is deleting operation.

[0093] Among them, the record of test case operation behavior during the execution of automated test cases is equivalent to the use case pre-position. For example, if a certain automated test case is to test whether the new data can be added successfully, then the use case pre-position is to record the new behavior. The use case test result data is also equivalent to the use case post-position. For example, for the above-mentioned new behavior, the reverse operation behavior of the new behavior is determined, that is, the deletion behavior, and the data added by the new behavior is deleted.

[0094] Among them, for operations on database data during the execution of automated test cases, such as adding or deleting data, the data can be backed up to the cache at the same time. When the case is post-processed, the specified data can be deleted or added through the backup data.

[0095] 106. When the case test result data is restored successfully, obtain a second automated test case from the automated test case set and execute the second automated test case, wherein the second automated test case is any automated test case in the automated test case set except the first automated test case.

[0096] Among them, by restoring the case test result data, that is, restoring the database table data associated with the second automated test case, it can be ensured that the testing of the first automated test case will not affect the testing of the second automated test case.

[0097] Among them, after the second automated test case is executed, the test result data after the second automated test case can also be restored according to the test case operation behavior, and then other automated test cases in the automated test case set are executed, and the execution is looped in sequence until all automated test cases of the project to be tested are completed.

[0098] Before executing the second automated test case, the function module to which the test case belongs is restored. When restoring the function module, the configuration environment of the function module is mainly restored. That is, optionally, in some embodiments, before the step of "obtaining the second automated test case from the automated test case set and executing the second automated test case", the following steps are also included:

[0099] Backing up the configuration file associated with the configuration environment of the functional module to be tested to obtain a backup configuration file;

[0100] When the test case test result data is restored successfully, the configuration data of the configuration environment of the function module to be tested is restored according to the backup configuration file;

[0101] When the use case test result data is restored successfully and the configuration data is restored successfully, a second automated test case is obtained from the automated test case set and the second automated test case is executed.

[0102] Among them, before the execution of the second automated test case, the configuration environment involved in the execution of the first automated test case is restored, which can fully realize the restoration of the project from multiple angles and reduce the interference of the execution of the first automated test case on the execution of the second automated test case. In the embodiment of the present application, the entire configuration environment of the functional module to which the case belongs is restored, that is, the configuration environment of the same functional module to which each automated test case belongs is restored, which can fully reduce the mutual interference of the execution of each automated test case during the automated testing process.

[0103] In the process of restoring the configuration environment, the configuration files related to the configuration environment of the functional module may be backed up, and then after the automated test case is executed, the containerized configuration environment data may be regenerated according to the backed up configuration files, and the configuration test result data after the automated test case is executed may be restored using the regenerated containerized configuration environment data, that is, optionally, in some embodiments, before the step of "restoring the configuration data of the configuration environment of the functional module to be tested according to the backup configuration files", it may also include:

[0104] Regenerate the containerized object of the functional module to be tested according to the backup configuration file;

[0105] Replace the configuration environment of the functional module to be tested according to the containerized object.

[0106] Among them, the configuration file is for the functional module rather than the configuration file for the entire project, for example, the configuration file for the database module, the configuration file for the user information management module or the configuration file for the search module. Therefore, the restoration of the configuration environment for a single functional module has higher execution efficiency and restoration efficiency.

[0107] The backup of the level corresponding to the functional module is equivalent to the module pre-installation, that is, to prevent mutual interference between modules (mutual interference between use cases corresponding to different modules during automated testing), the data of each module is backed up. For example, if the functional module is database-related, the module pre-installation is responsible for backing up the entire database-related content to avoid affecting the execution of other modules due to database interference.

[0108] Restoring the module data is equivalent to the module post-processing. After the entire functional module or a use case in the functional module is automatically tested, the data of the entire functional module is restored. The object tested by the module is generated through containerization technology, so the module front-end usually saves related configuration files. After the test, a new container can be created using the same configuration file. This data recovery technology is faster than overall restoration, so it is more suitable as a means of avoiding interference between modules.

[0109] Among them, the post-processing of the functional module can be executed after the automated testing of a single use case, or after the automated testing of all use cases included in the functional module.

[0110] Before the second automated test case is executed, the infrastructure data of the entire project may also be restored, that is, optionally, in some embodiments, before the step of "restoring the configuration data of the configuration environment of the function module to be tested according to the backup configuration file", it also includes:

[0111] Back up the infrastructure data corresponding to the project to be tested to obtain backup architecture data;

[0112] After the automated test cases corresponding to the test cases to be tested are executed, the architecture test result data corresponding to the project to be tested is obtained;

[0113] When the configuration data is restored successfully, the infrastructure data is replaced with the architecture test result data according to the backup architecture data;

[0114] When the use case test result data is restored successfully, the configuration data is restored successfully, and the infrastructure data is restored successfully, a second automated test case is obtained from the automated test case set and the second automated test case is executed.

[0115] Among them, the infrastructure data can include common data of various functional modules, such as server data, gateway data, architecture underlying configuration files, etc. By restoring the infrastructure data, it is possible to avoid changes in the infrastructure data of the entire project due to automated testing of use cases, thereby avoiding interference with the execution of other automated test cases.

[0116] Among them, the project-level backup is equivalent to the overall pre-installation of the project, which is a pre-installation operation before the entire set of automated test cases starts running. Generally, the data in the overall pre-installation is the data common to each functional module in the project. For example, when testing a certain server, the server includes the database and web server gateway, etc. Since the content in the server is large and complex and cannot be refined, the overall pre-installation will make a comprehensive backup of all the data in the server. No matter how the subsequent functional modules and test cases modify the content of a certain area of ​​the server, this complete backup of the entire project will be kept for subsequent recovery.

[0117] Among them, data restoration at the project level is equivalent to the overall post-processing of the project. The overall post-processing restores the data of the entire project. In the embodiment of the present application, for the execution of automated test cases for a single use case, the overall post-processing can restore the infrastructure data.

[0118] For example, see Figure 3 , Figure 3It is a schematic diagram of the use case tree structure for the entire project in an embodiment of the present application, wherein overall pre-positioning and overall post-positioning are performed for the project, and module pre-positioning and module post-positioning are performed for each module in the project, and use case pre-positioning and use case post-positioning are performed for the use cases in the modules.

[0119] Among them, the overall front-end is mainly for the backup (snapshot) of the underlying common data such as the project operating environment, and the overall post-end is to restore the operating environment according to the backup data of the overall front-end; the module front-end is mainly for the backup of the module configuration environment, for example, the configuration files related to the module configuration environment are backed up, and the module post-end is based on the backup configuration files in the module front-end, using the backup configuration files to regenerate the containerized object, and use the containerized object to replace the module configuration environment data to achieve the restoration of the module-level configuration environment; the use case front-end records the test case operation behavior for specific use cases, and after the use case automation test is completed, the test result data is restored according to the test case operation behavior, among which the test case data can be restored according to the reverse operation behavior of the test case operation behavior, that is, action rollback.

[0120] Among them, the overall post-position can be executed after the execution of the automated test case of a single use case is completed, it can also be executed after the post-position of a single functional module, and it can also be executed after the automated test cases of all use cases are executed and after the functional modules are restored.

[0121] In an embodiment of the present application, the test case may also be a code block. In order to determine whether the code block can be executed according to the expected steps, this part of the code block may be subjected to an automated test, wherein the database tables operated by each code block may be different, may be the same, or may be related to each other. In an embodiment of the present application, a code block associated with a database table of operation data is obtained, and then the automated test case corresponding to one of the code blocks is executed, and the execution of the automated test cases corresponding to other code blocks is stopped. That is, when one of the code blocks is subjected to an automated test, the code blocks associated with other database tables are locked until the automated test case of the previous code block is executed, and after restoring the database table data according to the execution flow of the code block, an automated test case corresponding to a code block is selected from other code blocks for execution until the automated testing of all code blocks is completed.

[0122] For example, multiple code blocks in the same use case may also belong to different modules, and the database tables corresponding to different modules may be different. Therefore, the code blocks to be tested can be determined simultaneously according to the use case and the module, and other code blocks belonging to the same module in the use case can be locked. For example, use case A includes code block 1, code block 2, code block 3 and code block 4, wherein code block 1 belongs to module 1, code block 2 belongs to module 2, code block 3 belongs to module 4, and code block 4 belongs to module 5. When the embodiment of the present application performs automated testing on the code blocks in use case A, since code block 1, code block 2, code block 3 and code block 4 belong to different modules respectively, these code blocks Code blocks can be subjected to automated testing operations simultaneously. Conversely, if code block 1 and code block 1a belong to the same module, it is necessary to first perform automated testing on code block 1 and lock code block 1a at the same time, or to first perform automated testing on code block 1a and lock code block 1 at the same time. The purpose is that since code block 1 and code block 1a belong to the same module, the database table data involved can be associated. Therefore, in order to avoid mutual interference during the automated testing of the two code blocks, the two code blocks are subjected to automated testing successively, and the test result data after testing one of the code blocks is restored before the automated testing of the other code blocks is performed.

[0123] In an embodiment of the present application, when the database tables of the operation data are not related, pipeline operations can be performed on each code block. For example, these code blocks can be automatically tested at the same time, that is, the automated test cases corresponding to these code blocks can be executed at the same time, thereby speeding up the automated testing process of the entire project.

[0124] For example, see Figure 4 , Figure 4 Another flow chart for automated testing of the test case, including:

[0125] Pre-process:

[0126] 110. Perform overall pre-production of the project (for example, backing up or taking snapshots of the operating environment information);

[0127] 111. Perform module pre-setting for each functional module in the project to be tested (for example, back up each functional module or the configuration environment data of the module, such as backing up the configuration file);

[0128] 112. Perform use case pre-positioning for each use case in the functional module (for example, record the test case operation behavior of the use case);

[0129] 113. When performing automated testing on a use case, lock and pipeline operations are performed on the code block corresponding to the use case;

[0130] Post-process:

[0131] 114. After the use case is automatically tested, that is, after the code block corresponding to the use case is executed, each use case in the functional module is post-tested (for example, the test case result data is restored according to the reverse operation behavior);

[0132] 115. After each use case in the functional module is post-positioned, each functional module is post-positioned (for example, a containerized object is regenerated using a backed-up configuration file, and configuration environment data is replaced using the containerized object);

[0133] 116. After each functional module is post-positioned, the entire project is post-positioned as a whole (for example, the environmental data of the project after automated testing is replaced according to the backed-up environmental information).

[0134] The embodiment of the present application performs automated testing on use cases associated with a database table in sequence, and the subsequent use case is automated testing performed only after the prior use case has been tested and the test result data has been restored, so that the automated testing of the subsequent use case is not affected by the prior test results, that is, the mutual interference of automated testing between use cases is reduced. In addition, the embodiment of the present application restores the test result data according to the test case operation behavior, thereby improving the efficiency of data restoration and accelerating the process of automated testing of the entire project to be tested.

[0135] In order to better implement the automated testing method of the present application, the present application also provides an automated testing device based on the automated testing method. The meanings of the terms are the same as those in the automated testing method, and the specific implementation details can refer to the description in the method embodiment.

[0136] See also Figure 5 , Figure 5 The schematic diagram of the structure of the automated testing device provided in the present application, wherein the automated testing device may include an acquisition module 201, a selection module 202, a test module 203, a recording module 204, a restoration module 205 and a decision module 206, which may be specifically as follows:

[0137] The acquisition module 201 is used to acquire an automated test case set corresponding to a function module to be tested in a project to be tested. The automated test case set includes automated test cases of multiple test cases. Database tables corresponding to the multiple test cases are associated.

[0138] In order to overcome the problem of mutual interference among the test cases under test during the automated testing process, the acquisition module 201 in the embodiment of the present application acquires the automated test case corresponding to the test case under test based on whether the database table corresponding to the test case under test is associated, and manages the automated testing of the test case under test associated with the database table. In the embodiment of the present application, each test case under test corresponds to an automated test case.

[0139] The selection module 202 is used to select a first automated test case from the automated test case set.

[0140] Among them, the first automated test case can select any automated test case from the automated test case set, or select an automated test case with a higher test priority as the first automated test case according to actual needs. In an embodiment of the present application, the first automated test case is associated with the database table corresponding to other automated test cases in the automated test case set, and there is no other difference or special selection criteria.

[0141] The testing module 203 is used to execute the first automated test case and obtain the test result data corresponding to the database table.

[0142] Among them, the test of the use case is often a test of a certain function in the functional module to be tested, and this function will bring changes to the corresponding database table data during the execution process. Therefore, after executing the automated test case, the database table data corresponding to the use case will also change, and the change of the current database table data may affect the subsequent testing of other use cases. Therefore, in order to prevent the use cases from interfering with each other during the testing process, this part of the data needs to be restored. In the embodiment of the present application, the test result data obtained after the execution of the automated test case is the data that needs to be restored.

[0143] The recording module 204 is used to record the test case operation behavior during the execution of the first automated test case.

[0144] Among them, the record of test case operation behavior can be recorded according to the signal feedback in the automated test case, for example, the changes in database table data can be recorded in real time, and the test case operation behavior can be obtained according to the changes. It can also be obtained according to the operation process of the test case to be tested, for example, the execution process of the code corresponding to the test case to be tested, and the keywords of the operation data in each process, etc.

[0145] The restoration module 205 is used to restore the test result data according to the test case operation behavior.

[0146] For example, the execution process corresponding to the test case can be obtained from the test case operation behavior, and the database table data can be restored by executing the reverse execution process.

[0147] Optionally, in some embodiments of the present application, the restoration module 205 includes:

[0148] A determination unit, used to determine a reverse operation behavior of a test case operation behavior, where the reverse operation behavior and the test case operation behavior operate in opposite ways on the record data recorded in the database table;

[0149] The restoration unit is used to perform reverse operation and restore the test result data.

[0150] Data can be restored according to the reverse operation behavior. There is no need to back up the database data before the automated test. Data can be restored after the reverse operation behavior is executed. It is convenient, fast and efficient.

[0151] Optionally, in some embodiments of the present application, the determining unit includes:

[0152] A first determining subunit is used to determine an execution process of the test case to be tested, where the execution process includes at least one process node;

[0153] An identification subunit, used to identify the type of operation on each process node of the execution process;

[0154] A second determining subunit is used to determine a relative operation type of the operation type, where the relative operation type and the operation type have opposite operation modes on the record data recorded in the database table;

[0155] A sorting subunit is used to sort the execution process in reverse order to obtain a reverse execution process;

[0156] The replacement subunit is used to replace the operation type on each process node in the reverse execution process by using the relative operation type.

[0157] Among them, by obtaining the execution process in the test case operation behavior, after the execution process is reversed, the reverse execution process corresponding to the reverse operation behavior can be obtained. By obtaining the operation type on each process node in the execution process, after determining the opposite operation type of the operation type, the operation type of the corresponding process node is replaced in the reverse execution process, and the entire reverse operation behavior can be obtained.

[0158] In an embodiment of the present application, the execution process can be the various steps of code execution, and the keywords on the process nodes can be the keywords for data operations in each step, for example, keywords such as add, delete, modify, and check in each step. The order of the steps can be adjusted, that is, sorted in reverse, and then the keywords in each step are replaced with opposite operation keywords to achieve the reverse operation behavior of the test case operation behavior.

[0159] Optionally, in some embodiments of the present application, the second determining subunit is specifically used to:

[0160] Determine the keyword of the operation type operation record data;

[0161] According to the corresponding relationship between the keywords, determine the relative keywords that are opposite to the keywords in data operation;

[0162] Determine the relative operation type based on the relative keyword.

[0163] The decision module 206 is used to obtain a second automated test case from the automated test case set and execute the second automated test case when the test case result data is restored successfully, wherein the second automated test case is any automated test case in the automated test case set except the first automated test case.

[0164] Optionally, in some embodiments of the present application, the device further includes a first backup module, and the first backup module includes:

[0165] A configuration backup unit is used to back up a configuration file associated with the configuration environment of the functional module to be tested to obtain a backup configuration file;

[0166] The configuration restoration unit is used to restore the configuration data of the configuration environment of the function module to be tested according to the backup configuration file when the test case test result data is restored successfully;

[0167] The decision module 206 includes:

[0168] The first decision subunit is used to obtain a second automated test case from the automated test case set and execute the second automated test case when the configuration data is restored successfully.

[0169] Optionally, in some embodiments of the present application, the configuration restoration unit is specifically used to:

[0170] Regenerate the containerized object of the functional module to be tested according to the backup configuration file;

[0171] Replace the configuration environment of the functional module to be tested according to the containerized object.

[0172] Optionally, in some embodiments of the present application, the device further includes a second backup module, and the second backup module includes:

[0173] The architecture data backup unit backs up the basic architecture data corresponding to the project to be tested to obtain backup architecture data;

[0174] The acquisition unit obtains the architecture test result data corresponding to the project to be tested after the automated test case corresponding to the test case to be tested is executed;

[0175] The architecture data replacement unit replaces the architecture test result data with the infrastructure architecture data according to the backup architecture data when the configuration data is restored successfully;

[0176] The decision module 206 includes:

[0177] The second decision subunit obtains a second automated test case from the automated test case set and executes the second automated test case when the infrastructure data is replaced successfully.

[0178] In the embodiment of the present application, the acquisition module 201 first acquires the set of automated test cases corresponding to the function to be tested in the project to be tested, wherein the set of automated test cases includes automated test cases of multiple test cases, and the database tables corresponding to the multiple test cases are associated with each other. Secondly, the selection module 202 selects an automated test case from the set of automated test cases. Then, the testing module 203 executes the automated test case selected by the selection module 202 to obtain test result data. At the same time, the recording module 204 records the test case operation behavior during the execution of the automated test case. Subsequently, the restoration module 205 restores the test result data according to the test case operation behavior obtained by the recording module. Finally, after the test result data is successfully restored, the decision module 203 Module 206 selects one of the remaining automated test cases from the automated test case set, and then the test module 203 executes the selected automated test case, in a loop until all automated test cases corresponding to the functions to be tested are completed. The embodiment of the present application controls the sequential execution of automated test cases associated with the database table, and executes the subsequent automated test case only after the execution of the previous automated test case is completed and the test result data is restored, which can avoid the problem of mutual interference during the execution of automated test cases. In addition, in the embodiment of the present application, the test result data is restored according to the test case operation behavior during the execution of the automated test case, which improves the efficiency of data restoration and speeds up the process of automated testing of the entire project to be tested.

[0179] In addition, the present application also provides an electronic device, such as Figure 6 As shown, it shows a schematic diagram of the structure of the electronic device involved in this application, specifically:

[0180] The electronic device may include components such as a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, a power supply 403, and an input unit 404. Those skilled in the art will appreciate that Figure 6 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0181] The processor 401 is the control center of the electronic device, and uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 402, and calling data stored in the memory 402, the processor 401 performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. Optionally, the processor 401 may include one or more processing cores; preferably, the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 401.

[0182] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and data processing by running the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 402 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 with access to the memory 402.

[0183] The electronic device also includes a power supply 403 for supplying power to each component. Preferably, the power supply 403 can be logically connected to the processor 401 through a power management system, so as to manage charging, discharging, power consumption and other functions through the power management system. The power supply 403 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators and other arbitrary components.

[0184] The electronic device may further include an input unit 404, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.

[0185] Although not shown, the electronic device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 401 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 402 according to the following instructions, and the processor 401 will run the application programs stored in the memory 402, thereby realizing various functions, as follows:

[0186] Obtain an automated test case set corresponding to a functional module to be tested in the project to be tested, the automated test case set including multiple automated test cases for the cases to be tested, and the database tables corresponding to the multiple cases to be tested are associated with each other; select a first automated test case from the automated test case set; execute the first automated test case to obtain test result data corresponding to the database table; record the test case operation behavior during the execution of the first automated test case; restore the test result data to the test case test result data according to the test case operation behavior; when the test case test result data is restored successfully, obtain a second automated test case from the automated test case set, and execute the second automated test case, wherein the second automated test case is any automated test case in the automated test case set except the first automated test case.

[0187] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0188] The embodiment of the present application performs automated testing on use cases associated with database tables in sequence, and the subsequent use case is automated testing performed only after the previous use case is tested and the test result data is restored, so that the automated testing of the subsequent use case is not affected by the previous test results, that is, mutual interference between automated tests of use cases is prevented. In addition, the embodiment of the present application restores the test result data according to the test case operation behavior, thereby improving the efficiency of data restoration and accelerating the process of automated testing of the entire project to be tested.

[0189] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.

[0190] To this end, the present application provides a storage medium in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any message delay detection method provided in the present application. For example, the instructions can execute the following steps:

[0191] Obtain an automated test case set corresponding to a functional module to be tested in the project to be tested, the automated test case set including multiple automated test cases for the cases to be tested, and the database tables corresponding to the multiple cases to be tested are associated with each other; select a first automated test case from the automated test case set; execute the first automated test case to obtain test result data corresponding to the database table; record the test case operation behavior during the execution of the first automated test case; restore the test result data to the test case test result data according to the test case operation behavior; when the test case test result data is restored successfully, obtain a second automated test case from the automated test case set, and execute the second automated test case, wherein the second automated test case is any automated test case in the automated test case set except the first automated test case.

[0192] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0193] The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0194] Since the instructions stored in the storage medium can execute the steps in any one of the automated testing methods provided in the present application, the beneficial effects that can be achieved by any one of the automated testing methods provided in the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.

[0195] The above is a detailed introduction to an automated testing method, device, electronic device and storage medium provided by the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. An automated testing method, characterized in that: include: Obtaining an automated test case set corresponding to a function module to be tested in the project to be tested, wherein the automated test case set includes automated test cases of multiple test cases to be tested, and database tables corresponding to the multiple test cases to be tested are associated; Selecting a first automated test case from the automated test case set; Execute the first automated test case to obtain test result data corresponding to the database table; Recording test case operation behaviors during the execution of the first automated test case; Performing case test result data restoration on the test result data according to the test case operation behavior; When the test case test result data is restored successfully, obtaining a second automated test case from the automated test case set, and executing the second automated test case, wherein the second automated test case is any automated test case in the automated test case set except the first automated test case; The restoring the test result data according to the test case operation behavior includes: Determine an execution process of the test case, wherein the execution process includes at least one process node; Identifying an operation type at each process node of the execution process; Determine a relative operation type of the operation type, where the relative operation type and the operation type have opposite operation modes on the record data recorded in the database table; Reversely sort the execution process to obtain a reverse execution process; Using the relative operation type to replace the operation type on each process node in the reverse execution process, to obtain a counter-execution process; Execute the reverse operation behavior corresponding to the opposite execution process to restore the user test result data to the test result data; The executing the first automated test case to obtain the test result data corresponding to the database table includes: Determine a plurality of code blocks involved in the first automated test case, and determine a functional module to which each code block belongs; If there are multiple first code blocks belonging to the same functional module, a second code block is selected from the first code blocks, and other code blocks in the first code blocks except the second code block are used as third code blocks; Performing a locking operation on the third code block; Executing the first automated test case on the second code block to obtain test result data; Among them, after the test result data of the second code block is restored, the first automated test case is used to test each code block in the third code block respectively.

2. The method according to claim 1, characterized in that The determining the relative operation type of the operation type comprises: Determine a keyword for operating the recorded data using the operation type; Determining, according to the correspondence between the keywords, a relative keyword that is opposite to the keyword in data operation; The relative operation type is determined according to the relative keyword.

3. The method according to claim 1, characterized in that The method further includes: Backing up the configuration file associated with the configuration environment of the functional module to be tested to obtain a backup configuration file; When the test case test result data is restored successfully, the configuration data of the configuration environment of the functional module to be tested is restored according to the backup configuration file; When the test case test result data is restored successfully, obtaining a second automated test case from the automated test case set and executing the second automated test case includes: When the configuration data is restored successfully, a second automated test case is obtained from the automated test case set, and the second automated test case is executed.

4. The method according to claim 3, characterized in that The restoring of configuration data of the configuration environment of the functional module to be tested according to the backup configuration file includes: Regenerate the containerized object of the functional module to be tested according to the backup configuration file; The configuration environment of the functional module to be tested is replaced according to the containerized object.

5. The method according to claim 3, characterized in that: The method further includes: Backing up the infrastructure data corresponding to the project to be tested to obtain backup architecture data; After the automated test case corresponding to the test case is executed, the architecture test result data corresponding to the test item is obtained; When the configuration data is restored successfully, the architecture test result data is replaced with basic architecture data according to the backup architecture data; When the test case test result data is restored successfully, obtaining a second automated test case from the automated test case set and executing the second automated test case includes: When the infrastructure data is replaced successfully, a second automated test case is obtained from the automated test case set, and the second automated test case is executed.

6. An automated testing device, characterized in that: include: An acquisition module is used to acquire an automated test case set corresponding to a function module to be tested in a project to be tested, wherein the automated test case set includes automated test cases of multiple test cases to be tested, and database tables corresponding to the multiple test cases to be tested are associated; A selection module, used to select a first automated test case from the automated test case set; A test module, used to execute the first automated test case and obtain the test result data corresponding to the database table; A recording module, used to record the test case operation behavior during the execution of the first automated test case; A restoration module, used to restore the test result data according to the test case operation behavior; A decision module, configured to obtain a second automated test case from the automated test case set and execute the second automated test case when the test case test result data is restored successfully, wherein the second automated test case is any automated test case in the automated test case set except the first automated test case; The restoring the test result data according to the test case operation behavior includes: Determine an execution process of the test case, wherein the execution process includes at least one process node; Identifying an operation type at each process node of the execution process; Determine a relative operation type of the operation type, where the relative operation type and the operation type have opposite operation modes on the record data recorded in the database table; Reversely sort the execution process to obtain a reverse execution process; Using the relative operation type to replace the operation type on each process node in the reverse execution process, to obtain a counter-execution process; Execute the reverse operation behavior corresponding to the opposite execution process to restore the user test result data to the test result data; The executing the first automated test case to obtain the test result data corresponding to the database table includes: Determine a plurality of code blocks involved in the first automated test case, and determine a functional module to which each code block belongs; If there are multiple first code blocks belonging to the same functional module, a second code block is selected from the first code blocks, and other code blocks in the first code blocks except the second code block are used as third code blocks; Performing a locking operation on the third code block; Executing the first automated test case on the second code block to obtain test result data; Among them, after the test result data of the second code block is restored, the first automated test case is used to test each code block in the third code block respectively.

7. An electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the steps of the automated testing method according to any one of claims 1 to 5 are implemented.

8. A computer-readable storage medium, characterized in that: A computer program is stored thereon, wherein when the computer program is executed by a processor, the steps of the automated testing method according to any one of claims 1 to 5 are implemented.