Automated testing method and device

Through multi-threaded execution and fault-tolerant consensus mechanism, the accuracy problem of automated testing in complex environments is solved, and login delay is optimized through cookie sharing, achieving more efficient automated testing.

CN113760709BActive Publication Date: 2024-10-18BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011046744.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-29
Publication Date
2024-10-18
Estimated Expiration
2040-09-29

AI Technical Summary

Technical Problem

Existing automated testing solutions are easily affected by hardware configuration differences and interference factors in complex test execution environments, resulting in inaccurate test results.

Method used

Multi-threads are used to execute test cases, and the final execution results are determined through a fault-tolerant consensus mechanism. The local cookie cache pool is used to share cookie information to reduce login delays.

Benefits of technology

It effectively improves the accuracy and efficiency of test results, reduces the impact of external execution environment interference on test results, and optimizes the login process of automated tests.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113760709B_ABST
    Figure CN113760709B_ABST
Patent Text Reader

Abstract

The present application discloses an automated testing method and device, wherein the method comprises: executing each test case in the test plan in sequence according to a preset test order, wherein for each test case, at least two threads are used to independently execute the test case, and all execution results of the test case are subjected to fault-tolerant consensus to obtain the final execution result of the test case. The present invention can improve the accuracy of the test results by introducing multithreading and fault-tolerant consensus technology.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to an automated testing method and device. Background Art

[0002] Automated testing is a process that converts human-driven testing behavior into machine execution. This process can save manpower, time or hardware resources and improve testing efficiency.

[0003] In the process of implementing the present invention, the applicant discovered that the existing automated testing solutions have the problem that the test results are easily affected by the actual test execution environment. After studying and analyzing the existing automated testing solutions, the applicant discovered that the specific reasons for this problem are as follows:

[0004] In the existing automated testing solutions, single-threaded execution is used for each test case in the test plan. In this way, the accuracy of the execution result of each test case depends on the execution of the test case by a single thread. However, the test execution environment of the actual automated testing plan is relatively complex. For example, the automated testing plan of the WEB system often involves different test environments, pre-release environments, and production environments. In each automated testing execution environment, the hardware configuration of each machine is usually different, and the hardware response rate will also have a certain degree of deviation. In this way, during the testing process, some individual machines may not be able to provide a test environment that meets the test requirements in some cases due to some physical factors, resulting in some unexpected performance of the machine when running the test case, which in turn affects the correctness of the test case execution results.

[0005] It can be seen from this that when a test case is executed, if interference factors occur in the execution environment, it will directly affect the normal operation of the corresponding thread, which will inevitably lead to deviations in the test results of the test case, and further affect the accuracy of the final test results of the entire test plan. Summary of the invention

[0006] In view of this, the main purpose of the embodiments of the present invention is to provide an automated testing method and device, which can improve the accuracy of test results.

[0007] In order to achieve the above object, the technical solution proposed in the embodiment of the present invention is:

[0008] An automated testing method, comprising:

[0009] Execute each test case in the test plan in sequence according to the preset test order; wherein, for each test case, use at least two threads to independently execute the test case, and perform fault-tolerant consensus on all execution results of the test case to obtain the final execution result of the test case;

[0010] Based on all the final execution results, a test report is generated.

[0011] Preferably, the performing of a fault-tolerant consensus on all execution results of the test case to obtain the final execution result of the test case includes:

[0012] Calculate n success The ratio of n to n, where n success is the number of threads that successfully executed the current test case; N is the number of threads that executed the current test case;

[0013] If the ratio is greater than or equal to a preset fault tolerance coefficient, the final execution result of the current test case is determined to be successful; otherwise, the final execution result of the current test case is determined to be a failure.

[0014] Preferably, the method further comprises:

