Test case generation method, system, storage medium and electronic device
By acquiring and traversing the test condition structure tree of smart home devices and generating test cases using multi-level mapping relationships, the problems of low efficiency and omissions in test case generation in existing technologies are solved, achieving efficient and comprehensive test case generation.
Patent Information
- Application Number
- CN202211193338.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-28
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2042-09-28
AI Technical Summary
In existing technologies, the generation of test cases for smart home devices is inefficient and prone to omissions, making it impossible to conduct tests efficiently and comprehensively.
By obtaining the test condition structure tree of the target device, traversing the nodes of the multi-level mapping relationship, generating test cases, creating nodes and updating status information using the multi-level mapping relationship, the integrity and uniqueness of the node cluster are ensured.
It enables efficient and comprehensive test case generation, avoiding duplication and omissions, and improving testing efficiency and accuracy.
Smart Images

Figure CN115695264B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of smart home, and particularly relates to a test case generation method and system, a storage medium and an electronic device. BACKGROUND
[0002] When testing devices such as smart home, most cases need to be tested according to combination logic, which includes multiple conditions with dependency or mapping relationship. When there are many conditions, the branches will also increase.
[0003] In the prior art, a technician manually designs each test instance according to the conditions and branches, which is low in efficiency and has the risk of omission.
[0004] Therefore, it is an urgent problem to be solved to provide a high-efficiency and comprehensive test case generation method. SUMMARY
[0005] The present application provides a test case generation method and system, a storage medium and an electronic device, to solve the defects of low efficiency and easy omission in the prior art of manually designing each test instance according to conditions and branches, and to achieve efficient and comprehensive generation of test cases.
[0006] The present application provides a test case generation method, comprising:
[0007] Obtaining a test condition structure tree of a target device, the test condition structure tree including multiple nodes with multi-level mapping relationship;
[0008] Traversing test case conditions corresponding to the nodes with multi-level mapping relationship in the test condition structure tree to generate test cases of the target device.
[0009] According to the test case generation method provided by the present application, the test condition structure tree of the target device is obtained, comprising:
[0010] Obtaining multiple test case conditions with multi-level mapping relationship corresponding to the target device;
[0011] Creating nodes corresponding to the test case conditions according to the multi-level mapping relationship;
[0012] Constructing the test condition structure tree of the target device according to the nodes.
[0013] According to the test case generation method provided by the present application, the nodes corresponding to the test case conditions are created according to the multi-level mapping relationship, comprising:
[0014] According to the plurality of test case conditions with the multi-level mapping relationship, a plurality of levels of nodes are created, wherein each node corresponds to a test case condition and state information, and the state information includes available state and unavailable state.
[0015] According to the test case generation method provided in the application, the test case conditions corresponding to the nodes with the multi-level mapping relationship in the test condition structure tree are traversed, and the test case of the target device is generated, including:
[0016] According to the levels corresponding to the plurality of nodes with the multi-level mapping relationship, nodes clusters are sequentially determined from the plurality of nodes with the multi-level mapping relationship;
[0017] According to the test case conditions corresponding to the target nodes in each node cluster, target test cases corresponding to each node cluster are determined;
[0018] According to the level of the target node in each node cluster and / or the state information of the node at the next level of the target node, the state information of the target node is changed;
[0019] According to the changed state information of the target node, the plurality of nodes with the multi-level mapping relationship are updated, and the step of sequentially determining the node clusters from the plurality of nodes with the multi-level mapping relationship is returned to be executed until the plurality of nodes with the multi-level mapping relationship are traversed;
[0020] According to the target test cases corresponding to each node cluster, the test case of the target device is determined.
[0021] According to the test case generation method provided in the application, the nodes at different levels have independent numbers;
[0022] According to the levels corresponding to the plurality of nodes with the multi-level mapping relationship, nodes clusters are sequentially determined from the plurality of nodes with the multi-level mapping relationship, including:
[0023] It is judged whether the current node meets a preset condition, and the preset condition includes that the state information of the current node is available state, and the number of the current node is the smallest;
[0024] In the case where the current node meets the preset condition, the current node is determined as the target node in the node cluster;
[0025] According to the levels corresponding to the plurality of nodes with the multi-level mapping relationship, the node at the next level of the current node is determined as the current node, and the step of judging whether the current node meets the preset condition is returned to be executed.
[0026] According to the test case generation method provided in the application, the state information of the target node is changed according to the level of the target node in each node cluster and / or the state information of the node at the next level of the target node, and the state information of the target node is changed, including:
[0027] The state information of the target node with the lowest level in the node cluster is changed to an unavailable state.
[0028] And / or,
[0029] In the case that the state information of the node at the next level corresponding to the target node is all unavailable, the state information of the target node is changed to an unavailable state.
[0030] The application further provides a test case generation system, comprising:
[0031] An acquisition unit is configured to acquire a test condition structure tree of a target device, wherein the test condition structure tree comprises a plurality of nodes having a multi-level mapping relationship.
[0032] A generation unit is configured to traverse test case conditions corresponding to the nodes having a multi-level mapping relationship in the test condition structure tree, and generate test cases of the target device.
[0033] According to the test case generation system provided in the application, the acquisition unit is specifically configured to:
[0034] Acquire a plurality of test case conditions corresponding to the target device and having a multi-level mapping relationship.
[0035] Create nodes corresponding to the test case conditions according to the multi-level mapping relationship.
[0036] Construct a test condition structure tree of the target device according to the nodes.
[0037] The application further provides an electronic device comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the computer program to implement any of the test case generation methods described above.
[0038] The application further provides a computer-readable storage medium comprising a stored program, wherein the program is executed to implement any of the test case generation methods described above.
[0039] The application further provides a computer program product comprising a computer program, wherein the computer program is executed by a processor to implement any of the test case generation methods described above.
[0040] The test case generation method, system, storage medium, and electronic device provided in this application utilize the test condition structure tree of the target device, which includes multiple nodes with multi-level mapping relationships. These multi-level mapping relationships determine the level and mapping relationship of each node. By traversing the test case conditions corresponding to the nodes in the test condition structure tree, all test cases corresponding to the test condition structure tree of the target device can be generated, achieving efficient and comprehensive test case generation. Attached Figure Description
[0041] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0042] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0043] Figure 1 This is a schematic diagram of the hardware environment for a test case generation method according to an embodiment of this application;
[0044] Figure 2 This is a flowchart illustrating the test case generation method provided in this application;
[0045] Figure 3 This is a schematic diagram of the test condition structure tree provided in this application;
[0046] Figure 4 This is a schematic diagram of the architecture of the test case generation system provided in this application;
[0047] Figure 5 This is a schematic diagram of the electronic device provided in this application. Detailed Implementation
[0048] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0049] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0050] According to one aspect of the embodiments of this application, a test case generation method is provided. This test case generation method is widely applicable to whole-house intelligent digital control application scenarios such as smart homes, smart home ecosystems, and intelligence house ecosystems. Optionally, in this embodiment, the above-mentioned test case generation method can be applied to, for example... Figure 1 The hardware environment shown consists of terminal device 102 and server 104. For example... Figure 1 As shown, server 104 is connected to terminal device 102 via a network and can be used to provide services (such as application services) to the terminal or clients installed on the terminal. A database can be set up on the server or independently of the server to provide data storage services for server 104. Cloud computing and / or edge computing services can be configured on the server or independently of the server to provide data processing services for server 104.
[0051] The aforementioned network may include, but is not limited to, at least one of the following: wired network, wireless network. The aforementioned wired network may include, but is not limited to, at least one of the following: wide area network, metropolitan area network, local area network. The aforementioned wireless network may include, but is not limited to, at least one of the following: Wi-Fi (Wireless Fidelity), Bluetooth. The terminal device 102 may not be limited to PC, mobile phone, tablet computer, smart air conditioner, smart range hood, smart refrigerator, smart oven, smart stove, smart washing machine, smart water heater, smart washing equipment, smart dishwasher, smart projector, smart TV, smart clothes rack, smart curtains, smart audio-visual equipment, smart socket, smart speaker, smart speaker box, smart fresh air equipment, smart kitchen and bathroom equipment, smart bathroom equipment, smart robot vacuum cleaner, smart window cleaning robot, smart mopping robot, smart air purifier, smart steam oven, smart microwave oven, smart water heater, smart air purifier, smart water dispenser, smart door lock, etc.
[0052] This application provides a test case generation method, such as... Figure 2 As shown, it includes:
[0053] S21. Obtain the test condition structure tree of the target device, wherein the test condition structure tree includes multiple nodes with multi-level mapping relationships.
[0054] Specifically, the target device's preset test condition structure tree can be obtained. The nodes in the test condition structure tree have multi-level mapping relationships, that is, the nodes in the test condition structure tree are divided into multiple levels.
[0055] In one example, such as Figure 3 As shown, Figure 3 This is a schematic diagram of a test condition structure tree for an air conditioner. It should be noted that the air conditioner is only one type of target device, and the target device can be any type of household appliance. Figure 3 In the test condition structure tree, the air conditioner consists of three levels, from highest to lowest: Level 1, Level 2, and Level 3. The node at Level 1 is "Air Conditioner," the nodes at Level 2 include "On-state" and "Off-state," and the nodes at Level 3 include "Temperature Adjustment," "Fan Speed Adjustment," "Mode Adjustment," "On-state," and "Baseplate Upgrade." The mapping relationship is as follows: the "Air Conditioner" node can be mapped to the "On-state" and "Off-state" nodes; the "On-state" node can be mapped to the "Temperature Adjustment," "Fan Speed Adjustment," and "Mode Adjustment" nodes; and the "Off-state" node can be mapped to the "On-state" and "Baseplate Upgrade" nodes.
[0056] S22. Traverse the test case conditions corresponding to the nodes with multi-level mapping relationships in the test condition structure tree to generate test cases for the target device.
[0057] Specifically, each node corresponds to a test case condition. Continuing with the previous example, the test case condition corresponding to the "air condition" node is that the target device is an air conditioner, the test case condition corresponding to the "power on" node is that it is in the power-on state, and the test case condition corresponding to the "temperature adjustment" node is that the temperature parameter is adjusted.
[0058] Test cases for the target device can be generated by traversing the test case conditions corresponding to the nodes in the test condition structure tree. For example, a test case can be generated that includes test case conditions corresponding to the three nodes "air conditioner", "power on" and "temperature adjustment". Similarly, a test case can be generated that includes test case conditions corresponding to the three nodes "air conditioner", "power on" and "fan speed adjustment".
[0059] In this embodiment, the obtained test condition structure tree of the target device includes multiple nodes with multi-level mapping relationships. These multi-level mapping relationships determine the level and mapping relationship of each node. By traversing the test case conditions corresponding to the nodes in the test condition structure tree, all test cases corresponding to the test condition structure tree of the target device can be generated, achieving efficient and comprehensive test case generation.
[0060] According to the test case generation system provided in this application, step S21 includes:
[0061] S211. Obtain the conditions of multiple test cases with multi-level mapping relationships corresponding to the target device.
[0062] S212. Create the node corresponding to the test case condition according to the multi-level mapping relationship.
[0063] S213. Construct the test condition structure tree of the target device based on the nodes.
[0064] Specifically, in order to generate diverse and comprehensive test cases for target devices flexibly and quickly, a test condition structure tree for the target devices can be constructed as needed.
[0065] Obtain the multi-level mapping relationship of multiple test case conditions for the target device. In one example, continuing from the previous example... Figure 3 The test condition structure tree in the code is obtained through the following steps:
[0066] The acquired test case conditions include "target device is an air conditioner", "on", "off", "adjust temperature", "adjust fan speed", "adjust mode", "execute power-on", and "upgrade baseboard", as well as multi-level mapping relationships such as "target device is an air conditioner - on - adjust temperature", "target device is an air conditioner - on - adjust fan speed", "target device is an air conditioner - on - adjust mode", "target device is an air conditioner - off - execute power-on", and "target device is an air conditioner - off - upgrade baseboard".
[0067] Based on the above multi-level mapping relationship, nodes corresponding to test case conditions are created. Then, a test condition structure tree for the target device is constructed based on these nodes, resulting in the following: Figure 3 The test condition structure tree is shown.
[0068] In this embodiment, nodes for constructing a test condition structure tree are created through a multi-level mapping relationship of multiple test case conditions for the target device. By changing the test case conditions and the multi-level mapping relationship, test condition structure trees with different structures can be generated, thereby achieving flexible and efficient generation of diverse and comprehensive test cases.
[0069] According to the test case generation method provided in this application, step S212 includes:
[0070] Based on the multiple test case conditions with the multi-level mapping relationship, nodes of multiple levels are created, wherein each node corresponds to a test case condition and a status information, the status information including an available status and an unavailable status.
[0071] In this embodiment, nodes are divided into multiple levels, achieving multi-level differentiation, which facilitates the accurate and quick acquisition of test case conditions at different levels when generating test cases; each node corresponds to a test case condition, realizing mapping, making the test case condition represented by each node concise and clear, improving the accuracy and comprehensiveness of test case generation; each node has status information, including available and unavailable states, which facilitates quick differentiation of whether the test case condition has already been used to generate test cases, avoiding the generation of duplicate test cases.
[0072] According to the test case generation method provided in this application, step S22 includes:
[0073] S221. Determine node clusters sequentially from the plurality of nodes with multi-level mapping relationships according to the levels corresponding to the plurality of nodes with multi-level mapping relationships;
[0074] S222. Determine the target test cases for each node cluster based on the test case conditions corresponding to the target nodes in each node cluster.
[0075] S223. Change the state information of the target node according to the level of the target node in each node cluster and / or the state information of the node at the next level of the target node;
[0076] S224. Based on the modified state information of the target node, update the plurality of nodes with multi-level mapping relationships, and return to the step of determining the node cluster from the plurality of nodes with multi-level mapping relationships in sequence, until all the plurality of nodes with multi-level mapping relationships have been traversed.
[0077] S225. Determine the test cases for the target device based on the target test cases corresponding to each node cluster.
[0078] Specifically, in one example:
[0079] In a multi-level mapping relationship, there exists a first-level node A and corresponding second-level nodes B and C. Node A is selected as a target node in a node cluster at the first level, and node B is selected as a target node in a node cluster at the second level. A node cluster is formed based on target nodes A and B. Target test cases are generated for this node cluster based on the test case conditions corresponding to target nodes A and B.
[0080] Based on the levels of nodes A and B in the node cluster and / or the state information of the nodes at the next level of A and B in the multi-level mapping relationship, the state information of A and B is modified, and the nodes in the multi-level mapping relationship are updated. Assuming that after the update, the state information of A is available and the state information of B is unavailable, the process returns to selecting target nodes from the first and second levels sequentially to form a node cluster. This generates a node cluster containing target nodes A and C. Based on the test case conditions corresponding to target nodes A and C, target test cases are generated for this node cluster. Similarly, the state information is modified, and the nodes in the multi-level mapping relationship are traversed.
[0081] Then, the target test cases corresponding to each node cluster generated above are determined as the test cases for the target device.
[0082] In this embodiment, node clusters are determined based on the levels corresponding to nodes in a multi-level mapping relationship. This allows for hierarchical filtering of target nodes within a node cluster according to their levels, preventing the omission of conditions corresponding to nodes across levels and thus avoiding missing test cases. Based on the level of the target node in the node cluster and / or the state information of the nodes at the next lower level, the state information of the target node is modified, and the nodes in the multi-level mapping relationship are updated. The process is then repeated to re-determine the node clusters until all nodes have been traversed. This ensures the completeness of traversing all nodes in the multi-level mapping relationship while preventing duplicate node clusters from generating duplicate test cases.
[0083] According to the test case generation method provided in this application, nodes at different levels have independent numbers;
[0084] Step S221 includes:
[0085] S2211. Determine whether the current node meets the preset conditions, wherein the preset conditions include the current node's status information being in an available state and the current node's number being the smallest.
[0086] S2212. If the current node meets the preset conditions, the current node is determined as the target node in the node cluster.
[0087] S2213. According to the level corresponding to the multiple nodes with multi-level mapping relationship, determine the next level node of the current node as the current node, and return to execute the step of determining whether the current node meets the preset conditions.
[0088] Specifically, if the current node does not meet the preset conditions or if the next level node of the current node cannot be determined as the current node, the loop of steps S2211-S2213 ends, and a node cluster is obtained.
[0089] Specifically, in one example:
[0090] It is known that there are two nodes in the first level, numbered 1 and 2, and three nodes in the second level, numbered 1, 2 and 3. The second-level nodes that are mapped to node 1 in the first level are nodes 1 and 2, and the second-level node that is mapped to node 2 in the first level is node 3. All nodes are in an available state.
[0091] The two nodes of the first level are selected as the current nodes in turn. The first level node 1 is in an available state and has the smallest number, so it is selected as a target node in the node cluster. The two nodes of the second level that have a mapping relationship with the first level node 1 are selected as the current nodes in turn. The second level node 1 is in an available state and has the smallest number, so it is selected as a target node in the node cluster. At this time, the second level node 1 has no corresponding node in the next level, and the complete node cluster is obtained.
[0092] In this embodiment, when the current node's status information is available and its number is the smallest, it is determined as the target node in the node cluster. This achieves the goal of filtering nodes in the multi-level mapping relationship without omission by using both status information and number as dual elements to obtain the target node and determine the node cluster, thereby ensuring the diversity and completeness of the subsequently obtained node clusters.
[0093] According to the test case generation method provided in this application, step S223 includes:
[0094] S2231. Change the status information of the lowest-level target node in the node cluster to an unavailable state.
[0095] And / or,
[0096] S2232, If the status information of all nodes at the next level corresponding to the target node is unavailable, change the status information of the target node to unavailable.
[0097] Specifically, continuing the previous example, for the node cluster, node 1 of the second level is the lowest-level target node, and its status information is changed to unavailable. Now, the process is repeated to determine the node cluster from multiple nodes with multi-level mapping relationships, sequentially according to their corresponding levels. For the first level, node 1 is still selected as a target node for the node cluster. For the two nodes in the second level that have a mapping relationship with node 1 of the first level, since the status information of node 1 of the second level has been changed to unavailable, the node with the smallest available status and number is selected as node 2 as a target node for the node cluster. At this point, node 1 of the second level has no corresponding node in the next lower level, resulting in a complete node cluster. In this node cluster, node 2 of the second level is the lowest-level target node, and its status information is changed to unavailable.
[0098] Specifically, continuing from the previous example, since the status information of the two second-level nodes with the mapping relationship of the first-level node 1 is both unavailable, the status information of the first-level node 1 is changed to unavailable. Based on the changed status information of the target node, multiple nodes with multi-level mapping relationships are updated, and the step of determining the node cluster from multiple nodes with multi-level mapping relationships is re-executed according to the level corresponding to the multiple nodes with multi-level mapping relationships.
[0099] Since the state of node 1 in the first level has been changed to unavailable, the two nodes in the first level are selected sequentially as the current nodes. Node 2 in the first level is available and has the smallest number, so it is selected as a target node in the new node cluster. There is only one second-level node with a mapping relationship to node 2 in the first level, which is node 3 in the second level. Since node 3 is available, it is also selected as a target node in the new node cluster, resulting in a complete node cluster. In this cluster, node 3 in the second level is the lowest-level target node, and its state is changed to unavailable. Since all second-level nodes with a mapping relationship to node 2 in the first level are unavailable, node 2 in the first level is also changed to unavailable. This completes the traversal of multiple nodes with multi-level mapping relationships.
[0100] In this embodiment, the state information of the lowest-level target node in the node cluster is changed to an unavailable state. When the state information of the next-level nodes corresponding to the target node is all unavailable, the state information of the target node is changed to an unavailable state. This achieves accurate traversal of nodes at each level and prevents repeated traversal of multiple identical nodes forming the same node cluster, thereby generating duplicate test cases and wasting resources.
[0101] The test case generation system provided in this application is described below. The test case generation system described below can be referred to in correspondence with the test case generation method described above.
[0102] This application also provides a test case generation system, such as... Figure 4 As shown, it includes:
[0103] The acquisition unit 41 is used to acquire the test condition structure tree of the target device, wherein the test condition structure tree includes multiple nodes with multi-level mapping relationships;
[0104] The generation unit 42 is used to traverse the test case conditions corresponding to the nodes with multi-level mapping relationships in the test condition structure tree and generate test cases for the target device.
[0105] In this embodiment, the obtained test condition structure tree of the target device includes multiple nodes with multi-level mapping relationships. These multi-level mapping relationships determine the level and mapping relationship of each node. By traversing the test case conditions corresponding to the nodes in the test condition structure tree, all test cases corresponding to the test condition structure tree of the target device can be generated, achieving efficient and comprehensive test case generation.
[0106] According to the test case generation system provided in this application, the acquisition unit 41 is specifically used for:
[0107] Obtain multiple test case conditions with multi-level mapping relationships corresponding to the target device;
[0108] Create nodes corresponding to the test case conditions based on the multi-level mapping relationship;
[0109] Construct the test condition structure tree for the target device based on the nodes.
[0110] According to the test case generation system provided in this application, the acquisition unit 41 is specifically used for:
[0111] Based on the multiple test case conditions with the multi-level mapping relationship, nodes of multiple levels are created, wherein each node corresponds to a test case condition and a status information, the status information including an available status and an unavailable status.
[0112] According to the test case generation system provided in this application, the generation unit 42 is specifically used for:
[0113] Based on the levels corresponding to the multiple nodes with multi-level mapping relationships, node clusters are determined sequentially from the multiple nodes with multi-level mapping relationships;
[0114] Based on the test case conditions corresponding to the target nodes in each node cluster, determine the target test cases corresponding to each node cluster;
[0115] The state information of the target node is changed based on the level of the target node in each node cluster and / or the state information of the node at the next level of the target node;
[0116] Based on the modified state information of the target node, update the plurality of nodes with multi-level mapping relationships, and return to the step of determining the node cluster from the plurality of nodes with multi-level mapping relationships in sequence, until all the plurality of nodes with multi-level mapping relationships have been traversed;
[0117] Based on the target test cases corresponding to each node cluster, the test cases for the target device are determined.
[0118] According to the test case generation system provided in this application, nodes at different levels have independent numbers;
[0119] The generation unit 42 is specifically used for:
[0120] The step of determining node clusters sequentially from the plurality of nodes with multi-level mapping relationships according to the levels corresponding to those nodes includes:
[0121] Determine whether the current node meets the preset conditions, wherein the preset conditions include the current node's status information being in an available state and the current node's number being the smallest;
[0122] If the current node meets the preset conditions, the current node is determined as the target node in the node cluster;
[0123] According to the levels corresponding to the multiple nodes with multi-level mapping relationships, the next level node of the current node is determined as the current node, and the process returns to the step of determining whether the current node meets the preset conditions.
[0124] According to the test case generation system provided in this application, the generation unit 42 is specifically used for:
[0125] Change the status information of the lowest-level target node in the node cluster to an unavailable state;
[0126] And / or,
[0127] If the status information of all nodes at the next level corresponding to the target node is unavailable, change the status information of the target node to unavailable.
[0128] Figure 5 An example is a schematic diagram of the physical structure of an electronic device, such as...Figure 5 As shown, the electronic device may include a processor 510, a communications interface 520, a memory 530, and a communication bus 540, wherein the processor 510, communications interface 520, and memory 530 communicate with each other via the communication bus 540. The processor 510 can invoke logical instructions in the memory 530 to execute a test case generation method. This method includes: obtaining a test condition structure tree of the target device, the test condition structure tree including multiple nodes with multi-level mapping relationships; traversing the test case conditions corresponding to the nodes with multi-level mapping relationships in the test condition structure tree to generate test cases for the target device.
[0129] Furthermore, the logical instructions in the aforementioned memory 530 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0130] On the other hand, this application also provides a computer program product, which includes a computer program that can be stored on a computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the test case generation method provided by the above methods. The method includes: obtaining a test condition structure tree of a target device, the test condition structure tree including multiple nodes with multi-level mapping relationships; traversing the test case conditions corresponding to the nodes with multi-level mapping relationships in the test condition structure tree to generate test cases for the target device.
[0131] In another aspect, this application also provides a computer-readable storage medium, the computer-readable storage medium including a stored program, wherein the program executes the test case generation method provided by the above methods when it runs, the method including: obtaining a test condition structure tree of a target device, the test condition structure tree including multiple nodes with multi-level mapping relationships; traversing the test case conditions corresponding to the nodes with multi-level mapping relationships in the test condition structure tree to generate test cases for the target device.
[0132] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0133] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0134] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A test case generation method, characterized in that, include: Obtain the test condition structure tree of the target device, wherein the test condition structure tree includes multiple nodes with multi-level mapping relationships; The nodes in the test condition structure tree are divided into multiple levels; The test case conditions corresponding to nodes with multi-level mapping relationships in the test condition structure tree are traversed to generate test cases for the target device, including: Node clusters are determined sequentially from the nodes with multi-level mapping relationships according to their corresponding levels; nodes at different levels have mutually independent numbers. Based on the test case conditions corresponding to the target nodes in each node cluster, determine the target test cases corresponding to each node cluster; The state information of the target node is changed based on the level of the target node in each node cluster and / or the state information of the node at the next level of the target node; Based on the modified state information of the target node, update the plurality of nodes with multi-level mapping relationships, and return to the step of determining the node cluster from the plurality of nodes with multi-level mapping relationships in sequence, until all the plurality of nodes with multi-level mapping relationships have been traversed; Based on the target test cases corresponding to each node cluster, the test cases for the target device are determined.
2. The test case generation method according to claim 1, characterized in that, The test condition structure tree for obtaining the target device includes: Obtain multiple test case conditions with multi-level mapping relationships corresponding to the target device; Create nodes corresponding to the test case conditions based on the multi-level mapping relationship; Construct the test condition structure tree for the target device based on the nodes.
3. The test case generation method according to claim 2, characterized in that, The step of creating the node corresponding to the test case condition based on the multi-level mapping relationship includes: Based on the multiple test case conditions with the multi-level mapping relationship, nodes of multiple levels are created, wherein each node corresponds to a test case condition and a status information, the status information including an available status and an unavailable status.
4. The test case generation method according to claim 1, characterized in that, The step of determining node clusters sequentially from the plurality of nodes with multi-level mapping relationships according to the levels corresponding to those nodes includes: Determine whether the current node meets the preset conditions, wherein the preset conditions include the current node's status information being in an available state and the current node's number being the smallest; If the current node meets the preset conditions, the current node is determined as the target node in the node cluster; According to the levels corresponding to the multiple nodes with multi-level mapping relationships, the next level node of the current node is determined as the current node, and the process returns to the step of determining whether the current node meets the preset conditions.
5. The test case generation method according to claim 1, characterized in that, The step of changing the state information of the target node based on the level of the target node in each node cluster and / or the state information of the node at the next level of the target node includes: Change the status information of the lowest-level target node in the node cluster to an unavailable state; And / or, If the status information of all nodes at the next level corresponding to the target node is unavailable, change the status information of the target node to unavailable.
6. A test case generation system, characterized in that, include: The acquisition unit is used to acquire the test condition structure tree of the target device, wherein the test condition structure tree includes multiple nodes with multi-level mapping relationships; The nodes in the test condition structure tree are divided into multiple levels; The generation unit is used to traverse the test case conditions corresponding to nodes with multi-level mapping relationships in the test condition structure tree and generate test cases for the target device. This includes: determining node clusters sequentially from the plurality of nodes with multi-level mapping relationships according to their levels; determining target test cases corresponding to each node cluster based on the test case conditions corresponding to the target node in each node cluster; changing the state information of the target node based on the level of the target node in each node cluster and / or the state information of the node at the next level of the target node; updating the plurality of nodes with multi-level mapping relationships based on the changed state information of the target node, and returning to execute the step of sequentially determining node clusters from the plurality of nodes with multi-level mapping relationships until all the nodes with multi-level mapping relationships have been traversed; and determining test cases for the target device based on the target test cases corresponding to each node cluster.
7. The test case generation system according to claim 6, characterized in that, The acquisition unit is specifically used for: Obtain multiple test case conditions with multi-level mapping relationships corresponding to the target device; Create nodes corresponding to the test case conditions based on the multi-level mapping relationship; Construct the test condition structure tree for the target device based on the nodes.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein the program, when executed, performs the method of any one of claims 1 to 5.
9. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to execute the method of any one of claims 1 to 5 through the computer program.
Citation Information
Patent Citations
Tree-based black-box test case generation method and system
CN105930268A
Task robot testing method and device, electronic equipment and storage medium
CN114880241A