A method and device for automated testing
The automated test results are determined through blockchain node execution and consensus algorithms, which solves the reliability of the test results and achieves a more stable and efficient test process.
Patent Information
- Application Number
- CN201911283601.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-12-13
- Publication Date
- 2025-01-14
- Estimated Expiration
- 2039-12-13
AI Technical Summary
The reliability of automated test results is affected by factors such as hardware configuration and network transmission, which leads to unstable test case execution results and reduces the reliability of test results.
Blockchain nodes are used to execute test cases separately, and the test results are determined through the Byzantine fault-tolerant consensus algorithm. The data immutable characteristics of blockchain nodes are used to ensure the accuracy of the test results.
It improves the reliability of automated test results, effectively avoids interference from external factors, and improves the stability and efficiency of test results.
Smart Images

Figure CN111782502B_ABST
Abstract
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] In the modern software development and system performance evaluation process, automated testing has become an indispensable link. The reliability of test results has an important impact on the evaluation of software quality and system performance.
[0003] The test results of automated testing are generally determined based on the execution results of multiple test cases, that is, the execution results of each test case may affect the overall test results of automated testing. However, in the process of automated testing, there are many factors that can affect the execution results of test cases, such as hardware configuration and network transmission. Adverse factors may reduce the reliability of the execution results of test cases, thereby reducing the reliability of automated testing results. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides a method and apparatus for automated testing, which can improve the reliability of automated testing results.
[0005] To achieve the above objective, according to one aspect of an embodiment of the present invention, a method for automated testing is provided.
[0006] An automated testing method according to an embodiment of the present invention includes: receiving a test request, wherein the test request indicates a plurality of test cases for automated testing;
[0007] The blockchain nodes execute the multiple test cases respectively and broadcast the execution results of the test cases;
[0008] A test result of the test request is determined according to the broadcasted execution result.
[0009] Optionally, the multiple test cases are independent of each other;
[0010] The step of determining the test result of the test request according to the broadcasted execution result includes:
[0011] According to the execution results obtained by respectively executing the plurality of test cases by the blockchain nodes, the test result of the test request is determined using a Byzantine fault-tolerant consensus algorithm.
[0012] Optionally, the determining the test result of the test request by using a Byzantine fault-tolerant consensus algorithm includes:
[0013] The blockchain node determines its own corresponding consensus result based on the execution result obtained by itself and the execution results of other blockchain nodes obtained through broadcasting;
[0014] Determine the test result of the test request according to the consensus results respectively corresponding to the blockchain nodes.
[0015] Optionally, the execution result indicates whether the test case is executed successfully or failed;
[0016] The blockchain node determines the number of execution results indicating successful execution or failed execution among the multiple execution results obtained by itself and other blockchain nodes through broadcasting, and takes the execution result with the larger number as the consensus result.
[0017] Optionally, the execution result indicates whether the test case is executed successfully or failed, and determining the test result of the test request according to the broadcasted execution result includes:
[0018] According to the broadcasted execution results, statistics are calculated on the ratio of execution results indicating successful execution to statistical results indicating failed execution. When the ratio is less than a first threshold, the test result is determined to be a test failure. When the ratio is greater than a second threshold, the test result is determined to be a test success. The first threshold is less than or equal to the second threshold.
[0019] Optionally, the multiple test cases have dependencies;
[0020] The blockchain nodes execute the multiple test cases respectively and broadcast the execution results of the test cases, including:
[0021] The blockchain node executes a second test case among the multiple test cases that has a dependency relationship with the first test case based on the execution result of the first test case among the multiple test cases obtained through broadcasting, and broadcasts the execution result of the second test case.
[0022] Optionally, when the execution result of the first test case indicates that the first test case is successfully executed, the second test case is executed according to the successful execution result;
[0023] When the execution result of the first test case indicates that the first test case fails to execute, the second test case is executed according to the test parameters of the first test case pre-stored in the blockchain node.
[0024] To achieve the above objective, according to another aspect of an embodiment of the present invention, an automated testing device is provided.
[0025] An automated testing device according to an embodiment of the present invention comprises: a request receiving module, a use case execution module and a result determination module; wherein:
[0026] The request receiving module is used to receive a test request, wherein the test request indicates a plurality of test cases for automated testing;
[0027] The test case execution module is used to respectively execute the multiple test cases using blockchain nodes and broadcast the execution results of the test cases;
[0028] The result determination module is used to determine the test result of the test requirement according to the broadcasted execution result.
[0029] Optionally, when the multiple test cases are independent of each other, the result determination module is used to determine the test result of the test request using a Byzantine fault-tolerant consensus algorithm based on the execution results obtained by the blockchain node respectively executing the multiple test cases.
[0030] Optionally, when the multiple test cases have a dependency relationship, the case execution module is used to use the blockchain node to obtain the execution result of a first test case among the multiple test cases based on the broadcast, execute a second test case among the multiple test cases that has a dependency relationship with the first test case, and broadcast the execution result of the second test case.
[0031] To achieve the above objective, according to another aspect of an embodiment of the present invention, an electronic device for automated testing is provided.
[0032] An electronic device for automated testing according to an embodiment of the present invention comprises: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement an automated testing method according to an embodiment of the present invention.
[0033] To achieve the above objective, according to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided.
[0034] A computer-readable storage medium according to an embodiment of the present invention stores a computer program, and when the program is executed by a processor, an automated testing method according to an embodiment of the present invention is implemented.
[0035] One embodiment of the above invention has the following advantages or beneficial effects: after receiving a test request indicating multiple test cases, the blockchain node can be used to execute the multiple test cases respectively, and the test results of the test request can be determined based on the execution results of the test cases broadcast by the blockchain node. Since the blockchain node has the characteristic that data cannot be tampered with, it can ensure that the execution results of the test cases will not be tampered with, thereby improving the reliability of the test results.
[0036] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0038] Figure 1 is a schematic diagram of main steps of an automated testing method according to an embodiment of the present invention;
[0039] Figure 2 is a schematic diagram of main steps of another automated testing method according to an embodiment of the present invention;
[0040] Figure 3 is a schematic diagram of main steps of another automated testing method according to an embodiment of the present invention;
[0041] Figure 4 is a schematic diagram of main steps of another automated testing method according to an embodiment of the present invention;
[0042] Figure 5 is a schematic diagram of main modules of an automated testing apparatus according to an embodiment of the present invention;
[0043] Figure 6 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0044] Figure 7 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0045] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0046] It should be pointed out that the embodiments of the present invention and the technical features therein may be combined with each other without conflict.
[0047] Figure 1 It is a schematic diagram of main steps of an automated testing method according to an embodiment of the present invention.
[0048] like Figure 1 As shown, an automated testing method according to an embodiment of the present invention mainly includes the following steps:
[0049] Step S101: receiving a test request, wherein the test request indicates a plurality of test cases for automated testing.
[0050] Step S102: The blockchain nodes execute the multiple test cases respectively and broadcast the execution results of the test cases.
[0051] Step S103: Determine the test result of the test request according to the broadcasted execution result.
[0052] The multiple test cases indicated by the test request may be independent of each other or may have dependencies. When the execution result of any test case has no correlation with the execution results of other test cases among the multiple test cases, it means that the multiple test cases are independent of each other. On the contrary, when the execution result of a test case has correlation with the execution results of other test cases, it means that the multiple test cases have dependencies.
[0053] In one embodiment of the present invention, when multiple test cases are independent of each other, the test result of the test request can be determined using a Byzantine fault-tolerant consensus algorithm based on the execution results obtained by respectively executing the multiple test cases by the blockchain node.
[0054] It is understandable that when the Byzantine consensus algorithm is used to determine the test results, the blockchain nodes that execute the test cases are also nodes in the blockchain network that adopts the Byzantine consensus algorithm. When performing automated testing, the tester sends a test request to the master node of the blockchain node through the client. The master node is pre-agreed by each node in the blockchain network that adopts the Byzantine consensus algorithm. The master node then distributes multiple test cases to other blockchain nodes in the blockchain network, so that multiple blockchain nodes execute multiple test cases respectively.
[0055] After each blockchain node executes multiple test cases respectively, it can obtain the execution results of each test case. The blockchain node that executes the test case first can first write the execution results into the cache area. After each blockchain node has executed the test case, the execution results can be broadcasted by the blockchain node. Each blockchain node can obtain the execution results of other blockchain nodes, and then determine its own corresponding consensus result by combining the execution results obtained by executing its own test case and the execution results of other blockchain nodes obtained through broadcasting. Of course, after executing the test case, each blockchain node can also directly broadcast the test results so that other blockchains can obtain the test results through broadcasting. For example, when the execution result of the blockchain node executing the test case indicates that the test case is executed successfully, the blockchain node broadcasts 1, and when the execution result indicates that the execution fails, the blockchain node broadcasts 0. Then, each blockchain can determine its own corresponding consensus result based on its own execution result and the execution results of other blockchain nodes obtained through broadcasting.
[0056] When determining the consensus result, the blockchain node can use the execution result obtained by itself and the multiple execution results of other blockchain nodes broadcasted, and the number of test cases indicated by the execution result whether the execution is successful or failed, and take the execution result with the larger number as its corresponding consensus result. For example, when there are 4 blockchain nodes (node 0, node 1, node 2 and node 3) in the blockchain network using the Byzantine consensus algorithm, if all 4 blockchain nodes broadcast 1, the data on the execution results obtained by each blockchain node and its corresponding consensus result are shown in Table 1:
[0057] Table 1
[0058]
[0059] As shown in Table 1, when each blockchain node broadcasts 1, the execution result obtained by each blockchain node is 1, and the consensus result of the blockchain node is also 1. The consensus result is sent to the client, and the client can determine that the test result is successful based on the 4 consensus results (1).
[0060] In addition, if the execution result of one of the four blockchain nodes in the blockchain network of the Byzantine consensus algorithm is an execution failure, for example, the execution result of node 3 is an execution failure, then node 3 broadcasts 0, and the remaining blockchain nodes broadcast 1. The data on the execution results obtained by the four blockchain nodes and their corresponding consensus results are shown in Table 2:
[0061] Table 2
[0062]
[0063] As can be seen from Table 2, when one blockchain node broadcasts 0 and the other blockchain nodes broadcast 1, the consensus result of each blockchain node is also 1. The consensus result is sent to the client, and the client can determine that the test result is successful based on the 4 consensus results (1).
[0064] For example, if the execution results of two of the four blockchain nodes in the blockchain network of the Byzantine consensus algorithm are execution failures, for example, the execution results of nodes 3 and 2 are execution failures, then nodes 3 and 2 broadcast 0, and nodes 0 and 1 broadcast 1. The data on the execution results obtained by the four blockchain nodes and their corresponding consensus results are shown in Table 3:
[0065] Table 3
[0066]
[0067] In Table 3, N / A represents an unrecognizable consensus result. As can be seen from Table 3, when two blockchain nodes broadcast 0 and the other two blockchain nodes broadcast 1, the consensus result of each blockchain node is unrecognizable. The consensus result is sent to the client, and the client determines that the test result is a test result that cannot determine success or failure, and can also output the test case corresponding to the blockchain node whose execution result is execution failure, so that the tester can debug the test case and perform automated testing again.
[0068] It is understandable that, in addition to outputting the test case corresponding to the blockchain node with the execution result of execution failure when the test result representation cannot determine success or failure, when the test result is a test failure, and even when the test result is a test success (if there are test cases with the execution result of execution failure), the test case with the execution result of execution failure can be output to facilitate testers to debug these test cases.
[0069] Among them, each blockchain node can correspond to a thread that executes a test case. It can be seen from Tables 1 to 3 that when the test threads correspond to the test cases one by one, that is, when one test thread is used to execute one test case, when the execution result is that the number of test threads that failed to execute f and the total number of test threads p satisfy the following calculation formula (1), the consensus result of each blockchain node can clearly represent the success or failure of the test:
[0070] p>3f+1(f>0)………………(1)
[0071] In the process of automated testing, different test environments, pre-release environments, and production environments are often involved. In each test environment, the hardware configuration of each test machine is different, and the hardware response may also have a certain degree of deviation. In addition, some physical factors may cause a test machine to be abnormal. In the response cycle of the test case, the execution result of the test case may be abnormal due to these external factors (test environment or hardware configuration, etc.). These external factors may cause deviations in the final automated test results. Testers need to execute the test case multiple times to verify these external factors, so as to eliminate the interference of external factors on the automated test results.
[0072] like Figure 2 As shown, the automated testing method provided by the embodiment of the present invention may include the following steps:
[0073] Step S201: receiving a test request, wherein the test request indicates multiple test cases for automated testing, the blockchain node executes the multiple test cases respectively, and broadcasts the execution results of the test cases.
[0074] Step S202: Each blockchain node determines the number of execution results indicating successful execution or failed execution among the multiple execution results obtained by itself and other blockchain nodes through broadcasting, and takes the execution result with the larger number as the consensus result.
[0075] Step S203: Determine the test result of the test request according to the consensus results corresponding to the blockchain nodes respectively.
[0076] In an embodiment of the present invention, the Byzantine fault-tolerant consensus algorithm is used to determine the test results of the automated test, which can effectively avoid the interference of external factors on the test results. For example, the interference factor of the external factor will cause a single test case to have an abnormal result with a probability of x, and the number of multiple test cases used for automated testing is y. Assuming that the success rate of a single test case is r, the success probability of the test case set is R. In the absence of interference, the probability of successful execution of the test case is 100%, that is, the expected result is that all test cases pass, and the success rate of the test result is 1.
[0077] When disturbances exist, in traditional automated testing, the success rate r of each test case can be calculated by formula (2):
[0078] r=(1-x)………………(2)
[0079] In the embodiment of the present invention, when the test result is determined by the Byzantine fault-tolerant consensus algorithm, when the total number of blockchain nodes is p, the number of test cases that failed to execute is f, and p=3f+1 (f>0), the success rate r of each test case can be calculated by formula (3):
[0080]
[0081] After calculating the success rate of each test case, the relationship between the success probability R and r of the test case set is shown in formula (4):
[0082] R=r y ………………………………(4)
[0083] Assuming that the value of x is 0.002, the value of y is 80, the value of p is 4, and the value of f is 1, in the traditional automated test, the success probability r1 of each test case is 0.998, and the success probability R1 of the test case set is 85.2007%; in the embodiment of the present invention, in the Byzantine fault-tolerant consensus network, the success probability r2 of each test case is 0.99997, and the success probability R2 of the test case set is 99.8086%. It can be seen that the R2 result is significantly better than R1, and with the increase of test cases y in the case set and the increase of threads p, in the same test time, when the Byzantine fault-tolerant consensus algorithm is applied to automated testing, it will be significantly better than the traditional automated testing method in eliminating external disturbances, so as to improve the anti-interference ability of external physical factors in the automated testing process, save test resources to a certain extent, improve test efficiency, and thus facilitate the realization of a more efficient automated testing method.
[0084] In addition to using the Byzantine fault-tolerant consensus algorithm to determine the test result of the test request, the test result can also be directly counted according to the execution results broadcast by each blockchain node. Specifically, the ratio of the execution results indicating successful execution to the statistical results indicating failed execution can be counted according to the broadcasted execution results. When the ratio is less than the first threshold, the test result is determined to be a test failure. When the ratio is greater than the second threshold, the test result is determined to be a test success. The first threshold is less than or equal to the second threshold. For example, when there are a total of 100 test cases, there are 80 test cases indicating successful execution and 20 test cases indicating failed execution. The ratio of the execution results indicating successful execution to the statistical results indicating failed execution is 80 / 20. If the second threshold is 3, the test result is a successful test. For another example, when there are a total of 100 test cases, there are 20 test cases indicating failed execution and 80 test cases indicating successful execution. The ratio of the execution results indicating successful execution to the statistical results indicating failed execution is 20 / 80. If the first threshold is 1 / 3, the test result is a test failure. Among them, the first threshold and the second threshold may be equal or unequal. When the first threshold and the second threshold are unequal, the first threshold is smaller than the second threshold. The specific values of the first threshold and the second threshold may be customized according to actual needs.
[0085] Therefore, if Figure 3 As shown, the automated testing method provided by the embodiment of the present invention may include the following steps:
[0086] Step S301: receiving a test request, wherein the test request indicates a plurality of test cases for automated testing.
[0087] Step S302: The blockchain nodes execute the multiple test cases respectively and broadcast the execution results of the test cases.
[0088] Step S303: According to the broadcasted execution results, count the ratio m of the execution results indicating successful execution to the statistical results indicating failed execution. When the ratio m is less than the first threshold a1, execute step S304; when the ratio is greater than the second threshold a2, execute step S305.
[0089] The first threshold is less than or equal to the second threshold. In a preferred embodiment of the present invention, the first threshold is less than the second threshold.
[0090] Step S304: Determine that the test result is a test failure.
[0091] Step S305: Determine that the test result is a successful test.
[0092] In addition, when multiple test cases used for automated testing have dependencies, each blockchain node executes a second test case in the multiple test cases that has a dependency relationship with the first test case based on the broadcasted execution result of the first test case, and broadcasts the execution result of the second test case. The relevance of a test case means that the execution result of the test case is correlated with the execution results of other test cases. For example, if the execution of test case A requires the execution result of test case B, then test case A and test case B have a dependency relationship.
[0093] When the execution result of the first test case indicates that the first test case is executed successfully, the second test case is executed according to the successful execution result; when the execution result of the first test case indicates that the first test case fails to execute, the second test case is executed according to the test parameters of the first test case pre-stored in the blockchain node.
[0094] It is understandable that the execution result of the test case can indicate not only whether the test case is executed successfully or failed, but also the test parameters obtained after executing the test case. Then, when the first blockchain node executes test case B and broadcasts the execution result of test case B, the second blockchain node that executes test case A can first determine whether the execution result of test case B is successful or failed after obtaining the execution result of test case B through broadcasting. When test case B is successfully executed, the second blockchain node can execute test case A according to the test parameters indicated by the execution result of test case B. When the execution result of test case B indicates that it fails to execute, the second blockchain node can use the pre-stored test parameters to execute test case A. Among them, each blockchain node can pre-store the test parameters corresponding to each test case, so that when the test case on which the test case to be executed depends fails to execute, the test case to be executed is executed using the pre-stored test parameters in the blockchain node, thereby ensuring the normal progress of the test case, improving the efficiency of automated testing, and ensuring that the execution results of each test case will not be tampered with, thereby improving the reliability of the test results.
[0095] After each blockchain node has executed the test case, the ratio of successful to failed test cases can be output as the test result, and the identification information of the failed test cases can be output as the test result at the same time, so that the tester can debug the failed test cases according to the test results.
[0096] Therefore, if Figure 4 As shown, an automated testing method provided by an embodiment of the present invention may include the following steps:
[0097] Step S401: receiving a test request, wherein the test request indicates a plurality of test cases for automated testing.
[0098] Step S402: determining the execution order of the multiple test cases according to the dependency relationship of the multiple test cases, executing the first test case in the execution order using the first blockchain, and broadcasting the execution result of the first test case.
[0099] Step S403: The second blockchain node executes steps S404 and S406 based on the execution result obtained through broadcasting, when the execution result indicates successful execution; and executes steps S405 and S406 when the execution result indicates failure.
[0100] Step S404: Execute the second test case according to the successful execution result, and broadcast the execution result of the second test case.
[0101] Step S405: Execute the second test case according to the test parameters of the first test case pre-stored in the blockchain node, and broadcast the execution result of the second test case.
[0102] Step S406: Determine whether there are any unexecuted test cases among the multiple test cases. If yes, execute step S403; otherwise, execute step S407.
[0103] When returning to execute step S403, the second blockchain node obtains the execution result of the second test case through broadcasting, and the second test case in step S404 and step S405 is the next test case that has not been executed after the second test case in the execution order, that is, the test case that is currently being prepared to be executed.
[0104] Step S407: Determine the test result of the test request according to the execution results of the broadcasted multiple test cases.
[0105] It can be seen from an automated testing method according to an embodiment of the present invention that after receiving a test request indicating multiple test cases, the blockchain node can be used to execute the multiple test cases respectively, and the test results of the test request can be determined based on the execution results of the test cases broadcast by the blockchain node. Since the blockchain node has the characteristic that data cannot be tampered with, it can ensure that the execution results of the test cases will not be tampered with, thereby improving the reliability of the test results.
[0106] Figure 5 It is a schematic diagram of main modules of an automated testing device according to an embodiment of the present invention.
[0107] like Figure 5As shown, an automated testing device 500 according to an embodiment of the present invention includes: a request receiving module 501, a use case execution module 502 and a result determination module 503; wherein,
[0108] The request receiving module 501 is used to receive a test request, wherein the test request indicates a plurality of test cases for automated testing;
[0109] The test case execution module 502 is used to respectively execute the multiple test cases using blockchain nodes and broadcast the execution results of the test cases;
[0110] The result determination module 503 is used to determine the test result of the test requirement according to the broadcasted execution result.
[0111] In one embodiment of the present invention, when the multiple test cases are independent of each other, the result determination module 503 is used to determine the test result of the test request using a Byzantine fault-tolerant consensus algorithm based on the execution results obtained by the blockchain node respectively executing the multiple test cases.
[0112] In one embodiment of the present invention, the result determination module 503 is used to determine the consensus result corresponding to itself by using the blockchain node according to the execution result obtained by itself and the execution results of other blockchain nodes obtained through broadcasting; and determine the test result of the test request according to the consensus results corresponding to the blockchain nodes respectively.
[0113] In one embodiment of the present invention, the result determination module 503 is used to use the blockchain node to determine the number of execution results indicating successful execution or failed execution among multiple execution results obtained by itself and other blockchain nodes through broadcasting, and take the execution result with a larger number as the consensus result.
[0114] In one embodiment of the present invention, the result determination module 503 is used to count the ratio of execution results indicating successful execution to statistical results indicating failed execution based on the broadcasted execution results; when the ratio is less than a first threshold, the test result is determined to be a test failure; when the ratio is greater than a second threshold, the test result is determined to be a test success; and the first threshold is less than or equal to the second threshold.
[0115] In one embodiment of the present invention, when the multiple test cases have a dependency relationship, the case execution module 502 is used to use the blockchain node to obtain the execution result of the first test case among the multiple test cases based on the broadcast, execute the second test case among the multiple test cases that has a dependency relationship with the first test case, and broadcast the execution result of the second test case.
[0116] In one embodiment of the present invention, the use case execution module 502 is used to execute the second test case according to the successful execution result when the execution result of the first test case indicates that the first test case is executed successfully; when the execution result of the first test case indicates that the first test case fails to execute, execute the second test case according to the test parameters of the first test case pre-stored in the blockchain node.
[0117] It can be seen from an automated testing device according to an embodiment of the present invention that after receiving a test request indicating multiple test cases, the blockchain node can be used to execute the multiple test cases respectively, and the test results of the test request can be determined based on the execution results of the test cases broadcast by the blockchain node. Since the blockchain node has the characteristic that data cannot be tampered with, it can ensure that the execution results of the test cases will not be tampered with, thereby improving the reliability of the test results.
[0118] An embodiment of the present invention also provides an electronic device for automated testing, which includes: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement an automated testing method of an embodiment of the present invention.
[0119] An embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, an automated testing method of an embodiment of the present invention is implemented.
[0120] Figure 6 An exemplary system architecture 600 is shown to which an automated testing method or an automated testing apparatus according to an embodiment of the present invention may be applied.
[0121] like Figure 6 As shown, system architecture 600 may include terminal devices 601, 602, 603, network 604 and server 605. Network 604 is used to provide a medium for communication links between terminal devices 601, 602, 603 and server 605. Network 604 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0122] The user can use the terminal devices 601, 602, 603 to interact with the server 605 through the network 604 to receive or send messages, etc. Various communication client applications can be installed on the terminal devices 601, 602, 603, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0123] The terminal devices 601 , 602 , and 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.
[0124] The server 605 may be a server that provides various services, such as a backend management server that provides support for shopping websites browsed by users using the terminal devices 601, 602, and 603. The backend management server may analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information and product information) to the terminal device.
[0125] It should be noted that the automated testing method provided in the embodiment of the present invention is generally executed by the server 605 , and accordingly, an automated testing device is generally disposed in the server 605 .
[0126] It should be understood that Figure 6 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.
[0127] Reference below Figure 7 , which shows a schematic diagram of the structure of a computer system 700 of a terminal device suitable for implementing an embodiment of the present invention. Figure 7 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0128] like Figure 7 As shown, the computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0129] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage section 708 as needed.
[0130] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the central processing unit (CPU) 701, the above-mentioned functions defined in the system of the present invention are executed.
[0131] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0132] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0133] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be set in a processor, for example, it may be described as: a processor includes a request receiving module, a use case execution module and a result determination module. The names of these modules do not constitute a limitation on the modules themselves in some cases, for example, the request receiving module may also be described as a "module for receiving test requests".
[0134] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: receiving a test request, the test request indicating multiple test cases for automated testing; the blockchain node executes the multiple test cases respectively, and broadcasts the execution results of the test cases; and determining the test result of the test request according to the broadcasted execution result.
[0135] According to the technical solution of an embodiment of the present invention, after receiving a test request indicating multiple test cases, the blockchain node can be used to execute the multiple test cases respectively, and the test results of the test request can be determined based on the execution results of the test cases broadcast by the blockchain node. Since the blockchain node has the characteristic of data immutability, it can ensure that the execution results of the test cases will not be tampered with, thereby improving the reliability of the test results.
[0136] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for automated testing, characterized in that: include: receiving a test request indicating a plurality of test cases for automated testing; The blockchain nodes execute the multiple test cases respectively and broadcast the execution results of the test cases; Determining a test result of the test request according to the broadcasted execution result; The step of determining the test result of the test request according to the broadcasted execution result includes: The blockchain node determines its own corresponding consensus result based on the execution result obtained by itself and the execution results of other blockchain nodes obtained through broadcasting; Determine the test result of the test request according to the consensus results respectively corresponding to the blockchain nodes; When the test result characterization cannot determine success or failure, or when the test result is a test failure, or there is a test case whose execution result is an execution failure, the test case corresponding to the blockchain node whose execution result is an execution failure is output to facilitate the tester to debug the test case.
2. The method according to claim 1, characterized in that The multiple test cases are independent of each other; The step of determining the test result of the test request according to the broadcasted execution result includes: According to the execution results obtained by respectively executing the plurality of test cases by the blockchain nodes, the test result of the test request is determined using a Byzantine fault-tolerant consensus algorithm.
3. The method according to claim 1, characterized in that The execution result indicates whether the test case is executed successfully or failed; The blockchain node determines the number of execution results indicating successful execution or failed execution among the multiple execution results obtained by itself and other blockchain nodes through broadcasting, and takes the execution result with the larger number as the consensus result.
4. The method according to claim 1, characterized in that: The execution result indicates whether the test case is executed successfully or failed, and determining the test result of the test request according to the broadcasted execution result includes: According to the broadcasted execution results, statistics are calculated on the ratio of execution results indicating successful execution to statistical results indicating failed execution. When the ratio is less than a first threshold, the test result is determined to be a test failure. When the ratio is greater than a second threshold, the test result is determined to be a test success. The first threshold is less than or equal to the second threshold.
5. The method according to claim 1, characterized in that: The multiple test cases have dependencies; The blockchain nodes execute the multiple test cases respectively and broadcast the execution results of the test cases, including: The blockchain node executes a second test case among the multiple test cases that has a dependency relationship with the first test case based on the execution result of the first test case among the multiple test cases obtained through broadcasting, and broadcasts the execution result of the second test case.
6. The method according to claim 5, characterized in that When the execution result of the first test case indicates that the first test case is successfully executed, executing the second test case according to the successful execution result; When the execution result of the first test case indicates that the execution of the first test case fails, the second test case is executed according to the test parameters of the first test case pre-stored in the blockchain node.
7. An automated testing device, characterized in that: include: Request receiving module, use case execution module and result determination module; among them, The request receiving module is used to receive a test request, wherein the test request indicates a plurality of test cases for automated testing; The test case execution module is used to respectively execute the multiple test cases using blockchain nodes and broadcast the execution results of the test cases; The result determination module is used to determine the test result of the test requirement according to the broadcasted execution result; The result determination module is specifically used to determine the consensus result corresponding to the blockchain node according to the execution result obtained by the blockchain node itself and the execution results of other blockchain nodes obtained through broadcasting; determine the test result of the test request according to the consensus results respectively corresponding to the blockchain nodes; The use case output module is used to output the test case corresponding to the blockchain node whose execution result is execution failure when the test result representation cannot determine success or failure, or the test result is test failure, or there is a test case whose execution result is execution failure, so as to facilitate the tester to debug the test case.
8. The device according to claim 7, characterized in that When the multiple test cases are independent of each other, the result determination module is used to determine the test result of the test request using a Byzantine fault-tolerant consensus algorithm based on the execution results obtained by the blockchain node respectively executing the multiple test cases.
9. The device according to claim 7, characterized in that When the multiple test cases have a dependency relationship, the case execution module is used to use the blockchain node to obtain the execution result of a first test case among the multiple test cases based on the broadcast, execute a second test case among the multiple test cases that has a dependency relationship with the first test case, and broadcast the execution result of the second test case.
10. An electronic device for automated testing, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.
11. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Block-chain consensus algorithm test method, device, computing device and storage medium
CN109508295A