[0015] During the execution of the test case, when it is necessary to obtain Cookie information for logging into the system for the test account, it is determined whether there is corresponding valid Cookie information in the local Cookie cache pool. If so, the valid Cookie information is obtained from the local Cookie cache pool. Otherwise, the scheduler is used to perform the corresponding automatic login. After the login is successful, the Cookie information obtained by this login is saved in the local Cookie cache pool.

[0016] Preferably, the step of sequentially executing each test case in the test plan according to a preset test sequence includes:

[0017] a. According to the test sequence, take out an unexecuted test case from the test case set of the to-be-tested plan as the current working test case;

[0018] b. Use at least two threads to independently execute the current working test case;

[0019] c. Obtain the execution result of each thread on the working test case, and generate an execution result set of the working test case;

[0020] d. Write the execution result set into the current fault-tolerant consensus processing buffer to trigger fault-tolerant consensus on the execution results in the execution result set to obtain the final execution result of the working test case; at the same time, determine whether there are unexecuted test cases in the test case set. If so, return to step a.

[0021] An automated testing device, comprising:

[0022] An execution module is used to execute each test case in the test plan in sequence according to a preset test order; wherein, for each test case, at least two threads are used to independently execute the test case, and all execution results of the test case are subjected to fault-tolerant consensus to obtain the final execution result of the test case;

[0023] The test report generation module is used to generate and output a test report based on all the final execution results.

[0024] Preferably, the execution module is specifically used to perform fault-tolerant consensus on all execution results of the test case, including:

[0025] Calculate n success The ratio of n to n, where n success is the number of threads that successfully executed the current test case; N is the number of threads that executed the current test case;

[0026] If the ratio is greater than or equal to a preset fault tolerance coefficient, the final execution result of the current test case is success; otherwise, the final execution result of the current test case is failure.

[0027] Preferably, the execution module is further used for:

[0028] During the execution of the test case, when it is necessary to obtain Cookie information for logging into the system for the test account, it is determined whether there is corresponding valid Cookie information in the local Cookie cache pool. If so, the valid Cookie information is obtained from the local Cookie cache pool. Otherwise, the scheduler is used to perform the corresponding automatic login. After the login is successful, the Cookie information obtained by this login is saved in the local Cookie cache pool.

[0029] Preferably, the execution module is specifically used to sequentially execute each test case in the test plan according to a preset test sequence, including:

[0030] a. According to the test sequence, take out an unexecuted test case from the test case set of the to-be-tested plan as the current working test case;

[0031] b. Use at least two threads to independently execute the current working test case;

[0032] c. Obtain the execution result of each thread on the working test case, and generate an execution result set of the working test case;

[0033] d. Write the execution result set into the current fault-tolerant consensus processing buffer to trigger fault-tolerant consensus on the execution results in the execution result set to obtain the final execution result of the working test case; at the same time, determine whether there are unexecuted test cases in the test case set. If so, return to step a.

[0034] The embodiment of the present invention further discloses a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores instructions, and when the instructions are executed by a processor, the processor executes the steps of the automated testing method as described above.

[0035] An embodiment of the present invention further discloses an electronic device, comprising the non-volatile computer-readable storage medium as described above, and the processor capable of accessing the non-volatile computer-readable storage medium.

[0036] It can be seen from the above technical scheme that in the test process of the embodiment of the present invention, when executing each test case, it is necessary to use at least two threads to execute the test case separately, and determine the final execution result of the test case by performing fault-tolerant consensus on the execution results of each thread. In this way, the accuracy of the execution result of each test case no longer depends on the execution of the test case by a certain thread, but needs to consider the execution of the test case by multiple threads. In actual applications, the test execution environment corresponding to different threads will be different, and the test performance of a certain device in the execution environment will not affect the execution results of all threads. In this way, the interference factors in the test execution environment can usually only affect the normal execution of individual threads, and in the above scheme, the final execution result of the test case is obtained based on the fault-tolerant consensus on the execution results of all threads, so that the erroneous execution results of individual threads can be effectively shielded. Therefore, by adopting the embodiment of the present invention, the influence of the interference factors of the external execution environment on the accuracy of the test case execution results can be effectively reduced, thereby effectively improving the accuracy of the test results. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 A schematic diagram of the automated testing method flow in an embodiment of the present invention;

