Method and System for Simulating Operation of Visual Interface of Operating System Based on Probability Model
By building a directed graph warehouse and using probabilistic models to simulate user operations, the inefficiency of operating system software testing is solved, unattended automated testing is realized, covering more operation combinations, and testing efficiency is improved.
Patent Information
- Application Number
- CN202111678758.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-31
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2041-12-31
AI Technical Summary
In the prior art, operating system software testing requires manual operation, time-consuming and labor-intensive, difficult to cover abnormal operation steps, and the bugs in unconscious operations are seriously ignored, resulting in inefficient testing.
Using a method based on probability model, a directed graph warehouse is built by collecting user operation steps, randomly selecting the root node, finding the next node in turn, simulating user operations, and realizing unattended automated testing.
Unattended automated testing is realized, covering more operation combinations, improving testing efficiency, ensuring coverage of abnormal operations, and reducing the time and manpower investment of human testing.
Smart Images

Figure CN114416539B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the software testing technology of operating systems, and more particularly to a method and system for simulating operations on a visual interface of an operating system based on a probability model. Background Art
[0002] Currently, in the software testing of operating systems, the testing of software or web pages requires manual and conscious testing. It requires people to stay in front of the computer for a long time, or consciously write automated test scripts using code to complete several specific tests, which is time-consuming and laborious. The logic of testing is to test the operation steps for the existing designed functions, and it is very difficult to write test cases for the non-designed operation steps. Because the operation steps other than the designed ones are relatively divergent and cannot converge, it is difficult to fully cover the test cases for the abnormal operation steps. Moreover, most bugs occur due to some unconscious and aimless operations. Since the normal operations receive special attention from developers, while the abnormal operations are usually ignored, the abnormal operations are the areas where bugs are most likely to occur. The normal use of software and the testing of web page programs require a large amount of time investment from people. The use testing of a software within a certain period of time is relatively limited. If all parts of the software need to be tested, it will require a large amount of time and a large number of personnel. Summary of the Invention
[0003] The technical problem to be solved by the present invention is: in view of the above problems of the prior art, to provide a method and system for simulating operations on a visual interface of an operating system based on a probability model. The present invention can deduce approximate user operations and possible operation combinations, simulate human manual operations, continuously apply pressure to the server when unattended, restore all real user operations, and achieve unattended automated random testing of graphical software and web pages.
[0004] To solve the above technical problems, the technical solution adopted by the present invention is as follows:
[0005] A method for simulating operations on a visual interface of an operating system based on a probability model, comprising:
[0006] 1) Collect in advance the operation steps of a user on the visual interface of the operating system when performing a test task. Each test operation of the user is regarded as a node, and the order between test operations is regarded as the edge between nodes. A directed graph is constructed for each test task, and a directed graph repository containing multiple test tasks is generated;
[0007] 2) Randomly select a root node of a directed graph in the directed graph repository according to the occurrence probability of the test task;
[0008] 3) Starting from the selected root node, sequentially search for the next node that has an edge with the current node in the directed graph repository based on a preset probability model or sequentially search for the next node in the same directed graph. If a node that meets the requirements is found, execute the test operation corresponding to that node to simulate the test operation on the visual interface of the operating system. If no node that meets the requirements is found, return to step 2) or exit.
[0009] Optionally, each test operation of the user in step 1) is a mouse operation, a keyboard operation, or a command-line operation.
[0010] Optionally, when generating a corresponding directed graph for each group of test tasks in step 1), the attributes of each node in the directed graph include the timestamp, operation type, and operation content of the test operation corresponding to that node.
[0011] Optionally, when generating a directed graph repository containing multiple test tasks in step 1), it further includes: for multiple directed graphs containing the same node, using this same node as the reference node, dividing the corresponding directed graphs into a set of precursor nodes before the reference node and a set of successor nodes after the reference node respectively, and then pairwise combining and splicing the sets of precursor nodes and successor nodes of multiple directed graphs containing the same node to obtain a directed graph representing the generated test tasks.
[0012] Optionally, when generating a directed graph repository containing multiple test tasks in step 1), it further includes: for multiple directed graphs containing the same node, using this same node as the reference node, dividing the corresponding directed graphs into a set of precursor nodes before the reference node and a set of successor nodes after the reference node respectively, shuffling the set of successor nodes to obtain multiple new sets of successor nodes, and then pairwise combining and splicing the sets of precursor nodes and the new sets of successor nodes of multiple directed graphs containing the same node to obtain a directed graph representing the generated test tasks.
[0013] Optionally, the shuffling of the set of successor nodes to obtain multiple new sets of successor nodes includes:
[0014] S1) Convert the sets of precursor nodes and successor nodes of multiple directed graphs containing the same node into two-dimensional matrices respectively. The first element of each row in the two-dimensional matrix is the test operation, and the subsequent elements are empty, and the row number corresponds to the order of the first element in the set of subsequent test operations.
[0015] S2) For multiple directed graphs containing the same nodes, generate a new random matrix from the two-dimensional matrix corresponding to the set of predecessor nodes and the two-dimensional matrix corresponding to the set of successor nodes of each directed graph through the restricted Boltzmann machine model RBM, and convert the random matrix into a new set of successor nodes; the functional expression for the restricted Boltzmann machine model RBM to generate a new random matrix is:
[0016]
[0017] In the above formula, E(v, h) represents the restricted Boltzmann machine model, both v and v i are two-dimensional matrices corresponding to the set of predecessor nodes of the same node i, h is the two-dimensional matrix corresponding to the set of successor nodes, W i,j is the preset probability model from the same node i to the next node j, and h j is the newly generated random matrix.
[0018] Optionally, when selecting the root node of a directed graph in the directed graph repository according to the occurrence probability of the test task in step 2), the probability of each root node of the directed graph being selected is the number of occurrences of the directed graph in the directed graph repository divided by the total number of occurrences of the directed graphs in the directed graph repository.
[0019] Optionally, the functional expression of the preset probability model in step 3) is:
[0020] Q x = ∏ i Q(x i |Q ag (x i ))
[0021] In the above formula, Q x represents the probability that node x is selected, x i represents the i-th parent node of node x, and when i takes the lower boundary, the i-th parent node is node x itself, and when i takes the upper boundary, the i-th parent node is the root node in the directed graph where node x has the most parent nodes, Q ag (x i ) represents the parent node of node x i , and Q(x i |Q ag (x i )) represents the probability of node x i relative to the parent node Q ag (x i ).
[0022] In addition, the present invention also provides an operating system visualization interface operation simulation system based on a probability model, including a microprocessor and a memory connected to each other, and the microprocessor is programmed or configured to execute the steps of the operating system visualization interface operation simulation method based on the probability model.
[0023] In addition, the present invention also provides a computer-readable storage medium, in which a computer program is stored, and the computer program is used to be executed by a computer device to implement the steps of the operating system visualization interface operation simulation method based on the probability model.
[0024] Compared with the prior art, the present invention mainly has the following advantages:
[0025] 1. The present invention includes collecting the operation steps of a user performing a test task and constructing a directed graph, generating a directed graph repository; randomly selecting a root node in the directed graph repository; starting from the selected root node, successively searching for the next node having an edge with the current node in the directed graph repository based on a preset probability model or successively searching for the next node in the same directed graph. If a node meeting the requirements is found, execute the test operation corresponding to the node to implement the test operation simulation of the operating system visualization interface. Otherwise, continue to iterate or exit. The present invention can infer the next operation based on the recorded operation steps of the test task, simulate the manual operation of a person, continuously apply pressure to the server when unattended, restore all the operations of real users, and achieve unattended automated random testing of graphical software and web pages.
[0026] 2. The present invention includes selecting a root node of a directed graph in the directed graph repository according to the occurrence probability of the test task. By using the occurrence probability of the test task as the probability model for selecting the root node, the more frequently occurring test tasks have a greater probability of being selected, so that the key test tasks have a greater probability of being selected, resulting in better test effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 It is a schematic diagram of the basic process of the method in Embodiment 1 of the present invention.
[0028] Figure 2 It is an example of the directed graphs corresponding to three test tasks in Embodiment 1 of the present invention.
[0029] Figure 3 It is a schematic diagram of the basic process of the method in Embodiment 2 of the present invention.
[0030] Figure 4 It is an example of three new combined directed graphs in Embodiment 5 of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0031] Embodiment 1:
[0032] As Figure 1 shown, the method for simulating operations of the visual interface of an operating system based on a probability model in this embodiment includes:
[0033] 1) Pre-collect the operation steps of the user on the visual interface of the operating system when performing test tasks respectively. Each test operation of the user is regarded as a node, and the order between test operations is regarded as the edge between nodes. A directed graph is constructed for each test task, and a directed graph repository containing multiple test tasks is generated;
[0034] 2) Select the root node of a directed graph in the directed graph repository according to the occurrence probability of the test task;
[0035] 3) Starting from the selected root node, sequentially find the next node in the same directed graph. If a node that meets the requirements is found, execute the test operation corresponding to the node to implement the simulation of the test operation on the visual interface of the operating system. If a node that meets the requirements is not found, return to step 2) or exit.
[0036] In this embodiment, each test operation of the user in step 1) is a mouse operation, a keyboard operation or a command line operation. Mouse operations include mouse movement, single or double click of the left and right mouse buttons, mouse wheel, pressing or releasing the keyboard, etc.; Keyboard operations include single-key or multi-key combination input of characters such as a to z, ctrl to tab, 1 to 0,! to}, double click of the keyboard, etc.; Command line operations include cmd commands in Windows (such as: config, reboot, netstat, etc.), shell terminal commands in Linux, etc.
[0037] In this embodiment, when generating a corresponding directed graph for each group of test tasks in step 1), the attributes of each node in the directed graph include the timestamp, operation type and operation content of the test operation corresponding to the node. The timestamp is used to record the time of the test operation, and the operation type and operation content are used to reproduce the test operation corresponding to the node. The directed graph of the test task takes the first test operation as the root node, and the subsequent nodes can be connected in sequence to form a chain or tree structure. As an alternative implementation, each node can also save information such as the probability of jumping to the next node. For example, the following are three specific test tasks:
[0038] The first type: Open "My Computer" (node a), open drive C (node b), open the pictures (node d) in the user directory (node c), maximize the picture window (node e), and finally close the picture (node f). Then the corresponding directed graph can be obtained as (a, b, c, d, e, f), as Figure 2 shown by the directed graph (1) in
[0039] The second type: Open "My Computer" (node a), open drive C (node b), open the pictures in the user directory (node c) (node d), drag left and right ten times (the left and right drag nodes are l and r respectively), and finally close the picture (node f), then the corresponding directed graph obtained is (a, b, c, d, l, r, l, r, l, r, l, r, l, r, l, r, l, r, l, r, f), as Figure 2 shown by the directed graph (2) in
[0040] The third type: Open "My Computer" (node a), open drive D (node q), go back (node w), open drive C (node b), open the user directory (node c), copy the picture to the user's desktop (node p), then the corresponding directed graph obtained is (a, q, w, b, c, p), as Figure 2 shown by the directed graph (3) in
[0041] When generating a directed graph repository containing multiple test tasks in step 1) of this embodiment, the generated test tasks are all real test tasks. Subsequently, only real test tasks are selected for simulated execution. Therefore, it is possible to achieve a one-to-one restoration of user operations.
[0042] In this embodiment, when selecting a root node of a directed graph in the directed graph repository according to the occurrence probability of the test task in step 2), the probability of each root node of the directed graph being selected is the number of occurrences of the directed graph in the directed graph repository divided by the total number of occurrences of the directed graphs in the directed graph repository. By the above method, the more frequently occurring test tasks have a greater probability of being selected, so that the key test tasks have a greater probability of being selected, resulting in a better test effect. Undoubtedly, in step 2), a root node of a directed graph can also be randomly selected in the directed graph repository as needed. In this case, the probability of each directed graph of the test task being selected is the same, and the test is more random.
[0043] In addition, this embodiment also provides a probability model-based operating system visual interface operation simulation system, including a microprocessor and a memory connected to each other, characterized in that the microprocessor is programmed or configured to execute the steps of the aforementioned probability model-based operating system visual interface operation simulation method.
[0044] In addition, this embodiment also provides a computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, and the computer program is used to be executed by a computer device to implement the steps of the aforementioned probability model-based operating system visual interface operation simulation method.
[0045] Embodiment 2:
[0046] This embodiment is basically the same as the first embodiment, and the main difference is that the method of finding the next node in step 3) is different. In this embodiment, the method of finding the next node in step 3) is as follows: successively search in the directed graph repository for the next node that has an edge with the current node based on a preset probability model, such as Figure 3 shown, step 3) includes: starting from the selected root node, successively search in the directed graph repository for the next node that has an edge with the current node based on a preset probability model. If a node that meets the requirements is found, execute the test operation corresponding to that node to simulate the test operation of the operating system visualization interface. If no node that meets the requirements is found, return to step 2) or exit. As Figure 2 shown, the directed graphs (1), (2), and (3) are three directed graphs in the directed graph repository that contain the current node c. The next nodes that have an edge with the current node c include node d and node p. As an optional implementation manner, the preset probability model in this embodiment is a random probability model, that is, randomly select one of node d and node p as the next node according to the random probability. Through the above method, approximate user operations and possible operation combinations can be deduced, and human manual operations can be simulated, with more permutation and combination methods, so that the coverage of the test operation is larger and the test effect is better.
[0047] In addition, this embodiment also provides an operating system visualization interface operation simulation system based on a probability model, including a microprocessor and a memory connected to each other, characterized in that the microprocessor is programmed or configured to execute the steps of the foregoing operating system visualization interface operation simulation method based on a probability model.
[0048] In addition, this embodiment also provides a computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, and the computer program is used to be executed by a computer device to implement the steps of the foregoing operating system visualization interface operation simulation method based on a probability model.
[0049] Embodiment Three:
[0050] This embodiment is a further improvement of Embodiment Two. Refer to Figure 2 It can be seen that since the next nodes that have an edge with the current node c in the directed graphs (1), (2), and (3) include node d and node p, but node d appears twice and node p appears once. If the next node is selected according to the random probability model at this time, it is difficult to express the characteristic that the frequency of node d appears higher. To solve the above technical problem, it is necessary to increase the probability of node d. To achieve the problem of increasing the probability of node d, the function expression of the preset probability model in this embodiment is:
[0051] Q x =∏ i Q(xi |Q ag (x i )),
[0052] In the above formula, Q x represents the probability that node x is selected, and x i represents the i-th parent node of node x. When i takes the lower boundary, the i-th parent node is node x itself; when i takes the upper boundary, the i-th parent node is the root node in the directed graph with the most parent nodes of node x. Q ag (x i ) represents the parent node of node x i , and Q(x i |Q ag (x i )) represents the probability of node x i relative to its parent node Q ag (x i ). Assume that the nodes between node x i and the root node in the directed graph with the most parent nodes are (a, b). Then the probability that node x (node b) is selected is Q(a)Q(b|a); assume that the nodes between node x i and the root node in the directed graph with the most parent nodes are (a, b, c). Then the probability that node x (node c) is selected is Q(a)Q(b|a)Q(c|b); assume that the nodes between node x i and the root node in the directed graph with the most parent nodes are (a, b, c, d). Then the probability that node x (node d) is selected is Q(a)Q(b|a)Q(c|b)Q(d|c); assume that the nodes between node x i and the root node in the directed graph with the most parent nodes are (a, b, c, d, e). Then the probability that node x (node e) is selected is Q(a)Q(b|a)Q(c|b)Q(d|c)Q(e|d); assume that the nodes between node x i and the root node in the directed graph with the most parent nodes are (a, b, c, d, e, f). Then the probability that node x (node f) is selected is Q(a)Q(a|b)Q(c|b)Q(d|c)Q(e|d)Q(f|e). Among them, Q(a) represents the probability of the root node relative to the empty parent node, and its value is the probability that the node a appears as the root node in all directed graphs, that is, the number of times the node a appears as the root node divided by the total number of root nodes; in addition, it can also take the value of the probability that the node a appears in all directed graphs, that is, the number of times the node a appears as the root node and the number of ordinary nodes divided by the total number of nodes; the probability Q(x i relative to its parent node Q ag (x i ) of node x i|Q ag (x i ) takes the value of the parent node Q ag (x i ) After that, the number of occurrences of node x i is divided by the total number of child nodes after the parent node Q ag (x i ). In this way, considering the probability of the nodes between node x itself and the root node in the directed graph with the most parent nodes where the i-th parent node is node x, the selection between different directed graphs becomes more reasonable.
[0053] In addition, this embodiment also provides an operating system visualization interface operation simulation system based on a probability model, including a microprocessor and a memory connected to each other. It is characterized in that the microprocessor is programmed or configured to execute the steps of the aforementioned operating system visualization interface operation simulation method based on a probability model.
[0054] In addition, this embodiment also provides a computer-readable storage medium, which is characterized in that a computer program is stored in the computer-readable storage medium, and the computer program is used to be executed by a computer device to implement the steps of the aforementioned operating system visualization interface operation simulation method based on a probability model.
[0055] Embodiment 4:
[0056] This embodiment is basically the same as Embodiment 3 and is also a further improvement of Embodiment 2. The main difference is that in order to solve the problem of increasing the probability of node d, the function expression of the preset probability model adopted in this embodiment is: select the next node according to the occurrence probability of the next node where there is an edge from the current node c. For example, in Figure 2 , the next nodes where there is an edge from the current node c include node d and node p. Node d appears twice and node p appears once. Then the probability that node d is selected as the next node is 2 / 3, and the probability that node p is selected as the next node is 1 / 3. In this way, the problem of increasing the probability of node d can also be solved, making the selection of the next node more reasonable, and the selection method is simple and fast.
[0057] In addition, this embodiment also provides an operating system visualization interface operation simulation system based on a probability model, including a microprocessor and a memory connected to each other. It is characterized in that the microprocessor is programmed or configured to execute the steps of the aforementioned operating system visualization interface operation simulation method based on a probability model.
[0058] In addition, this embodiment further provides a computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, and the computer program is used to be executed by a computer device to implement the steps of the foregoing method for simulating operations of a visual interface of an operating system based on a probability model.
[0059] Embodiment Five:
[0060] This embodiment is a further improvement on Embodiments One to Four. In step 1) of the foregoing Embodiments One to Four, when generating a directed graph repository containing multiple test tasks, the generated test tasks are all real test tasks. However, the test coverage of real test tasks is limited. To achieve a larger test coverage, in step 1) of this embodiment, when generating a directed graph repository containing multiple test tasks, it further includes: for multiple directed graphs containing the same node, taking the same node as the reference node, dividing the corresponding directed graphs into a set of predecessor nodes before the reference node and a set of successor nodes after the reference node respectively, and then combining and splicing the sets of predecessor nodes and successor nodes of multiple directed graphs containing the same node pairwise to obtain a directed graph representing the generated test task.
[0061] For example Figure 2 in the directed graphs (1), (2), and (3) are multiple directed graphs containing the same node c. When taking the same node as the reference node c and dividing the corresponding directed graphs into a set of predecessor nodes before the reference node and a set of successor nodes after the reference node respectively, the sets of predecessor nodes before the reference node and the sets of successor nodes after the reference node of the directed graph (1) are respectively: (a, b), (d, e, f); the sets of predecessor nodes before the reference node and the sets of successor nodes after the reference node of the directed graph (2) are respectively: (a, b), (d, l, r, l, r, l, r, l, r, l, r, l, r, l, r, l, r, l, r, f); the sets of predecessor nodes before the reference node and the sets of successor nodes after the reference node of the directed graph (3) are respectively: (a, q, w, b), (p). That is: all the sets of predecessor nodes before the reference node include: (a, b), (a, q, w, b) two types; all the sets of successor nodes after the reference node include: (d, e, f), (d, l, r, l, r, l, r, l, r, l, r, l, r, l, r, l, r, l, r, f), (p) three types. By combining and splicing pairwise, new directed graphs (4), (5), and (6) can be obtained, as Figure 4As shown. In the above manner, based on real test tasks, permutations and combinations can be carried out to obtain generated test tasks, thereby achieving a larger test coverage; this manner is combined with the manner in Embodiment 2 of inferring approximate user operations and possible operation combinations and simulating human manual operations, which can further increase the number of permutation and combination methods, thus making the coverage of test operations larger and the test effect better. It should be noted that based on real test tasks, permutations and combinations are carried out to obtain generated test tasks, thereby achieving a larger test coverage. When selecting a root node of a directed graph in the directed graph repository in step 2) according to the occurrence probability of the test task, the test task includes both real test tasks and generated test tasks. For the generated test tasks, the number of times the directed graph appears in the directed graph repository refers to the number of times the generated test task is generated during permutation and combination. For some generated test tasks, the same directed graph may be generated multiple times during permutation and combination, so only one copy of the directed graph and the generation times need to be recorded in the directed graph repository.
[0062] In addition, this embodiment also provides an operating system visual interface operation simulation system based on a probability model, including a microprocessor and a memory connected to each other, characterized in that the microprocessor is programmed or configured to execute the steps of the aforementioned operating system visual interface operation simulation method based on a probability model.
[0063] In addition, this embodiment also provides a computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, and the computer program is used to be executed by a computer device to implement the steps of the aforementioned operating system visual interface operation simulation method based on a probability model.
[0064] Embodiment Six:
[0065] This embodiment is a similar implementation of Embodiment Five, and is also used to carry out permutations and combinations based on real test tasks to obtain generated test tasks, thereby achieving a larger test coverage. When generating a directed graph repository containing multiple test tasks in step 1) of this embodiment, it further includes: for multiple directed graphs containing the same node, taking the same node as the reference node, respectively dividing the corresponding directed graphs into a set of predecessor nodes before the reference node and a set of successor nodes after the reference node, shuffling the set of successor nodes to obtain multiple new sets of successor nodes (so as to generate more disordered sets of successor nodes), and then pairwise combining and splicing the set of predecessor nodes and the new sets of successor nodes of multiple directed graphs containing the same node to obtain a directed graph representing the generated test task. For example, if the original successors are (d, e, f), after shuffling the set of successor nodes to obtain multiple new sets of successor nodes, the new sets of successor nodes generated include:
[0066] (d,f,e), (e,d,f), (e,f,d), (f,e,d), (f,d,e), (f,d,f), (d,f,e,d,f), (e,d,f,e,d,f), etc.
[0067] After shuffling the set of successor nodes to obtain multiple new sets of successor nodes, similarly, based on the actual test tasks, permutations and combinations can be performed to obtain the generated test tasks, thereby achieving a larger test coverage. However, compared with Embodiment Five, the method of shuffling the set of successor nodes to obtain multiple new sets of successor nodes may make the new sets of successor nodes more scattered. Although some ineffective operations may be introduced, it can make the test coverage wider.
[0068] Embodiment Seven:
[0069] This embodiment is a further improvement on Embodiment Five. Since the method of shuffling the set of successor nodes to obtain multiple new sets of successor nodes may make the new sets of successor nodes more scattered and irregular, although some ineffective operations may be introduced, the ineffective operations are also a kind of test for the system, which solves the boring operation of randomly performing ineffective operations by people in daily tests to check the security and robustness of the system software. In order to reduce the introduction of ineffective operations, in this embodiment, shuffling the set of successor nodes to obtain multiple new sets of successor nodes includes:
[0070] S1) Convert the set of precursor nodes and the set of successor nodes of multiple directed graphs containing the same nodes into two-dimensional matrices respectively. The first element in each row of the two-dimensional matrix is a test operation, and the subsequent elements are empty, and the row number corresponds to the order of the first element in the set of subsequent test operations; for example, a set of successor nodes (d,e,f) is converted into the form of a two-dimensional matrix as follows:
[0071]
[0072] For example, a set of successor nodes (p) is converted into the form of a two-dimensional matrix as follows:
[0073] [p,, ],
[0074] The number of columns of the two-dimensional matrix is 3 (the last two columns are both empty), and in addition, other values can also be specified according to needs.
[0075] S2) For multiple directed graphs containing the same nodes, generate a new random matrix by the restricted Boltzmann machine model RBM (Restricted Boltzmann Machines) for the two-dimensional matrix corresponding to the set of precursor nodes and the two-dimensional matrix corresponding to the set of successor nodes of each directed graph, and convert the random matrix into a new set of successor nodes; the functional expression for the restricted Boltzmann machine model RBM to generate a new random matrix is:
[0076]
[0077] In the above formula, E(v,h) represents the restricted Boltzmann machine model, v and v i are the two-dimensional matrices corresponding to the predecessor node set of the same node i, h is the two-dimensional matrix corresponding to the successor node set, W i,j is the preset probability model from the same node i to the next node j, h j The new random matrix generated. The restricted Boltzmann machine model RBM is a type of random neural network model with a two-layer structure, symmetrical connection and no self-feedback. In this embodiment, the restricted Boltzmann machine model RBM implemented by the tensorflow-rmb library is specifically adopted (it has wide applications in the fields of dimensionality reduction, classification, collaborative filtering, feature learning and topic modeling). For ease of use, this embodiment is based on python, c++ development language, and Qt graphics library implements a graphical interface. The tensorflow-rmb library is called through the graphical interface to generate a new random matrix from the two-dimensional matrix corresponding to the predecessor node set and the two-dimensional matrix corresponding to the successor node set of each directed graph. The visual interface operations of the operating system are all within the area of the desktop resolution (for example, 1920*1080). In the visual interface operations of the operating system, each input must occur simultaneously with the focus. Each test operation and subsequent operation will have a probability of occurrence. Therefore, in this embodiment, the preset probability model probability of the same node i to the next node j is used as the weight W i,j . The probability model can choose to adopt the probability model of selecting the root node in Example 1 as needed, or can choose the probability model in Example 3 as needed. This embodiment uses the restricted Boltzmann machine model RBM to increase the disorder of converting the random matrix into a new successor node set, so that the method of shuffling the successor node set to obtain multiple new successor node sets can make the test coverage wider, but it cannot reduce invalid operations, but if it is an invalid operation, it just makes up for the shortcomings of functional testing in normal testing.
[0078] In addition, this embodiment also provides an operating system visual interface operation simulation system based on a probability model, including a microprocessor and a memory connected to each other, characterized in that the microprocessor is programmed or configured to execute the steps of the aforementioned operating system visual interface operation simulation method based on a probability model.
[0079] In addition, this embodiment also provides a computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, and the computer program is used to be executed by a computer device to implement the steps of the aforementioned probability model-based operating system visual interface operation simulation method.
[0080] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. The present application is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram, as well as the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices generate means for implementing the functions specified in one Figure 1 flow or multiple flows and / or blocks Figure 1 or one block or multiple blocks. These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including instruction means that implement the functions specified in one Figure 1 flow or multiple flows and / or blocks Figure 1 or one block or multiple blocks. These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one Figure 1 flow or multiple flows and / or blocks Figure 1 or one block or multiple blocks.
[0081] The above is only the preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions falling within the concept of the present invention belong to the protection scope of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present invention, several improvements and refinements should also be regarded as within the protection scope of the present invention.
Claims
1. A method for simulating operations on a visual interface of an operating system based on a probability model, characterized in that, Including: 1) Pre-collect the operation steps of the user on the visual interface of the operating system when performing test tasks respectively. Each test operation of the user is regarded as a node, and the sequence between test operations is regarded as the edge between nodes, and a directed graph is constructed for each test task to generate a directed graph repository containing multiple test tasks; 2) In the directed graph repository, select a root node of a directed graph according to the occurrence probability of the test task or randomly; 3) Starting from the selected root node, sequentially search for the next node with an edge to the current node in the directed graph repository based on a preset probability model or sequentially search for the next node in the same directed graph. If a node that meets the requirements is found, execute the test operation corresponding to the node to simulate the test operation on the visual interface of the operating system. If a node that meets the requirements is not found, return to step 2) or exit; When selecting a root node of a directed graph in the directed graph repository according to the occurrence probability of the test task in step 2), the probability of each root node of the directed graph being selected is the number of occurrences of the directed graph in the directed graph repository divided by the total number of occurrences of the directed graphs in the directed graph repository; The function expression of the preset probability model in step 3) is: , In the above formula, represents the probability that node x is selected, represents the x th i parent node of node i and when i takes the lower boundary, the x th parent node is the node itself, i and when i takes the upper boundary, the x th parent node is the root node in the directed graph with the most parent nodes, represents the parent node of node , represents the probability of node relative to its parent node .
2. The method for simulating the operation of the visual interface of an operating system based on a probability model according to claim 1, wherein, Each test operation of the user in step 1) is a mouse operation, a keyboard operation or a command line operation.
3. The method for simulating operation of a visual interface of an operating system based on a probability model according to claim 2, wherein, When generating a corresponding directed graph for each group of test tasks in step 1), the attributes of each node in the directed graph include the timestamp, operation type and operation content of the test operation corresponding to the node.
4. The method for simulating operation of an operating system visualization interface based on a probability model according to claim 3, wherein When generating a directed graph repository containing multiple test tasks in step 1), it further includes: for multiple directed graphs containing the same node, taking the same node as the reference node, dividing the corresponding directed graphs into a set of precursor nodes before the reference node and a set of successor nodes after the reference node respectively, and then combining and splicing the sets of precursor nodes and successor nodes of multiple directed graphs containing the same node in pairs to obtain a directed graph representing the generated test task.
5. The method for simulating the operation of the visual interface of an operating system based on a probability model according to claim 4, wherein When generating a directed graph repository containing multiple test tasks in step 1), it further includes: for multiple directed graphs containing the same node, taking the same node as the reference node, dividing the corresponding directed graphs into a set of precursor nodes before the reference node and a set of successor nodes after the reference node respectively, shuffling the set of successor nodes to obtain multiple new sets of successor nodes, and then combining and splicing the sets of precursor nodes and new sets of successor nodes of multiple directed graphs containing the same node in pairs to obtain a directed graph representing the generated test task.
6. The method for simulating the operation of the visual interface of an operating system based on a probability model according to claim 5, wherein The shuffling the set of successor nodes to obtain multiple new sets of successor nodes includes: S1) Convert the sets of precursor nodes and successor nodes of multiple directed graphs containing the same node into two-dimensional matrices respectively. The first element of each row in the two-dimensional matrix is the test operation, the subsequent elements are empty, and the row number corresponds to the order of the first element in the set of subsequent test operations; S2) For multiple directed graphs containing the same nodes, generate a new random matrix by using the restricted Boltzmann machine model RBM for the two-dimensional matrix corresponding to the set of precursor nodes and the two-dimensional matrix corresponding to the set of successor nodes of each directed graph, and convert the random matrix into a new set of successor nodes; the functional expression for the restricted Boltzmann machine model RBM to generate a new random matrix is: , In the above formula, represents a restricted Boltzmann machine model, and are both two-dimensional matrices corresponding to the set of precursor nodes of the same node i, is a two-dimensional matrix corresponding to the set of successor nodes, is a preset probability model from the same node i to the next node j, is a newly generated random matrix.
7. An operating system visual interface operation simulation system based on a probability model, comprising a microprocessor and a memory connected to each other, characterized in that, The microprocessor is programmed or configured to execute the steps of the method for simulating the operation of the visual interface of the operating system based on the probability model according to any one of claims 1 to 6.
8. A computer-readable storage medium, characterized in that, A computer program is stored in the computer-readable storage medium, and the computer program is used to be executed by a computer device to implement the steps of the method for simulating the operation of the visual interface of the operating system based on the probability model according to any one of claims 1 to 6.
Citation Information
Patent Citations
Test case automatic generation method based on use utilization procedure digraphs and test method
CN102566988A