Abnormal case generation method and device, electronic equipment and storage medium
By constructing abnormal test cases by combining process nodes and hierarchical information in a directed graph, the inefficiency caused by manual reliance in existing technologies is solved, and abnormal test cases are generated efficiently to discover logical problems.
Patent Information
- Application Number
- CN202111227049.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-21
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2041-10-21
Smart Images

Figure CN114281668B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of Internet communication, and particularly relates to an abnormal use case generation method and device, electronic equipment and a storage medium. BACKGROUND
[0002] With the development of Internet communication technology, Internet products are emerging in an endless stream, and testing of Internet products has become an important work link. In the related art, testing of Internet products includes abnormal testing of software using test cases, and the test cases used are often generated by staff through parameter input with the aid of a test model. Therefore, the abnormal use case generation scheme in the related art is highly dependent on manual work, and has problems such as large manual workload and low abnormal use case generation efficiency. SUMMARY
[0003] To solve the problems of low efficiency in generating abnormal use cases in the prior art, the present application provides an abnormal use case generation method, device, electronic equipment and storage medium:
[0004] According to a first aspect of the present application, an abnormal use case generation method is provided, which comprises:
[0005] adopting a preset combination rule to combine a plurality of process nodes to obtain a plurality of process node combinations; wherein the plurality of process nodes are determined from a directed graph indicating a plurality of normal use cases based on a preset strategy;
[0006] based on the hierarchical information of the plurality of process nodes in the directed graph, obtaining a corresponding pointing relationship of each process node combination;
[0007] constructing a corresponding candidate use case based on the pointing relationship;
[0008] when the execution result of the candidate use case meets the abnormal assertion requirement, marking the candidate use case as an abnormal use case.
[0009] According to a second aspect of the present application, an abnormal use case generation device is provided, which comprises:
[0010] a combination module: configured to adopt a preset combination rule to combine a plurality of process nodes to obtain a plurality of process node combinations; wherein the plurality of process nodes are determined from a directed graph indicating a plurality of normal use cases based on a preset strategy;
[0011] a obtaining module: configured to obtain a corresponding pointing relationship of each process node combination based on the hierarchical information of the plurality of process nodes in the directed graph;
[0012] A candidate use case construction module is configured to construct a corresponding candidate use case based on the pointing relationship;
[0013] An abnormal use case marking module is configured to mark the candidate use case as an abnormal use case when the execution result of the candidate use case meets the abnormal assertion requirement.
[0014] According to a third aspect of the present application, an electronic device is provided, which includes a processor and a memory, the memory storing at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the abnormal use case generation method according to the first aspect.
[0015] According to a fourth aspect of the present application, a computer readable storage medium is provided, the storage medium storing at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by a processor to implement the abnormal use case generation method according to the first aspect.
[0016] According to a fifth aspect of the present application, a computer program product or a computer program is provided, which includes computer instructions stored in a computer readable storage medium. A processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to enable the computer device to perform the abnormal use case generation method according to the first aspect.
[0017] The abnormal use case generation method, device, electronic device and storage medium provided by the present application have the following technical effects:
[0018] The present application obtains a plurality of process node combinations by adopting a preset combination rule to combine a plurality of process nodes; then, based on the hierarchical information of the plurality of process nodes in the directed graph, a corresponding pointing relationship of each process node combination is obtained; further, a corresponding candidate use case is constructed based on the pointing relationship, so that the candidate use case whose execution result meets the abnormal assertion requirement is marked as an abnormal use case. The plurality of process nodes are determined from the directed graph indicating a plurality of normal use cases based on a preset strategy. The present application combines the process nodes in the directed graph constructed for generating normal use cases to generate abnormal use cases, without the need to construct a graph, thereby improving the efficiency and convenience of generating abnormal use cases. At the same time, the pointing relationship is obtained from the hierarchical information of the process nodes in the directed graph, which ensures that the abnormal use case focuses on logical abnormalities, which is easier to guide the discovery of logical problems of the program compared to the dependence on parameter abnormalities in related technologies. BRIEF DESCRIPTION OF DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the accompanying drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced. Obviously, the accompanying drawings in the following description only represent some of the embodiments of the present application, and for those skilled in the art, other drawings can be obtained without creative effort based on these drawings.
[0020] Figure 1 is a schematic diagram of an application environment provided by an embodiment of the present application;
[0021] Figure 2 is a flowchart of an abnormal use case generation method provided by an embodiment of the present application;
[0022] Figure 3 is a flowchart of determining a plurality of process nodes provided by an embodiment of the present application;
[0023] Figure 4 is a flowchart of obtaining a candidate use case based on path information provided by an embodiment of the present application;
[0024] Figure 5 is a schematic diagram of an operation panel for drawing modeling provided by an embodiment of the present application;
[0025] Figure 6 is a schematic diagram of a directed graph indicating a normal use case provided by an embodiment of the present application;
[0026] Figure 7 is a flowchart of applying a preset filtering rule provided by an embodiment of the present application;
[0027] Figure 8 is a block diagram of an abnormal use case generation device provided by an embodiment of the present application;
[0028] Figure 9 is a structural schematic diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0029] The technical solutions in the embodiments of the present application will be described clearly and completely with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments only represent some of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative effort belong to the scope of protection of the present application.
[0030] It should be noted that the terms "comprising" and "having" and any variations thereof in the specification and claims of the present application and in the accompanying drawings are intended to cover not only the inclusion of the stated steps or elements but also the inclusion of other steps or elements not clearly listed or inherent to such processes, methods, products, or devices.
[0031] Please refer to Figure 1 , Figure 1 is a schematic diagram of an application environment provided by an embodiment of the present application, which can include a client 10 and a server 20. The client 10 and the server 20 can be directly or indirectly connected through wired or wireless communication. The staff can send an abnormal use case generation request to the server 20 through the client 10. The server 20 receives the abnormal use case generation request, and in response to the request, combines the process nodes in the directed graph constructed for generating normal use cases to generate abnormal use cases. It should be noted that, Figure 1 is only an example.
[0032] The client 10 can be an entity device such as a smart phone, a computer (such as a desktop computer, a tablet computer, a notebook computer), an augmented reality (AR) / virtual reality (VR) device, a digital assistant, a smart voice interaction device (such as a smart speaker), a smart wearable device, a smart home appliance, a vehicle terminal, etc., or a software such as a computer program running in an entity device. The operating system corresponding to the client can be an Android system, an iOS system (a mobile operating system developed by Apple Inc.), a Linux system, a Microsoft Windows system, etc.
[0033] The server 20 can be a standalone physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and basic cloud computing services such as big data and artificial intelligence platforms. The server can include a network communication unit, a processor, a memory, etc. The server can provide background services for the corresponding client. When the server 20 includes multiple servers, the multiple servers can be composed of a blockchain, and the servers are nodes on the blockchain.
[0034] In actual applications, the generated abnormal use cases can be used for abnormal testing of related Internet products to help verify and improve the robustness of related software. The related Internet products can be cloud technology products, artificial intelligence products, intelligent transportation products, and assisted driving products. The related Internet products can be online products or offline products. For offline products, the results of abnormal testing can be compared with online acceptance standards to determine whether they can be online. In addition, abnormal use cases can be used to perform abnormal testing on related Internet products in a full-automatic wave testing system.
[0035] The following describes a specific embodiment of an abnormal use case generation method of the present application, Figure 2 is a flowchart of an abnormal use case generation method provided by an embodiment of the present application. The present application provides method operation steps as described in the embodiments or flowcharts, but more or fewer operation steps can be included based on conventional or non-creative labor. The order of steps listed in the embodiments is only one of the many execution orders, and does not represent the only execution order. In actual system or product execution, the method order shown in the embodiments or the drawings can be executed in sequence or in parallel (for example, in a parallel processor or multi-threaded processing environment). Specifically, as shown in Figure 2 The method can include:
[0036] S201: combining a plurality of process nodes using a preset combination rule to obtain a plurality of process node combinations; wherein the plurality of process nodes are determined from a directed graph indicating a plurality of normal use cases based on a preset strategy;
[0037] In an embodiment of the present application, the server side combines a plurality of process nodes using a preset combination rule to obtain a plurality of process node combinations. The process of combining nodes can be regarded as a repeated operation or a concurrent operation of selecting m (m≤n) elements from n different elements to form a combination. The m elements used to form a combination can be randomly selected from n elements. The m elements used to form a combination can also be selected according to a preset selection rule, such as selecting m elements from a sequence constructed by n elements using a preset selection rule. The sequence can be obtained by sorting the n elements in descending order according to a preset index, and the preset index can indicate the heat of the process node in the directed graph, i.e., the frequency of being used to construct the node combination of the normal use case; the selection rule can be to preferentially select elements with odd sequence positions, or to select elements with interval sequence positions.
[0038] The plurality of process nodes are derived from a directed graph constructed for generating normal use cases. The directed graph can be understood as that the edges connecting two nodes are directed. Whether it is a normal use case or an abnormal use case, the use case is derived based on nodes and directed edges between the nodes based on the idea of graph theory. The start point in the node can indicate the object to be tested (such as the interface to be tested), and the start point is generally a unique point. The end point in the node can indicate the expected result, and the end point is generally only connected to the process node, and has no connection relationship with the start point. The process node in the node can be a decision node, which stores a decision condition or an execution condition. The execution condition is used to indicate which other decision node or end point the test request is forwarded to when the parameter carried by the test request is X. The directed edges between the nodes include the first type of directed edges and the second type of directed edges. The first type of directed edges are between the start point and the process node, and the corresponding directed relationship of the first type of directed edges is start point—>process node, which is generally fixed. The second type of directed edges are between the process nodes and between the process nodes and the end points, and the corresponding directed relationship of the second type of directed edges is determined by the execution condition stored by the process node. The required conditions for executing the use case can be constructed according to the edge values. Since the “decision tree” is a description of the structure stored in the computer by the decision tree classifier, that is, a tree structure, and the tree is a connected and loop-free directed graph. Therefore, the directed graph here can also be regarded as a decision tree. The start point described above can be regarded as the root of the decision tree, the end point can be regarded as the leaf of the decision tree, and the process node can be regarded as the internal point of the decision tree.
[0039] The directed graph here is constructed for generating normal use cases, and the process nodes are determined from the directed graph based on a preset strategy, that is, the start points and the end points are filtered out from the directed graph based on the construction rule of the directed graph to determine the process nodes, or the tree roots and the tree leaves are filtered out based on the construction rule of the decision tree to determine the process nodes as internal points. In actual application, the breadth-first search algorithm can be used to determine the process nodes from the directed graph. Through the breadth-first search, a decision tree can be split into the following types according to the node type: 1) start point: characteristic- there is only one start point (one-to-one); 2) process node; 3) end point: characteristic- the final direction to the result is unique, and it is black or white (multiple-to-one); 4) edge connecting the nodes: parameter condition for use case execution.
[0040] In an exemplary embodiment, as shown in Figure 3 Before the node combination of the plurality of process nodes is performed by using the preset combination rule, the method further includes:
[0041] S301: acquiring the directed graph; wherein the directed graph includes a plurality of nodes for constructing the plurality of normal use cases and a plurality of directed edges;
[0042] S302: determining the plurality of process nodes from the plurality of nodes based on a preset screening rule.
[0043] The development of Internet products often adopts the form of modular development, and different teams are responsible for the development and maintenance of corresponding modules. Team A may be responsible for building the directed graph indicating normal use cases, team B may be responsible for generating abnormal use cases, and of course, team A may also be responsible. When it is the same team, the server end can obtain the directed graph from the storage object with read permission. When it is not the same team, even a team affiliated with a third party, the server end can obtain the directed graph by sending a directed graph acquisition request. Thus, by acquiring the directed graph, the business of generating abnormal use cases can be linked to the upstream business, reducing the coupling of the business to facilitate maintenance.
[0044] In combination with the above introduction of “directed graph” and “decision tree”, the construction of a normal use case needs a starting point (tree root) + at least one process node (inner point) + an end point (tree leaf). Referring to Figure 6 , the node combination for constructing a normal use case can include: (0) + (1.1) + (3.1), where (0) is the starting point, (1.1) is the process node, and (3.1) is the end point.
[0045] The process of determining the process node can be to filter out the starting point and the end point in the directed graph based on the construction rule to determine the process node, that is, to retain all original process nodes; or to filter out the starting point and the end point in the directed graph based on the construction rule to determine candidate nodes, and then screen the candidate nodes to obtain the process node, that is, to retain part of the original process nodes. Exemplarily, Figure 6 In (1.1), (1.2), (1.3), (2.1), (2.2), (2.3), (2.4), and (2.5) in the above table, all of them are original process nodes. In the way of retaining part of the original process nodes, these nodes are also candidate nodes, and considering the focus on logical abnormalities and avoiding use case explosion, those with high heat (i.e., the frequency of being used to construct node combinations of normal use cases) in the directed graph can be screened from the candidate nodes. In actual application, the demand for generating abnormal use cases can be considered to determine whether to retain all original process nodes and how to retain part of the original process nodes, thereby improving the execution flexibility of the business of generating abnormal use cases.
[0046] How to construct the directed graph indicating normal use cases will be introduced below:
[0047] 1) As shown in Figure 5As shown, the modeling can be achieved by drawing on the operation panel provided by the relevant client by the staff. The process of drawing modeling includes node editing (start / end) -> edge condition editing -> protocol field customization. After saving the drawing, the service system supporting the operation panel formats the drawing data to generate a data format that meets the conditions, generates normal use cases through a breadth-first search algorithm, and displays the generated normal use cases on the right side of the page. Among them, "scene" represents the final result (expected result) of the use case; "use case x" can jump to the use case execution log when triggered; "description" represents the path description of the use case; "result" represents the actual result of the use case: PASS-pass, FAIL-failure (floating layer displays the failure reason), NOT RUN-not executed. The left side of the page is the directed graph indicating the normal use case.
[0048] Of course, if the service system executes the abnormal use case generation scheme provided by the embodiment of the application, it can generate abnormal use cases based on the above directed graph and display the generated abnormal use cases on the right side of the page, and display the directed graph indicating the abnormal use case on the left side of the page.
[0049] 2) It can be implemented with a model. At the same time, automatic testing can be realized based on the strategy of the model.
[0050] MBT testing (Model-based Testing) needs to implement a model, and then formulate the relationship between behaviors and the relationship between behaviors and the system (finite state machine). The test system generates a lot of use cases according to the state of the system under test, the previously set limit conditions (the above relationship) and the strategy (the generated use case will be different each time it is executed). Through the specified data format->generate graph->then process the format data to generate corresponding test data. The graph is a directed graph indicating the normal use case. The test result is affected by a series of operations, which can produce uncertainty and is more likely to find some unexpected deep path BUG.
[0051] In an exemplary embodiment, the preset combination rule can be obtained before the plurality of process nodes are combined according to the preset combination rule. The preset combination rule indicates that the combination is performed in a full combination manner. Correspondingly, the plurality of process nodes are combined in a full combination manner to obtain a plurality of process node combinations.
[0052] In a full combination manner, sufficient combination of the plurality of process nodes can be achieved, and omission can be avoided. Referring to Figure 6 The finally generated process node combination is:
[0053] Single node combination: [1.1], [1.2], [1.3], [2.1],...
[0054] The node combination of two nodes: [1.1, 1.2], [1.1, 1.3], [1.1, 2.1]…;
[0055] …
[0056] The node combination of M(8) nodes: [1.1, 1.2, 1.3, 2.1, 2.2, 2.3, 2.4, 2.5].
[0057] For example, if the multiple process nodes are nodes a-c, the resulting process node combinations can include combination 1 composed of node a, combination 2 composed of node b, combination 3 composed of node c, combination 4 composed of nodes a and b, combination 5 composed of nodes a and c, combination 6 composed of nodes b and c, and combination 7 composed of nodes a-c. The number of the resulting process node combinations is
[0058] S202: obtaining the corresponding directed relationship of each process node combination based on the hierarchical information of the multiple process nodes in the directed graph;
[0059] In the embodiments of the present application, the server obtains the corresponding directed relationship of each process node combination based on the hierarchical information of the multiple process nodes in the directed graph. The hierarchical information of the process nodes in the directed graph reflects the order of the process nodes participating in decision making using the decision conditions (execution conditions) stored by the process nodes. The earlier the order of a process node participating in decision making, the closer it is to the starting point. The later the order of a process node participating in decision making, the closer it is to the end point. For example, if the starting point is a one-layer node and the end point is an L-layer node, the process nodes can be divided into two-layer nodes, three-layer nodes, …, L-1-layer nodes. In addition, in combination with the hierarchical information mentioned herein, the aforementioned process of node combination can extract one from each layer of nodes to obtain a process node combination composed of two-layer nodes, three-layer nodes, …, N-1-layer nodes.
[0060] The hierarchical information of the process nodes in the directed graph can be obtained by traversing the directed graph using a breadth-first traversal algorithm. It can be performed simultaneously with the determination of the process nodes from the directed graph using the breadth-first traversal algorithm described in the foregoing step S201. Breadth-first traversal starts from the root node R0, traverses the nodes of the tree along the width of the tree structure, and sequentially explores the unvisited adjacent points W1, W2, … of R0. Then, the unvisited adjacent points of W1, the unvisited adjacent points of W2, etc. are sequentially explored, and if the first appearing leaf node is found, the traversal stops. Using the breadth-first traversal algorithm, all nodes in the directed graph can be systematically checked, ensuring the accuracy of determining the node type split and the accuracy of determining the hierarchical information of the process nodes.
[0061] Regarding the pointing relationships corresponding to process node combinations: 1) If it is a single-node combination, then the pointing relationship is: start point -> process node combination -> end point; 2) If it is not a single-node combination, then the pointing relationship includes not only "start point -> process node combination -> end point", but also the pointing relationships within the process node combination. The pointing relationships within the process node combination include which process node is connected to the start point, which process node is connected to the end point, and how the process nodes are connected.
[0062] Compared to arranging process nodes in a process node combination sequentially to obtain the pointing relationship, the pointing relationship determined by referring to the hierarchical information of process nodes in the directed graph reduces the number of pointing relationships, thereby avoiding the problem of use case explosion in the future.
[0063] When determining the pointing relationship by referring to the hierarchical information of process nodes in the directed graph, there may be cases where at least two process nodes in a process node combination point to the same level. In such cases, it is possible to:
[0064] 1) For at least two process nodes at the same level, a connection method can be randomly selected, and the pointing relationship can be obtained based on the information describing the connection method;
[0065] 2) For at least two process nodes at the same level, a connection method is determined according to a preset direction, thereby obtaining the pointing relationship based on the information describing the connection method. The preset direction can be from left to right, from right to left, from top to bottom, or from bottom to top.
[0066] In practical applications, for at least two process nodes indicating the same level, a directed graph with a tree structure determines a connection method from left to right. Because the flow of the policy decision tree model is top-down, and with the preset direction, the same combination of process nodes will only produce one pointing relationship. This pointing relationship can be obtained by directly traversing the directed graph using a breadth-first search algorithm.
[0067] S203: Construct corresponding candidate use cases based on the aforementioned pointing relationship;
[0068] In the embodiments of the present application, the server side constructs a corresponding candidate use case based on the pointing relationship. The pointing relationship can explicitly indicate the specific connection relationship between the process node combination and the starting point and the ending point. The candidate use case can be obtained based on the reference starting point, the reference ending point and the pointing relationship. The reference starting point can follow the starting point in the directed graph, and the reference ending point can also follow the ending point in the directed graph. When there are at least two ending points in the directed graph, the leftmost ending point in the tree structure of the directed graph is generally selected. Considering that there may be functional modules with different business directions but similar or even the same implementation logic in the Internet product (for example, functional module A is used for number-based payment verification in e-commerce business scenarios, and functional module B is used for number-based login verification in vehicle networking business scenarios), the reference starting point and the reference ending point can be selected from the to-be-tested objects and the expected results corresponding to the similar functional modules.
[0069] In an exemplary embodiment, when the starting point and the ending point in the directed graph are followed, the reference starting point and the reference ending point indicating the normal use case can be determined in the directed graph, so as to obtain the use case node combination based on the reference starting point, the reference ending point and the process node combination. Correspondingly, after the pointing relationship corresponding to each process node combination is obtained based on the hierarchical information of the plurality of process nodes in the directed graph, the path information corresponding to the use case node combination is obtained based on the pointing relationship, so as to obtain the candidate use case based on the path information.
[0070] Based on the pointing relationship corresponding to the known process node combination, the path information corresponding to the use case node combination is obtained after the reference starting point and the reference ending point are integrated, so as to obtain the candidate use case. The process of determining the pointing relationship corresponding to the process node combination is taken as an independent step,
[0071] For the case where the use case node combination has a fixed starting point and ending point, the generation efficiency of the path information and the use case can be improved. In actual application, the corresponding path information can also be obtained by directly traversing the directed graph using the breadth-first traversal algorithm under the premise of knowing the use case node combination, so as to obtain the candidate use case.
[0072] Further, referring to Figure 4 For the process of obtaining the candidate use case based on the path information, the following steps can be implemented:
[0073] S401: Analyzing the path information to determine the corresponding to-be-tested object, execution condition description information and expected result;
[0074] S402: Generating a corresponding execution condition based on the execution condition description information;
[0075] S403: Generating a test request for the to-be-tested object based on the execution condition and the specification file of the to-be-tested object.
[0076] S404: obtaining the candidate use case based on the test request, the execution condition, and the expected result.
[0077] The process can be regarded as a process of parsing a path to obtain an executable use case. Taking the path information describing node 1->node 2->node 3->node 5 as an example, the parsing obtains the to-be-tested object (such as a to-be-tested interface) indicated by node 1, the expected result indicated by node 5, and the execution condition description information indicated by "node 1->node 2", "node 2->node 3", and "node 3->node 5". The parsing process can be traversing the path (node 1->node 2->node 3->node 5) to generate a combination of path edges "node 1->node 2", "node 2->node 3", and "node 3->node 5". In actual application, node 1 serves as a starting point, and the node content of node 1 can include protocol information such as information defining the name of the to-be-tested object. Based on the information, the to-be-tested object can be determined. Node 5 serves as a terminal point, and the expected result indicated by node 5 can serve as the assertion content involved in the subsequent step S204. The path edges "node 1->node 2", "node 2->node 3", and "node 3->node 5" respectively indicate keyword descriptions (keyword information), and based on the keyword descriptions, the execution condition description information can be obtained.
[0078] The process of generating a corresponding execution condition based on the execution condition description information can be a process of obtaining content matching the execution condition description information from a preset storage object. For example, obtaining content having a mapping relationship with the execution condition description information from a database serving as a prediction storage object. In actual application, in combination with the above description of path edges and keyword descriptions, a keyword can be determined based on the keyword description, and the keyword can be mapped with content in the database to generate a corresponding execution condition. The execution condition can be an executable method, for example, "generate an IP in region A" or "generate certificate information in region A". Further, the keyword description or the keyword can not provide a relatively direct intent representation, which will affect the difficulty of generating the execution condition. Therefore, an escape process can be performed, that is, natural language is escaped into a condition parameter required for use case execution, so as to ensure the accuracy of generating the execution condition. For example, the keyword description or the keyword indicates that the current transaction time is within 3 days, and the escape process obtains "generate a date of 20210811" (premise: the current system time is 20210814).
[0079] The test request for the to-be-tested object is generated based on the execution condition and the specification file of the to-be-tested object, which can be understood as input parameter assignment. Specifically, the parameter item provided by the execution condition can be matched with the candidate parameter item-candidate value provided by the specification file. Taking the to-be-tested object as an example, the interface content of the test request is obtained from the relevant interface information in the starting point, and the interface information usually only includes the interface name. The corresponding interface specification file (an idl file) can be queried from the database as a prediction storage object through the interface information, and then the parameters corresponding to the execution condition are matched with the parameter information in the idl file and are assigned values to obtain the test request.
[0080] The candidate use case is obtained based on the test request, the execution condition and the expected result. Based on the nodes and the directed edges provided by the directed graph, the relevant node information and the directed edge information can be used or processed for use, so that the efficiency of generating executable candidate use cases can be improved.
[0081] In an exemplary embodiment, before the candidate use case is obtained based on the path information, the method further includes: when the path information meets the requirements of a preset filtering rule, excluding the path information as source data for use case generation; wherein the filtering content indicated by the preset filtering rule includes at least one of the following: path information indicating the normal use case, and path information irrelevant to the directed edges in the directed graph.
[0082] Before the use case is generated, the path information that will be used to generate the normal use case and / or the full-path edgeless use case is filtered out. Generating the normal use case is contrary to the purpose of the embodiments of the present application to generate abnormal use cases, and generating the full-path edgeless use case is inconsistent with the focus of the embodiments of the present application on logical abnormalities. Filtering the relevant path information can timely exclude path information that is not conducive to the generation of abnormal use cases, thereby ensuring the effectiveness of the subsequently generated abnormal use cases and achieving effective response to system abnormalities.
[0083] In actual applications, the repeated paths can be removed first, and then the invalid paths can be removed. The repeated paths can include the same paths as the paths of the normal use cases, and the same paths in the path set used for the preset filtering rule to exclude.
[0084] For the decision tree (directed graph) indicating normal use cases, the same use case node combination will only produce one path, and the path indicated by the same use case node combination due to other ordering is an invalid path, i.e., a parameterless path (which can correspond to the above-mentioned "path information irrelevant to the directed edges in the directed graph" and "full-path edgeless use case"), which needs to be filtered out. Because the edge condition of the decision tree (directed graph) is input from top to bottom, if other ordering occurs, the corresponding edge condition parameter cannot be obtained, and the path indicated by such ordering is an invalid path. Thus, filtering of invalid paths, filtering of full-path edgeless data, and reservation of edge data are achieved. Edge data can be determined by 'edges' in the standard format content, and data with edges in 'edges' is valid data. Full-path edgeless data means that all edges in the corresponding path have no matching items in 'edges'. It can be understood that the standard format is obtained by converting the related format variable generated by the drawing modeling in the above-mentioned step S201. The standard format content is based on the format variable and has the indication of 'edges' and 'nodes'.
[0085] S204: When the execution result of the candidate use case meets the abnormal assertion requirement, the candidate use case is marked as an abnormal use case.
[0086] In the embodiments of the present application, the server end marks the candidate use case whose execution result meets the abnormal assertion requirement as an abnormal use case. Meeting the abnormal breakpoint requirement means that the candidate use case does not match the expected result. If the execution result of the candidate use case matches the expected result, it means that the execution of the candidate use case does not have an abnormal situation. If the execution result of the candidate use case does not match the expected result, it means that the execution of the candidate use case has an abnormal situation, and such candidate use case is an abnormal use case.
[0087] In an exemplary embodiment, before the step of marking the candidate use case as an abnormal use case when the execution result of the candidate use case meets the abnormal assertion requirement, the method further includes the following steps: first, triggering execution of the test request to obtain the corresponding test result; wherein the test result is determined based on the execution condition; and then, if the test result does not match the expected result, determining that the execution result of the candidate use case meets the abnormal assertion requirement.
[0088] In combination with the related descriptions in the foregoing steps S401-S404, the path information is analyzed to obtain executable candidate use cases, without additional construction of abnormal conditions, and the existing conditions can be directly used for testing. The test request can be processed in sequence based on the sub-execution conditions indicated by the path edges "node 1—>node 2", "node 2—>node 3", and "node 3—>node 5". The sending of the test request is triggered, and the test result is obtained (for example, the returned test result is received). The test result is compared with the expected result indicated by the end point. When the test result does not match the expected result, it is determined that the candidate use case passes the verification (assertion). Because the verification of the abnormal use case requires that the test result does not match the expected result. The test result not matching the expected result can be inconsistency of related values. In addition, if the test result matches the expected result, it is determined that the execution result of the candidate use case does not meet the abnormal assertion requirement, and the candidate use case is not marked as an abnormal use case. The verification can determine that the marked abnormal use case is a candidate use case that has an abnormal situation, and the effectiveness of the generated abnormal use case is ensured.
[0089] In addition, for the use case indicating the abnormal path, it can also be directly determined that it meets the abnormal assertion requirement. The abnormal path is relative to the path of the normal use case.
[0090] Referring to Figure 7 In combination with the application of the "preset filtering rule" in the foregoing step S203, in actual application, the path information corresponding to each use case node combination can be obtained based on each use case node combination, to obtain a use case corresponding to each use case node combination. Then, the initial use case set is obtained based on the use case corresponding to each use case node combination. Further, when the execution result of the initial use case meets the abnormal assertion requirement, the initial use case is marked as a candidate use case. Finally, the candidate use case is processed by using the preset filtering rule to obtain the target abnormal use case.
[0091] The embodiment of the present application provides an abnormal use case generation scheme. The breadth-first traversal is performed on the directed graph in the Figure 6 , to automatically generate executable scene abnormal use cases, and to automatically select abnormal assertions, without secondary intervention adjustment and automatic generation of parameters. The specific process of generating the abnormal use case is as follows: all possible path combinations are paired, the repeated use cases, the normal use cases, and the full-path no-edge use cases are removed based on the path combinations, and the abnormal use cases are obtained based on the remaining path combinations. Because the edge combinations in all the remaining path combinations do not match the path combinations in the directed graph, the results are often not as expected.
[0092] Compared with generating path combinations by performing full permutation on multiple nodes of a directed graph, the abnormal case generation scheme provided in the embodiments of the present application can effectively solve the problem of case explosion, and can also ensure that the abnormal cases have a certain coverage. Taking 9 nodes as an example, 362,880 path combinations can be generated by using the full permutation method. In actual application, 24 path combinations can be generated by using the abnormal case generation scheme provided in the embodiments of the present application.
[0093] As can be seen from the technical scheme provided in the embodiments of the present application, the embodiments of the present application obtain multiple process node combinations by performing node combination on multiple process nodes based on a preset combination rule; then, based on the hierarchical information of the multiple process nodes in the directed graph, the corresponding pointing relationship of each process node combination is obtained; further, the corresponding candidate case is constructed based on the pointing relationship, so as to mark the candidate case whose execution result meets the abnormal assertion requirement as an abnormal case. The multiple process nodes are determined from the directed graph indicating multiple normal cases based on a preset strategy. The present application combines the process nodes in the directed graph constructed for generating normal cases to generate abnormal cases, without the need to construct a graph additionally, thereby improving the efficiency and convenience of generating abnormal cases. At the same time, the pointing relationship is obtained from the hierarchical information of the process nodes in the directed graph, which ensures that the abnormal cases pay attention to logical abnormalities, and compared with the dependence on parameter abnormalities in related technologies, this is more likely to guide the discovery of logical problems of the program.
[0094] The embodiments of the present application also provide an abnormal case generation device, as shown in Figure 8 The abnormal case generation device 800 includes:
[0095] The combination module 801 is configured to perform node combination on multiple process nodes based on a preset combination rule, to obtain multiple process node combinations; wherein the multiple process nodes are determined from a directed graph indicating multiple normal cases based on a preset strategy.
[0096] The obtaining module 802 is configured to obtain the pointing relationship corresponding to each process node combination based on the hierarchical information of the multiple process nodes in the directed graph.
[0097] The candidate case construction module 803 is configured to construct the corresponding candidate case based on the pointing relationship.
[0098] The abnormal case marking module 804 is configured to mark the candidate case as an abnormal case when the execution result of the candidate case meets the abnormal assertion requirement.
[0099] It should be noted that the device in the device embodiment and the method embodiment are based on the same inventive concept.
[0100] This application provides an electronic device including a processor and a memory. The memory stores at least one instruction or at least one program segment, which is loaded and executed by the processor to implement the exception use case generation method provided in the above method embodiments.
[0101] Furthermore, Figure 9 A schematic diagram of the hardware structure of an electronic device for implementing the abnormal test case generation method provided in the embodiments of this application is shown. The electronic device may participate in or include the abnormal test case generation apparatus provided in the embodiments of this application. Figure 9 As shown, the electronic device 100 may include one or more processors 1002 (shown as 1002a, 1002b, ..., 1002n in the figure) (processor 1002 may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 1004 for storing data, and a transmission device 1006 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 9 The structure shown is for illustrative purposes only and does not limit the structure of the electronic device described above. For example, the electronic device 100 may also include... Figure 9 The more or fewer components shown, or having the same Figure 9 The different configurations shown.
[0102] It should be noted that the aforementioned one or more processors 1002 and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be wholly or partially integrated into any other element within the electronic device 100 (or mobile device). As involved in the embodiments of this application, the data processing circuit serves as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).
[0103] The memory 1004 can be used to store software programs of application software and modules, such as program instructions / data storage means corresponding to the abnormal case generation method in the embodiments of the present application, and the processor 1002 can execute various functional applications and data processing, i.e., implement the abnormal case generation method described above, by running the software programs and modules stored in the memory 1004. The memory 1004 can include a high-speed random access memory, and can also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some examples, the memory 1004 can further include a memory remotely arranged with respect to the processor 1002, which can be connected to the electronic device 100 through a network. Examples of the network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0104] The transmission device 1006 is configured to receive or send data via a network. Specific examples of the network can include a wireless network provided by a communication provider of the electronic device 100. In one example, the transmission device 1006 includes a network interface controller (NIC) that can be connected to other network devices through a base station so as to communicate with the Internet. In one embodiment, the transmission device 1006 can be a radio frequency (RF) module configured to communicate with the Internet in a wireless manner.
[0105] The display can be, for example, a touch screen type liquid crystal display (LCD) that can enable a user to interact with a user interface of the electronic device 100 (or mobile device).
[0106] The embodiments of the present application also provide a computer readable storage medium that can be arranged in an electronic device to save at least one instruction or at least one program for implementing an abnormal case generation method in the method embodiments, and the at least one instruction or the at least one program is loaded and executed by the processor to implement the abnormal case generation method provided by the method embodiments.
[0107] Optionally, in the present embodiment, the storage medium described above can be located in at least one of a plurality of network servers of a computer network. Optionally, in the present embodiment, the storage medium can include, but is not limited to, a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store program codes.
[0108] It should be noted that the above-mentioned order of the embodiments of the present application is only for description, and does not represent the advantages and disadvantages of the embodiments. And the above-mentioned specific embodiments of the present application are described. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from the order in the embodiments and still achieve the desired result. In addition, the processes depicted in the figures do not necessarily require the particular order shown or sequential order to achieve the desired results. In certain implementations, multi-task processing and parallel processing are possible or advantageous.
[0109] Each of the embodiments in the present application is described in a progressive manner, and the same and similar parts between the embodiments can be referred to each other. Each embodiment focuses on the difference from other embodiments. Especially, for the device and electronic equipment embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the part of the method embodiments.
[0110] A person of ordinary skill in the art can understand that all or part of the steps of the above-mentioned embodiments can be completed by hardware, or by program instructing relevant hardware to complete, and the program can be stored in a computer readable storage medium. The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk.
[0111] The above-mentioned is only the preferred embodiment of the present application, and does not limit the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. An abnormal use case generation method characterized by comprising: The method comprises: combining the process nodes according to a preset combination rule to obtain a plurality of process node combinations, wherein the process nodes are determined from a directed graph indicating a plurality of normal use cases based on a preset strategy, and the process nodes store execution conditions for deciding to forward a test request to other nodes; based on level information of each of the process nodes in the directed graph, obtaining a corresponding pointing relationship of each of the process node combinations, wherein the pointing relationship comprises an internal relationship between the process nodes, and the level information of the process nodes in the directed graph reflects an order in which the process nodes participate in decision-making using the stored execution conditions; for each of the process node combinations, obtaining path information corresponding to a use case node combination based on the pointing relationship, and obtaining a corresponding candidate use case based on the path information, wherein the use case node combination is obtained based on the process node combination, a reference starting point, and a reference ending point, the reference starting point is a starting point indicating a to-be-tested object in the directed graph, and the reference ending point is an ending point indicating an expected result in the directed graph; when an execution result of the candidate use case does not match the expected result, marking the candidate use case as an abnormal use case, wherein the execution result is obtained by triggering execution of a test request for the to-be-tested object.
2. The method of claim 1, wherein, Before the combination of the process nodes according to the preset combination rule, the method further comprises: obtaining the directed graph, wherein the directed graph comprises a plurality of nodes and a plurality of directed edges for constructing the normal use cases; determining the plurality of process nodes from the plurality of nodes based on a preset screening rule.
3. The method of claim 1, wherein: before the combination of the process nodes according to the preset combination rule, the method further comprises: obtaining the preset combination rule, wherein the preset combination rule indicates that the combination is performed in a full combination manner; the combination of the process nodes according to the preset combination rule to obtain a plurality of process node combinations comprises: combining the process nodes in a full combination manner to obtain the plurality of process node combinations.
4. The method of claim 1, wherein, Before the obtaining of the pointing relationship corresponding to each of the process node combinations based on the level information of each of the process nodes in the directed graph, the method further comprises: performing a breadth-first traversal algorithm on the directed graph to obtain the level information of each of the process nodes in the directed graph.
5. The method of claim 1, wherein, The obtaining of the candidate use case corresponding to the path information comprises: parsing the path information to determine the to-be-tested object, execution condition description information, and the expected result corresponding to the path information; generating the execution condition corresponding to the path information based on the execution condition description information; generating a test request for the to-be-tested object based on the execution condition and a specification file of the to-be-tested object; obtaining the candidate use case based on the test request for the to-be-tested object, the execution condition, and the expected result.
6. The method of claim 1, wherein, Before the obtaining of the candidate use case corresponding to the path information, the method further comprises: When the path information meets a requirement of a preset filtering rule, the path information is excluded as source data for use case generation; wherein the filtering content indicated by the preset filtering rule comprises at least one of the following: path information indicating the normal use case, and path information irrelevant to a directed edge in the directed graph.
7. An abnormal use case generation apparatus characterized by comprising: The apparatus comprises: a combination module configured to combine the process nodes based on a preset combination rule to obtain a plurality of process node combinations, wherein the process nodes are determined from the directed graph indicating a plurality of normal use cases based on a preset strategy, and the process nodes store execution conditions for deciding to forward a test request to other nodes; an obtaining module configured to obtain a corresponding directed relationship of each process node combination based on level information of the process nodes in the directed graph, wherein the directed relationship comprises an internal relationship between the process nodes, and the level information of the process nodes in the directed graph reflects an order in which the process nodes participate in decision making by using the stored execution conditions; a candidate use case construction module configured to, for each process node combination, obtain path information corresponding to a use case node combination based on the directed relationship, and obtain a corresponding candidate use case based on the path information, wherein the use case node combination is obtained based on the process node combination, a reference starting point, and a reference ending point, the reference starting point is a starting point indicating a to-be-tested object in the directed graph, and the reference ending point is an ending point indicating an expected result in the directed graph; an abnormal use case marking module configured to, when an execution result of the candidate use case does not match the expected result, mark the candidate use case as an abnormal use case, wherein the execution result is obtained by triggering execution of a test request for the to-be-tested object.
8. The apparatus of claim 7, wherein, The apparatus is further configured to obtain the directed graph, wherein the directed graph comprises a plurality of nodes and a plurality of directed edges for constructing the normal use cases, and determine the process nodes from the plurality of nodes based on a preset screening rule.
9. The apparatus of claim 7, wherein: The apparatus is further configured to obtain the preset combination rule, wherein the preset combination rule indicates that combination is performed in a full combination manner. The combination module is further configured to combine the process nodes in a full combination manner to obtain the process node combinations.
10. The apparatus of claim 7, wherein, The apparatus is further configured to traverse the directed graph by using a breadth-first traversal algorithm to obtain the level information of the process nodes in the directed graph.
11. The apparatus of claim 7, wherein, The obtaining of the candidate use case based on the path information comprises: parsing the path information to determine the to-be-tested object, execution condition description information, and the expected result corresponding to the path information; generating the execution condition corresponding to the path information based on the execution condition description information; generating a test request for the to-be-tested object based on the execution condition and a specification file of the to-be-tested object; obtaining the candidate use case based on the test request for the to-be-tested object, the execution condition, and the expected result.
12. The apparatus of claim 7, wherein, The device is further configured to exclude the path information as source data for use case generation when the path information meets a requirement of a preset filtering rule; and the filtering content indicated by the preset filtering rule includes at least one of the following: path information indicating the normal use case, and path information irrelevant to a directed edge in the directed graph.
13. An electronic device, comprising: The electronic device includes a processor and a memory, and the memory stores at least one instruction or at least one program, which is loaded and executed by the processor to implement the abnormal use case generation method according to any one of claims 1-6.
14. A computer-readable storage medium, characterized in that, The storage medium stores at least one instruction or at least one program, which is loaded and executed by the processor to implement the abnormal use case generation method according to any one of claims 1-6.
15. A computer program product, characterised in that, The computer program product includes at least one instruction or at least one program, which is loaded and executed by the processor to implement the abnormal use case generation method according to any one of claims 1-6.
Citation Information
Patent Citations
Test data processing method and device, computer equipment and storage medium
CN110955608A
Use case generation method and device, server and storage medium
CN113297063A