[0038] Figure 2 for Figure 1 A schematic diagram of an implementation of step 101;

[0039] Figure 3 Schematic diagram of the structure of an automated testing device according to an embodiment of the present invention.

[0040] Figure 4 The figure is a schematic diagram of the structure of the automated testing equipment according to an embodiment of the present invention. DETAILED DESCRIPTION

[0041] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0042] Figure 1 FIG. 1 is a flow chart of an automated testing method according to an embodiment of the present invention. Figure 1 As shown, the automated testing method implemented in this embodiment mainly includes:

[0043] Step 101, execute each test case in the test plan in sequence according to a preset test order; wherein, for each test case, use at least two threads to independently execute the test case, and perform fault-tolerant consensus on all execution results of the test case to obtain the final execution result of the test case.

[0044] In this step, for each test case in the test plan, since at least two threads are executed independently, multiple execution results of the test case can be obtained.

[0045] In actual applications, different threads have different test execution environments. For example, when a Web access operation is executed using multiple threads, it will connect to different servers. In this way, if a server device has interference factors, it will not affect the normal operation of all threads. Therefore, the test performance of a device in the execution environment will not affect the execution results of all threads.

[0046] Since the interference factors in the test execution environment usually affect the execution of individual threads, the consensus on multiple execution results can be used to eliminate the execution results affected by environmental interference factors (such as environmental instability, network delays, external noise, etc.), thereby greatly improving the accuracy of the final execution results of the test case, and then improving the accuracy of the test results of the entire test plan.

[0047] In order to facilitate a clearer understanding of the present application, it should be noted that in the field of testing technology, test steps with an associated relationship are usually combined into a test case, and a test plan will contain multiple test cases, that is, the test plan is a collection of test cases. Each test case in the test case set is relatively independent (that is, the execution results between each test case do not affect each other). A test case is a collection of test step combinations, and each test case is combined by at least one "step", that is, a test case may contain only one step (such as querying a result once), or may contain multiple steps to be executed continuously (such as creating an activity, querying this activity, and then deleting this activity). Each step is the smallest split unit of automated testing, and each step has an assertion (Assert), which is used to judge the success or failure of a step. For Web applications, each request is to obtain a server resource once through methods such as Get / Post / Put / Delete in HTTP requests, and each request is a step.

[0048] In one embodiment, for each test case, each thread can execute the test case synchronously. After each thread completes execution, the execution result set consisting of the execution results of all threads on the test case is added to the current fault-tolerant consensus processing buffer to wait for fault-tolerant consensus processing of all execution results of the test case. At the same time, the next test case is taken out to continue to execute synchronously using multiple threads. In this way, by using multiple threads to synchronously execute the same test case, and while executing the test case, fault-tolerant consensus processing is performed on the execution results of the completed test case, the test accuracy can be improved while improving the test efficiency. Specifically, if Figure 2 As shown, the following steps can be used to implement the above-mentioned execution of each test case in the test plan in sequence according to the preset test sequence:

[0049] Steps 1011-1012, load the test case set of the plan to be tested, and according to the test sequence, take out an unexecuted test case from the test case set of the plan to be tested as the current working test case.

[0050] Step 1013: Utilize at least two threads to independently execute the current working test case;

[0051] Step 1014: Obtain the execution result of each thread on the working test case, and generate an execution result set of the working test case;

[0052] Steps 1015-1017, write the execution result set into the current fault-tolerant consensus processing buffer to trigger fault-tolerant consensus on the execution results in the execution result set to obtain the final execution result of the working test case; at the same time, determine whether there are unexecuted test cases in the test case set, if so, return to step 1012, otherwise, execute step 102.

[0053] In one implementation, the following method may be used to perform a fault-tolerant consensus on all execution results of the test case to obtain the final execution result of the test case:

[0054] Calculate n success The ratio of success is the number of threads that successfully executed the current test case; N is the number of threads that executed the current test case;

[0055] If the ratio is greater than or equal to a preset fault tolerance coefficient, the final execution result of the current test case is success; otherwise, the final execution result of the current test case is failure.

[0056] The above fault-tolerant consensus method can be used to effectively screen the impact of environmental interference on test results.

[0057] The fault tolerance coefficient is less than or equal to 1, and a suitable value may be set by those skilled in the art according to actual needs, for example, it may be greater than 50%, 60%, 70%, 80% or a larger value.

[0058] In actual applications, the number of threads used when executing each test case can be set by technical personnel in this field according to actual needs. The larger the number of threads, the stronger the interference shielding ability, but the greater the processing overhead. Conversely, the smaller the number of threads, the weaker the interference shielding ability, but the smaller the processing overhead.

[0059] Step 102: Generate a test report based on all the final execution results.

[0060] In this step, a test report is generated according to the final execution results of all test cases obtained in step 101. Since step 101 can improve the accuracy of the final execution result of each test case, the test report generated in this step also has high accuracy.

[0061] In actual applications, when the test plan is a test plan for Web applications, the inventor found that for large-scale Web systems, the existing automated testing solutions have the problem of long system login delays. The specific reasons are: there are many types of users in large-scale Web systems, which will involve different user role permissions. Taking the WEB system of e-commerce as an example, users can be divided into buyers, sellers, internal operation personnel, etc., among which buyers can be divided into members, non-members, new customers, returning customers, etc.; sellers can also be divided into various types of sellers according to their different permissions. Obviously, if automated testing is performed, different scenarios need to be covered, and different login permissions need to be involved. The prior art generally uses automated login to divide different account permissions, and the existing automated login solution is interface (UI) automated login. This automated login method requires other operations besides HTTP requests such as screen copying. These other operations will cause the automated login to take a long time, ranging from about 5 to 15 seconds, while an HTTP request often only takes tens of milliseconds. Moreover, in complex automation scenarios, multiple different account permission checks are often required. Thus, if a large number of login steps are required in an automated test, the use of existing automated login methods will significantly increase the execution time of the automated test, and if the automated login fails, the execution of the test case will be directly blocked, thereby reducing the efficiency of the automated test. To address this problem, on the basis of using the above method embodiment to perform automated testing using multiple threads, a method of sharing cookies can be further used to complete the switching of account permissions. Specifically, the following method can be used to achieve this purpose:

[0062] Furthermore, in one embodiment, during the execution of the test case in the above step 101, when it is necessary to obtain cookie information for logging into the system for the test account, it is determined whether there is corresponding valid cookie information in the local cookie cache pool. If so, the valid cookie information is obtained from the local cookie cache pool. Otherwise, the corresponding automatic login is performed using the scheduler. After the login is successful, the cookie information obtained for this login is saved in the local cookie cache pool.

[0063] It should be noted that Cookie is a string of information stored on the client. The information is used to locate the session on the server to determine the login status, so Cookie information has an expiration date.

[0064] Using the above method, when it is necessary to obtain login cookie information, cookie data will be obtained from the cache first. In this way, multiple threads executing the same test case can use the local cookie cache pool to share local cookie information. Similarly, during the validity period of the cookie, different test plans can also use the local cookie cache pool to share local cookie information. In this way, in test scenarios that require frequent account switching, the number of times the system is logged in to obtain cookie data can be greatly reduced.

[0065] For example, if account A tries to obtain the login cookie for the first time, since there is no cookie data in the cache, the scheduler (i.e., remote automation execution machine), such as Jenkins, will perform automated login. After the login is successful, the cookie will be cached (such as stored in Redis) and a timeout will be set. When the cookie information of account A is obtained again, there are three possibilities:

[0066] 1. The cookie does not exist locally, triggering the return-to-source logic and executing the automated login again.

[0067] 2. The cookie exists locally, but it is actually invalid. When the cookie verification fails, the return-to-source logic will be triggered and the automatic login will be performed again.

[0068] 3. If the cookie exists and is valid, you can directly return the previously stored cookie information.

[0069] It should be noted that the above method takes into account that in the automated testing solution of multi-account scenarios, a test account is generally used, that is, an "internal account" with the same permissions as the real account. Since the test account is used by internal personnel, the risk requirements for account permissions are relatively low. Therefore, in the test scenario, the above-mentioned shared cookie method can be used to quickly complete the switching of account permissions, thereby greatly reducing the number of times the system logs in to obtain cookie information and avoiding lengthy login links. Therefore, the efficiency of HTTP testing can be greatly improved.

[0070] The following further illustrates the technical effect that can be obtained by the embodiment of the present invention by comparing the automated testing method of the embodiment of the present invention with the traditional method.

[0071] 1. Comparison of multi-threaded automated testing:

[0072] In traditional automated testing methods, a single thread is used to execute automated test cases.

[0073] Assume that in an automated test plan, all the included HTTP interfaces meet the test requirements, that is, the results of all test steps meet expectations. A perturbation factor will cause each step to have an abnormal result with a probability of x. For ease of calculation, assume that each test case contains m steps and the number of test cases in the automated test is y.

[0074] Obviously, if there is no disturbance in the execution environment, the success probability of executing the test case set of the entire test plan is 100%, that is, the expected result is that all test cases pass.

[0075] The success rate of a single step is a, the success rate of a single test case is r, and the probability of the entire automated test passing completely is R.

[0076] When there is a disturbance, the calculation formula for the success rate a1 of a single step in traditional automated testing and the success rate a2 of a single step in fault-tolerant automated testing is:

[0077] a1=(1-x)

[0078] a2=(1-x)

[0079] Obviously, when all steps in a test case succeed, the test case is executed successfully, otherwise the test case fails.

[0080] When there is a disturbance, the calculation formula for the success rate r1 of a single test case in traditional automated testing is:

[0081] r1=a1 m =(1-x) m

[0082] Using multi-threaded fault-tolerant consensus, the probability of the use case's eventual consistency success satisfies the binomial distribution.

[0083] The number of threads is p, the fault tolerance coefficient is ε, the tolerable number of failed nodes is: f = [p*(1-ε)], and the calculation formula for the success rate r2 of a single use case in automated testing is:

[0084]

[0085] Since each automated test case is relatively independent, the relationship between the probability R of automated test passing and the success r of each case is:

[0086] R=r y

[0087] Therefore, the success probability of traditional automated testing is R1:

[0088] R1=(1-x) m·y

[0089] Therefore, the success probability of multi-threaded fault-tolerant automated testing is R2:

[0090]

[0091] Assume that the value of x is 0.002, the value of m is 1, the value of y is 80, the value of p is 4, and the value of f is 1.

[0092] According to the formula calculation, the success probability r1 of a single case in traditional automated testing is 0.998, and the success probability R1 of a test case set is 85.2007%; the success probability r2 of a single case in fault-tolerant automated testing is 0.99997, and the success probability R2 of a test case set is 99.8086%.

[0093] It can be seen from the above data results that the R2 result is better than the R1 result, and with the increase of test cases y in the test case set and the increase of threads p, in the same test time, the automated testing method of the embodiment of the present invention will be significantly better than the traditional automated testing method in eliminating external disturbances.

[0094] 2. Comparison of Cookie Information Sharing Automated Testing:

[0095] Assume that there are m threads and n accounts in an automated test plan. Each login takes p seconds. During the execution of an automated test, the login part takes a total of:

[0096] S=m*n*p

[0097] Traditional automated login methods take about 10 seconds

[0098] By sharing the cookie method, because the cache data is read, the cookie is obtained in milliseconds (assuming 50ms)

[0099] Assume m = 1 (i.e., conventional single-threaded test scenario), n = 10p = 10,

[0100] The traditional automated login method takes 100 seconds, while the shared cookie login method takes 0.5 seconds.

[0101] In some automated testing scenarios, the execution time of all HTTP automated test cases is only a few seconds. However, if there are multiple automated logins, the execution time of the automated test will be significantly extended.

[0102] The automated login strategy involved in this article can greatly reduce the duration of the login part during the automated test execution process, thereby reducing time costs and improving execution speed. In multi-threaded scenarios, the effect is more obvious, and it is well combined with the multi-threaded fault-tolerant automated testing part described later to improve the efficiency of HTTP interface testing.

[0103] In summary, the automated testing method implemented in the embodiment of the present invention uses a multi-threaded method to execute HTTP test cases, and uses fault-tolerant consensus to finally determine the execution results of multi-threaded HTTP tests, which can effectively shield the interference of the execution environment and improve the efficiency of automated testing. In addition, in the login scenario commonly used in HTTP automated testing, the Cookie sharing strategy is used for optimization, which greatly reduces the execution time of automated testing on the login side, which not only reduces the overall automated testing time, but also avoids the problems of unstable use case execution and redundant use case processes that may exist in multiple automated logins.

[0104] Corresponding to the above method embodiment, the present application also provides an automated testing device, such as Figure 2 Shown include:

[0105] The execution module 301 is used to execute each test case in the test plan in sequence according to a preset test order; wherein, for each test case, at least two threads are used to independently execute the test case, and all execution results of the test case are subjected to fault-tolerant consensus to obtain the final execution result of the test case;

[0106] The test report generating module 302 is used to generate and output a test report according to all the final execution results.

[0107] Preferably, the execution module 301 is specifically used to perform fault-tolerant consensus on all execution results of the test case, including:

[0108] Calculate n success The ratio of success is the number of threads that successfully executed the current test case; N is the number of threads that executed the current test case;

[0109] If the ratio is greater than or equal to a preset fault tolerance coefficient, the final execution result of the current test case is success; otherwise, the final execution result of the current test case is failure.

[0110] Preferably, the execution module 301 is further used for:

[0111] During the execution of the test case, when it is necessary to obtain Cookie information for logging into the system for the test account, it is determined whether there is corresponding valid Cookie information in the local Cookie cache pool. If so, the valid Cookie information is obtained from the local Cookie cache pool. Otherwise, the corresponding automatic login is performed using the scheduler. After the login is successful, the Cookie information obtained by this login is saved in the local Cookie cache pool.

[0112] Preferably, the execution module 301 is specifically used to sequentially execute each test case in the test plan according to a preset test sequence, including:

[0113] a. According to the test sequence, take out an unexecuted test case from the test case set of the to-be-tested plan as the current working test case;

[0114] b. Use at least two threads to independently execute the current working test case;

[0115] c. Obtain the execution result of each thread on the working test case, and generate an execution result set of the working test case;

[0116] d. Write the execution result set into the current fault-tolerant consensus processing buffer to trigger fault-tolerant consensus on the execution results in the execution result set to obtain the final execution result of the working test case; at the same time, determine whether there are unexecuted test cases in the test case set. If so, return to step a.

[0117] The present application also discloses an automated testing device, Figure 4 This is a structural diagram of the automated testing equipment according to the present invention. Figure 4 As shown, the automated testing device includes: a processor 401 and a memory 402; wherein the memory 402 stores an application program executable by the processor 401, which is used to enable the processor 401 to execute any of the automated testing methods described above.

[0118] The memory 402 may be implemented as various storage media such as an electrically erasable programmable read-only memory (EEPROM), a flash memory (Flash memory), a programmable program read-only memory (PROM), etc. The processor 401 may be implemented as including one or more central processing units or one or more field programmable gate arrays, wherein the field programmable gate array integrates one or more central processing unit cores. Specifically, the central processing unit or the central processing unit core may be implemented as a CPU or an MCU.

[0119] It should be noted that not all steps and modules in the above processes and structure diagrams are necessary, and some steps or modules can be ignored according to actual needs. The execution order of each step is not fixed and can be adjusted as needed. The division of each module is only for the convenience of describing the functional division adopted. In actual implementation, a module can be implemented by multiple modules, and the functions of multiple modules can also be implemented by the same module. These modules can be located in the same device or in different devices.

[0120] The hardware modules in each embodiment can be implemented mechanically or electronically. For example, a hardware module may include a specially designed permanent circuit or logic device (such as a dedicated processor, such as an FPGA or ASIC) for performing a specific operation. The hardware module may also include a programmable logic device or circuit (such as a general-purpose processor or other programmable processor) temporarily configured by software to perform a specific operation. As for whether to implement the hardware module mechanically, or using a dedicated permanent circuit, or using a temporarily configured circuit (such as configured by software), it can be decided based on cost and time considerations.

[0121] The present invention also provides a machine-readable storage medium, storing instructions for a machine to perform a method as described in the present application. Specifically, a system or device equipped with a storage medium can be provided, on which a software program code for realizing the functions of any of the embodiments described in the above embodiments is stored, and the computer (or CPU or MPU) of the system or device reads out and executes the program code stored in the storage medium. In addition, the operating system etc. operated on the computer can also be made to complete part or all of the actual operations by instructions based on the program code. The program code read out from the storage medium can also be written to a memory provided in an expansion board inserted into the computer or to a memory provided in an expansion unit connected to the computer, and then the CPU etc. installed on the expansion board or expansion unit can be made to perform part and all of the actual operations based on the instructions of the program code, thereby realizing the functions of any of the embodiments described in the above embodiments.

[0122] Storage media implementations for providing program code include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), magnetic tapes, non-volatile memory cards, and ROMs. Optionally, program code can be downloaded from a server computer or cloud via a communication network.

[0123] In this article, "schematic" means "serving as an example, instance or explanation", and any diagram or implementation method described as "schematic" in this article should not be interpreted as a more preferred or more advantageous technical solution. In order to make the drawings concise, only the parts related to the present invention are schematically shown in each figure, and do not represent the actual structure of the product. In addition, in order to make the drawings concise and easy to understand, in some figures, only one of the parts with the same structure or function is schematically drawn, or only one of them is marked. In this article, "one" does not mean that the number of the relevant parts of the present invention is limited to "only one", and "one" does not mean that the number of the relevant parts of the present invention is "more than one". In this article, "upper", "lower", "front", "back", "left", "right", "inside", "outside", etc. are only used to indicate the relative position relationship between the relevant parts, rather than to limit the absolute position of these relevant parts.

[0124] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. An automated testing method, characterized in that: include: Execute each test case in the test plan in sequence according to the preset test order; wherein, for each test case, use at least two threads to independently execute the test case, and perform fault-tolerant consensus on all execution results of the test case to obtain the final execution result of the test case; Generate a test report based on all the final execution results; The fault-tolerant consensus of all execution results of the test case to obtain the final execution result of the test case includes: Calculate n success The ratio of n to n, where n success is the number of threads that successfully executed the current test case; N is the number of threads that executed the current test case; If the ratio is greater than or equal to the preset fault tolerance coefficient, the final execution result of the current test case is determined to be successful; otherwise, the final execution result of the current test case is determined to be a failure; Among them, in the presence of disturbances, the success rate r2 of the fault-tolerant automated test for each test case is calculated as follows: r1=a1 m =(1-x) m Among them, the success rate of a single case in traditional automated testing is r1, and the success rate of a single step is a1; Each test case contains m steps, and each step has a probability x of abnormal results; The number of threads is p, the fault tolerance coefficient is ε, and the number of failed nodes is n; The tolerable number of failed nodes is f = [p*(1-ε)].

2. The method according to claim 1, characterized in that The method further comprises: During the execution of the test case, when it is necessary to obtain Cookie information for logging into the system for the test account, it is determined whether there is corresponding valid Cookie information in the local Cookie cache pool. If so, the valid Cookie information is obtained from the local Cookie cache pool. Otherwise, the corresponding automatic login is performed using the scheduler. After the login is successful, the Cookie information obtained by this login is saved in the local Cookie cache pool.

3. The method according to claim 1, characterized in that The step of executing each test case in the test plan in sequence according to the preset test sequence includes: a. According to the test sequence, take out an unexecuted test case from the test case set of the to-be-tested plan as the current working test case; b. Use at least two threads to independently execute the current working test case; c. Obtain the execution result of each thread on the working test case, and generate an execution result set of the working test case; d. Write the execution result set into the current fault-tolerant consensus processing buffer to trigger fault-tolerant consensus on the execution results in the execution result set to obtain the final execution result of the working test case; at the same time, determine whether there are unexecuted test cases in the test case set. If so, return to step a.

4. An automated testing device, characterized in that: include: An execution module is used to execute each test case in the test plan in sequence according to a preset test order; wherein, for each test case, at least two threads are used to independently execute the test case, and all execution results of the test case are subjected to fault-tolerant consensus to obtain the final execution result of the test case; A test report generation module, used to generate and output a test report based on all the final execution results; Specifically, the execution module is specifically used to perform fault-tolerant consensus on all execution results of the test case, including: Calculate n success The ratio of n to n, where n success is the number of threads that successfully executed the current test case; N is the number of threads that executed the current test case; If the ratio is greater than or equal to the preset fault tolerance coefficient, the final execution result of the current test case is success, otherwise, the final execution result of the current test case is failure; Among them, in the presence of disturbances, the success rate r2 of the fault-tolerant automated test for each test case is calculated as follows: r1=a1 m =(1-x) m Among them, the success rate of a single case in traditional automated testing is r1, and the success rate of a single step is a1; Each test case contains m steps, and each step has a probability x of abnormal results; The number of threads is p, the fault tolerance coefficient is ε, and the number of failed nodes is n; The tolerable number of failed nodes is f = [p*(1-ε)].

5. The device according to claim 4, characterized in that The execution module is further used for: During the execution of the test case, when it is necessary to obtain Cookie information for logging into the system for the test account, it is determined whether there is corresponding valid Cookie information in the local Cookie cache pool. If so, the valid Cookie information is obtained from the local Cookie cache pool. Otherwise, the corresponding automatic login is performed using the scheduler. After the login is successful, the Cookie information obtained by this login is saved in the local Cookie cache pool.

6. The device according to claim 4, characterized in that The execution module is specifically used to execute each test case in the test plan in sequence according to a preset test sequence, including: a. According to the test sequence, take out an unexecuted test case from the test case set of the to-be-tested plan as the current working test case; b. Use at least two threads to independently execute the current working test case; c. Obtain the execution result of each thread on the working test case, and generate an execution result set of the working test case; d. Write the execution result set into the current fault-tolerant consensus processing buffer to trigger fault-tolerant consensus on the execution results in the execution result set to obtain the final execution result of the working test case; at the same time, determine whether there are unexecuted test cases in the test case set. If so, return to step a.

7. A non-volatile computer-readable storage medium storing instructions, characterized in that: When the instructions are executed by a processor, the processor is caused to perform the steps of the automated testing method according to any one of claims 1 to 3.

8. An electronic device, characterized in that: The invention comprises the non-volatile computer-readable storage medium as claimed in claim 7, and the processor capable of accessing the non-volatile computer-readable storage medium.

Citation Information

Patent Citations

  • Unit performance testing method and device

    CN107153601A

  • User login control method, smart television and storage device

    CN108282485A