CN114817036A - Decision tree testing method and device, electronic equipment and storage medium - Google Patents
Decision tree testing method and device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN114817036A CN114817036A CN202210447373.8A CN202210447373A CN114817036A CN 114817036 A CN114817036 A CN 114817036A CN 202210447373 A CN202210447373 A CN 202210447373A CN 114817036 A CN114817036 A CN 114817036A
- Authority
- CN
- China
- Prior art keywords
- decision tree
- target
- test
- path
- decision
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3676—Test management for coverage analysis
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3692—Test management for test results analysis
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
The present disclosure provides a decision tree testing method, which can be used in the technical field of computers, and the method comprises the following steps: obtaining a plurality of decision tree paths of a target decision tree, wherein each decision tree path has a leaf node which is represented as an expected result of the decision tree path; screening a plurality of test examples corresponding to a plurality of decision tree paths from an example library; respectively inputting the test cases into a target decision tree to obtain a plurality of execution results; and comparing the expected results with the execution results to obtain a test result of the target decision tree. In addition, the disclosure also provides a decision tree testing device, an electronic device and a readable storage medium.
Description
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a decision tree testing method, an apparatus, an electronic device, a readable storage medium, and a computer program product.
Background
A decision tree is a method that lists the relevant steps to solve a problem and the conditions and results under which each step occurs. In the related art, the decision tree can show a complex business logic by illustration so as to be convenient for business personnel to modify.
In implementing the disclosed concept, the inventors found that there are at least the following problems in the related art: in the related art, when the decision tree is tested, conflicts among the logic nodes are difficult to find, and the consumption of labor cost and time cost is large.
Disclosure of Invention
In view of the above, the present disclosure provides a decision tree testing method, a decision tree testing apparatus, an electronic device, a readable storage medium, and a computer program product.
One aspect of the present disclosure provides a decision tree testing method, including: obtaining a plurality of decision tree paths of a target decision tree, wherein each of the decision tree paths has a leaf node, and the leaf node represents an expected result of the decision tree path; screening a plurality of test examples corresponding to the plurality of decision tree paths from an example library; inputting a plurality of test cases into the target decision tree respectively to obtain a plurality of execution results; and comparing the expected results with the execution results to obtain a test result of the target decision tree.
According to an embodiment of the present disclosure, the decision tree path further has at least one logic node, and each of the logic nodes is configured with a logic branch; wherein, the screening a plurality of test cases corresponding to the plurality of decision tree paths from the case base includes: for each decision tree path, performing keyword matching in the example library by taking fields corresponding to the logic nodes of the decision tree path as keywords; under the condition that a first target instance is obtained from the instance base in a matching mode, screening is carried out in at least one first target instance based on the logic branch of the logic node; and under the condition that second target examples are obtained by screening from the first target examples, selecting a preset number of examples from the second target examples as test examples corresponding to the decision tree paths.
According to an embodiment of the present disclosure, the method further includes: generating a test instance corresponding to the decision tree path based on a field corresponding to the logical node and a logical branch of the logical node in case that a first target instance is not obtained from the instance base by matching or in case that a second target instance is not obtained from the first target instance by screening; and storing the test case into the case base.
According to an embodiment of the present disclosure, the inputting a plurality of test cases corresponding to a plurality of paths of the decision tree into the target decision tree to obtain a plurality of execution results includes: for each test case, inputting the test case into the target decision tree for multiple times to obtain multiple decision results; and determining the execution result of the test case as the decision result under the condition that the decision results are consistent.
According to an embodiment of the present disclosure, the method further includes: and when a decision result inconsistent with other decision results exists in a plurality of decision results, returning the path information of the decision tree path corresponding to the test example to the terminal equipment so as to perform manual verification.
According to an embodiment of the present disclosure, the method further includes: and for each decision tree path, under the condition that an expected result corresponding to the decision tree path is inconsistent with an execution result corresponding to the decision tree path, returning the path information of the decision tree path to the terminal equipment so as to perform manual verification.
Another aspect of the present disclosure provides a decision tree testing apparatus, including: an obtaining module, configured to obtain multiple decision tree paths of a target decision tree, where each of the decision tree paths has a leaf node, and the leaf node represents an expected result of the decision tree path; the first processing module is used for screening a plurality of test examples corresponding to the decision tree paths from an example library; the second processing module is used for respectively inputting a plurality of test cases into the target decision tree to obtain a plurality of execution results; and a comparison module for comparing the expected results with the execution results to obtain the test result of the target decision tree.
Another aspect of the present disclosure provides an electronic device including: one or more processors; memory to store one or more instructions, wherein the one or more instructions, when executed by the one or more processors, cause the one or more processors to implement a method as described above.
Another aspect of the present disclosure provides a computer-readable storage medium storing computer-executable instructions for implementing the method as described above when executed.
Another aspect of the disclosure provides a computer program product comprising computer executable instructions for implementing the method as described above when executed.
According to the embodiment of the disclosure, when the target decision tree is tested, the decision tree paths of the target decision tree can be exhausted, the test examples are screened from the example library respectively based on each decision tree path, and then the execution result of the test example can be compared with the expected result to determine the test result of the target decision tree. By the technical means, the coverage of the whole process of the target decision tree can be realized, and the technical problems that the conflict between logic nodes is difficult to find when the decision tree is tested and the consumption of labor cost and time cost is high in the related technology are at least partially solved, so that the test cost of the decision tree is effectively reduced, and the logic accuracy of the decision tree is improved.
Drawings
The above and other objects, features and advantages of the present disclosure will become more apparent from the following description of embodiments of the present disclosure with reference to the accompanying drawings, in which:
fig. 1 schematically illustrates an exemplary system architecture to which a decision tree testing method may be applied, according to an embodiment of the present disclosure.
FIG. 2 schematically illustrates a flow diagram of a decision tree testing method according to an embodiment of the present disclosure.
FIG. 3 schematically shows a flow chart of a test case screening method according to an embodiment of the present disclosure.
FIG. 4 schematically illustrates a flow diagram of a decision tree testing method according to another embodiment of the present disclosure.
FIG. 5 schematically shows a block diagram of a decision tree testing apparatus according to an embodiment of the present disclosure.
FIG. 6 schematically illustrates a block diagram of an electronic device suitable for implementing a decision tree testing method in accordance with an embodiment of the present disclosure.
Detailed Description
Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood that the description is illustrative only and is not intended to limit the scope of the present disclosure. In the following detailed description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the embodiments of the disclosure. It may be evident, however, that one or more embodiments may be practiced without these specific details. Moreover, in the following description, descriptions of well-known structures and techniques are omitted so as to not unnecessarily obscure the concepts of the present disclosure.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The terms "comprises," "comprising," and the like, as used herein, specify the presence of stated features, steps, operations, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, or components.
All terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs, unless otherwise defined. It is noted that the terms used herein should be interpreted as having a meaning that is consistent with the context of this specification and should not be interpreted in an idealized or overly formal sense.
Where a convention analogous to "at least one of A, B and C, etc." is used, in general such a construction is intended in the sense one having skill in the art would understand the convention (e.g., "a system having at least one of A, B and C" would include but not be limited to systems that have a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.). Where a convention analogous to "A, B or at least one of C, etc." is used, in general such a construction is intended in the sense one having skill in the art would understand the convention (e.g., "a system having at least one of A, B or C" would include but not be limited to systems that have a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.).
A decision tree is a tree-like structure in which each internal node represents a test on an attribute, each branch represents a test output, and each leaf node represents a category. In the related art, enterprises often orchestrate business logic through decision trees.
However, in the process of modifying and arranging the decision tree, the execution result and the main logic of the decision tree may be affected by adding a new logic node or modifying an existing logic node. To solve this problem, the following scheme is often adopted in the related art to test the decision tree: (1) after the nodes are newly added and modified, the functions and execution results of the nodes are tested; (2) the newly added nodes are arranged in the existing flow, and the execution result of the main flow is tested; (3) after the flow is arranged around the newly added node, testing the execution result of the theme flow; (4) and testing the execution result when adding or modifying nodes to the arranged decision tree.
The solutions of the related art have the following problems: (1) when a logic node is newly added, the node can be arranged in the existing decision tree flow only through the logic of the self-testing node of research personnel, and the execution result of the decision tree is regressed, so that the hidden logic problem is easily caused; (2) when the existing node logic is modified, regression needs to depend on all decision tree flows of the node, the difficulty and complexity of regression are greatly increased along with more organized flows, and if the flows of regression are tested only for a plurality of decision trees, the coverage of all the flows is not strict enough; (3) after nodes are newly added and modified in the programmed decision tree process, when developers self-test the process, time cost and labor cost which are needed to be consumed for covering all logic are large, with the increase of logic nodes, front and back logics of part of the nodes conflict, and when the programming process starts, hidden conflicts are difficult to find.
In view of this, embodiments of the present disclosure provide a method for testing a decision tree, which pre-determines a decision tree path as a criterion of an analysis logic by exhausting decision tree nodes.
In particular, embodiments of the present disclosure provide a decision tree testing method, apparatus, electronic device, readable storage medium, and computer program product. The method comprises the following steps: obtaining a plurality of decision tree paths of a target decision tree, wherein each decision tree path has a leaf node which is represented as an expected result of the decision tree path; screening a plurality of test examples corresponding to a plurality of decision tree paths from an example library; respectively inputting the test cases into a target decision tree to obtain a plurality of execution results; and comparing the expected results with the execution results to obtain a test result of the target decision tree.
In the technical scheme of the disclosure, the acquisition, storage, application and the like of the personal information of the related user all accord with the regulations of related laws and regulations, necessary security measures are taken, and the customs of the public order is not violated.
In the technical scheme of the disclosure, before the personal information of the user is acquired or collected, the authorization or the consent of the user is acquired.
Fig. 1 schematically illustrates an exemplary system architecture to which a decision tree testing method may be applied, according to an embodiment of the present disclosure. It should be noted that fig. 1 is only an example of a system architecture to which the embodiments of the present disclosure may be applied to help those skilled in the art understand the technical content of the present disclosure, and does not mean that the embodiments of the present disclosure may not be applied to other devices, systems, environments or scenarios.
As shown in fig. 1, the system architecture 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104 and a server 105.
The terminal devices 101, 102, 103 may be various electronic devices having a display screen including, but not limited to, smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired and/or wireless communication links, and so forth.
The server 105 may be a server or a server group that provides various services, or may be a cloud server located in the cloud.
Various client applications, such as shopping-like applications, web browser applications, search-like applications, instant messaging tools, mailbox clients, and/or social platform software, etc., may be installed on the terminal devices 101, 102, 103. The user may directly or indirectly orchestrate and modify the decision tree through the client application, which may then be sent to the server 105 through the network 104, where it is tested by the server 105.
It should be noted that the decision tree testing method provided by the embodiment of the present disclosure may be generally executed by the server 105. Accordingly, the decision tree testing apparatus provided by the embodiments of the present disclosure may be generally disposed in the server 105. The decision tree testing method provided by the embodiments of the present disclosure may also be performed by a server or a server cluster that is different from the server 105 and is capable of communicating with the terminal devices 101, 102, 103 and/or the server 105. Accordingly, the decision tree testing apparatus provided in the embodiment of the present disclosure may also be disposed in a server or a server cluster different from the server 105 and capable of communicating with the terminal devices 101, 102, 103 and/or the server 105. Alternatively, the decision tree testing method provided by the embodiment of the present disclosure may also be executed by the terminal device 101, 102, or 103, or may also be executed by another terminal device different from the terminal device 101, 102, or 103. Accordingly, the decision tree testing apparatus provided in the embodiment of the present disclosure may also be disposed in the terminal device 101, 102, or 103, or in another terminal device different from the terminal device 101, 102, or 103.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
FIG. 2 schematically illustrates a flow diagram of a decision tree testing method according to an embodiment of the present disclosure.
As shown in fig. 2, the method includes operations S201 to S204.
In operation S201, a plurality of decision tree paths of a target decision tree are obtained, where each decision tree path has a leaf node, and the leaf node represents an expected result of the decision tree path.
In operation S202, a plurality of test cases corresponding to a plurality of decision tree paths are screened from an example library.
In operation S203, a plurality of test cases are respectively input into the target decision tree, and a plurality of execution results are obtained.
In operation S204, the expected results are compared with the executed results to obtain a test result of the target decision tree.
According to an embodiment of the present disclosure, a plurality of logical nodes and a plurality of leaf nodes may be included in the target decision tree.
According to the embodiment of the present disclosure, the target decision tree may be a decision tree obtained after arrangement, or may be a decision tree obtained after adding, modifying, or deleting a logical node or a leaf node in an original decision tree.
According to embodiments of the present disclosure, each logical node may have multiple logical branches, e.g., each logical node may include three logical branches of "yes", "no", and "abnormal".
According to embodiments of the present disclosure, each leaf node may represent a category of the target decision tree output, for example, in a decision tree applied to a lottery drawing program, the categories of the decision tree output may include prize pool a, prize pool b, prize pool c, and the like.
According to embodiments of the present disclosure, one logical branch of each logical node may be connected to another logical node or leaf node. For example, a "yes" logical branch of the logical node a may connect the logical node B, indicating that, when the logical relationship represented by the logical node a is determined to be yes, the determination of the logical relationship represented by the logical node B is continued; the "no" logical branch of the logical node a may connect the leaf node C, and represents that the category represented by the leaf node C is output when the logical relationship represented by the logical node a is determined as no.
According to embodiments of the present disclosure, a decision tree path may be represented as a path in the target decision tree that is triggered from the first logical node, along a logical branch, and up to a leaf node.
According to the embodiment of the present disclosure, all decision tree paths may be obtained from the target decision tree by exhaustively enumerating each logical node.
According to the embodiment of the disclosure, a plurality of instances may be stored in the instance library, and the instances may be created in a previous testing process or generated by recording information of a user in an actual use process of an application program corresponding to a target decision tree. For example, the application program corresponding to the target decision tree may be a lottery drawing program, and when the user logs in the lottery drawing program to draw a lottery, the program may convert the user information into an instance and store the instance in an instance library after soliciting the user's consent.
According to the embodiment of the disclosure, the test case can be screened from the case base according to the logic node and the logic branch in the decision tree path. There may be one or more test cases corresponding to each decision tree path.
According to an embodiment of the present disclosure, inputting a plurality of test cases into a target decision tree may be inputting a plurality of test cases into an application corresponding to the target decision tree.
According to an embodiment of the present disclosure, for each decision tree path, the attribute represented by the leaf node of the decision tree path is the expected result corresponding to the decision tree path.
According to the embodiment of the disclosure, the expected result and the execution result corresponding to each decision tree path can be compared, and under the condition that the comparison results of all decision tree paths are consistent, the logic of the target decision tree can be considered to be accurate; under the condition that the comparison result of any one of the decision tree paths is inconsistent, it can be considered that a logic error occurs between a plurality of logic nodes in the decision tree path or between a logic node and a leaf node of the decision tree path, and a developer can check the logic node and the leaf node related to the decision tree path, so that the range of the logic error needing to be checked is reduced, and the testing efficiency is improved.
According to the embodiment of the disclosure, when the target decision tree is tested, the decision tree paths of the target decision tree can be exhausted, the test examples are screened from the example library respectively based on each decision tree path, and then the execution result of the test example can be compared with the expected result to determine the test result of the target decision tree. By the technical means, the coverage of the whole process of the target decision tree can be realized, and the technical problems that the conflict between logic nodes is difficult to find when the decision tree is tested and the consumption of labor cost and time cost is high in the related technology are at least partially solved, so that the test cost of the decision tree is effectively reduced, and the logic accuracy of the decision tree is improved.
The method shown in fig. 2 is further described with reference to fig. 3-4 in conjunction with specific embodiments.
FIG. 3 schematically shows a flow chart of a test case screening method according to an embodiment of the present disclosure.
As shown in fig. 3, the method includes operations S301 to S306.
In operation S301, keyword matching is performed in the instance base using fields corresponding to the logical nodes of the decision tree path as keywords.
In operation S302, it is determined whether a first target instance is obtained by matching; in a case that it is determined that the first target instance is obtained by matching, operation S303 is performed; in a case where it is determined that the first target instance is not obtained by the matching, operation S306 is performed.
In operation S303, a filtering is performed in the first target instance based on the logical branch of the logical node.
In operation S304, it is determined whether the second target instance is obtained by screening, and in case it is determined that the second target instance is obtained by screening, operation S305 is performed; in a case where it is determined that the second target instance cannot be filtered, operation S306 is performed.
In operation S305, a preset number of instances are selected from the second target instances as test instances.
In operation S306, a test case is generated based on the field corresponding to the logical node and the logical branch of the logical node.
According to an embodiment of the present disclosure, the method of operations S301 to S306 may be used to obtain a test case of any one decision tree path of the target decision tree.
For example, one of the decision tree paths of the target decision tree may be: a is- > B exception- > exception class. The decision tree path includes logical nodes "A", "B", and leaf nodes denoted as "exception category".
According to embodiments of the present disclosure, a field corresponding to a logical node may be determined, e.g., logical node "a" may correspond to field "IsANode" and logical node "B" may correspond to field "IsBNode".
According to an embodiment of the present disclosure, in executing the method of operation S301, an instance containing the above two keywords may be searched from an instance library as a first target instance using "IsANode" and "IsBNode" as keywords, and the number of the searched first target instances may be zero, one, or multiple.
According to an embodiment of the disclosure, the first target instance may include other keywords, such as "iscnod" and the like, in addition to the keywords "isanod" and "IsBNode", and assuming that "iscnod" corresponds to the logical node "C", the logical node "C" may be a logical node connected after other logical branches of the logical node "B". Thus, after the matching results in the first target instance, further screening may be performed based on the logical branch.
According to embodiments of the present disclosure, attributes of logical nodes may be determined based on logical branches. For example, in the decision tree path, the logical branches of the logical nodes include "yes", "no", and "abnormal", and the attributes of the fields corresponding to the logical nodes include "Y", "N", and "E"; accordingly, the logical branch of the logical node "a" is yes, and the attribute of "IsANode" may be determined to be "Y"; the logical branch of logical node "B" is "abnormal", and the attribute of "ISBNode" may be determined to be "E".
According to an embodiment of the present disclosure, when the method of operation S303 is executed, the second target instance may be filtered from the first target instance based on the attribute "Y" of the keyword "isaanode" and the attribute "E" of the keyword "IsBNode", and the number of the filtered second target instances may be zero, one, or multiple.
According to an embodiment of the present disclosure, the second target example may be as shown in table 1. Wherein, the 'pin': "123456" indicates that the identification of the instance is "123456", and in the case where the instance is converted from user information, the identification of the instance may be the ID of the user; "isanono": "Y" indicates that the logical branch of this instance corresponding to logical node "A" is "Y"; "IsBNode": "E" indicates that the logical branch of this example corresponding to logical node "B" is "E".
TABLE 1
According to the embodiment of the present disclosure, the preset number may be set to 1, and may also be set to any integer greater than 1 according to a specific application scenario, which is not limited herein.
According to the embodiment of the present disclosure, the process of generating the test case may be to convert each logical node and its logical branch in the decision tree path into fields as shown in table 1, fill all the fields in a preset structure template, and then generate a string of characters as the identifier of the example, thereby completing the generation of the test case.
According to the embodiment of the disclosure, the generated test case can be stored in the case base, so that the case can be directly called in the next test, and the test efficiency is improved.
FIG. 4 schematically illustrates a flow diagram of a decision tree testing method according to another embodiment of the present disclosure.
As shown in fig. 4, the method includes operations S401 to S409, where operations S401 to S404 may be performed by a backend server, and operations S405 to S409 may be performed by a front-end device or may be performed by the backend server.
It should be noted that, unless explicitly stated that there is an execution sequence between different operations or there is an execution sequence between different operations in technical implementation, the execution sequence between multiple operations may not be sequential, or multiple operations may be executed simultaneously in the flowchart in this disclosure.
In operation S401, an instance library is called to obtain a test instance meeting the condition.
In operation S402, logical nodes are exhausted and test cases are introduced.
In operation S403, all the decision tree paths obtained after the logical nodes are exhausted are recorded.
In operation S404, an expected result is output.
In operation S405, the acquired test cases are multiplexed.
In operation S406, a test application is invoked in bulk, passing into a test case.
In operation S407, a decision result is output.
In operation S408, the decision results obtained by calling the test application for multiple times are compared to determine an execution result.
In operation S409, the expected result is compared with the execution result.
According to an embodiment of the present disclosure, the methods of operations S401 to S407 may be implemented according to the methods of operations S201 to S204 and the methods of operations S301 to S306, and are not described herein again.
According to embodiments of the present disclosure, the test application may be an application corresponding to a target decision tree.
According to the embodiment of the disclosure, in the process of calling the test application program each time, all test cases can be respectively input into the test application program, and the decision result of the test case in the calling process is obtained.
According to the embodiment of the disclosure, before comparing the expected result with the execution result, the decision result output by the same test case in the process of calling the test application program for multiple times may be compared, and in the case that the multiple decision results are consistent, the execution result of the test case may be determined to be the decision result. By the method, the influence of random errors generated in the running process of the test application program on the test result can be reduced, and the robustness of the decision tree test process is improved.
According to the embodiment of the disclosure, when a decision result inconsistent with other decision results exists in a plurality of decision results, it can be considered that a logic error exists in the decision tree path, and at this time, the path information of the decision tree path corresponding to the test case can be returned to the terminal device of the developer, so that the developer can perform manual verification.
According to the embodiment of the disclosure, comparing the expected result with the execution result may obtain a comparison result, and in the case that the comparison result indicates consistency, it may be considered that no logical error exists in the target decision tree, and the test flow of the target decision tree may be ended. And under the condition that the comparison result shows inconsistency, determining a decision tree path corresponding to the inconsistent comparison result, and returning the decision tree path to the terminal equipment of the developer so as to facilitate the manual verification of the developer. After the developer modifies the decision tree, the decision tree testing method provided by the embodiment of the disclosure can be continuously executed on the modified decision tree.
FIG. 5 schematically shows a block diagram of a decision tree testing apparatus according to an embodiment of the present disclosure.
As shown in fig. 5, the decision tree testing apparatus 500 includes an obtaining module 510, a first processing module 520, a second processing module 530, and a comparing module 540.
An obtaining module 510 is configured to obtain a plurality of decision tree paths of a target decision tree, where each decision tree path has a leaf node, and the leaf node represents an expected result of the decision tree path.
The first processing module 520 is configured to filter a plurality of test cases corresponding to a plurality of decision tree paths from the case base.
The second processing module 530 is configured to input the multiple test cases into the target decision tree, respectively, to obtain multiple execution results.
The comparing module 540 is configured to compare the expected results with the execution results to obtain a test result of the target decision tree.
According to the embodiment of the disclosure, when the target decision tree is tested, the decision tree paths of the target decision tree can be exhausted, the test examples are screened from the example library respectively based on each decision tree path, and then the execution result of the test example can be compared with the expected result to determine the test result of the target decision tree. By the technical means, the coverage of the whole process of the target decision tree can be realized, and the technical problems that the conflict between logic nodes is difficult to find when the decision tree is tested and the consumption of labor cost and time cost is high in the related technology are at least partially solved, so that the test cost of the decision tree is effectively reduced, and the logic accuracy of the decision tree is improved.
According to an embodiment of the present disclosure, the first processing module 520 includes a first processing unit, a second processing unit, and a third processing unit.
And the first processing unit is used for carrying out keyword matching in the example library by taking fields corresponding to the logic nodes of the decision tree paths as keywords for each decision tree path.
And the second processing unit is used for screening in at least one first target instance based on the logic branch of the logic node under the condition that the first target instance is obtained by matching from the instance library.
And the third processing unit is used for selecting a preset number of examples from the second target examples as test examples corresponding to the paths of the decision tree under the condition that the second target examples are obtained by screening from the first target examples.
According to an embodiment of the present disclosure, the decision tree testing apparatus 500 further includes a generation module and a storage module.
And the generating module is used for generating the test example corresponding to the path of the decision tree based on the field corresponding to the logic node and the logic branch of the logic node under the condition that the first target example is obtained from the example base in a non-matching way or under the condition that the second target example is obtained from the first target example in a non-screening way.
And the storage module is used for storing the test examples into the example library.
The second processing module 530 includes a fourth processing unit and a fifth processing unit according to an embodiment of the present disclosure.
And the fourth processing unit is used for inputting the test case into the target decision tree for multiple times for each test case to obtain multiple decision results.
And the fifth processing unit is used for determining the execution result of the test case as the decision result under the condition that the decision results are consistent.
According to an embodiment of the present disclosure, the second processing module 530 further includes a sixth processing unit.
And the sixth processing unit is used for returning the path information of the decision tree path corresponding to the test example to the terminal equipment under the condition that a decision result inconsistent with other decision results exists in the decision results so as to facilitate manual verification.
According to an embodiment of the present disclosure, the decision tree testing apparatus 500 further includes a third processing module.
And the third processing module is used for returning the path information of the decision tree path to the terminal equipment under the condition that the expected result corresponding to the decision tree path is inconsistent with the execution result corresponding to the decision tree path for each decision tree path, so as to conveniently perform manual verification.
Any number of modules, sub-modules, units, sub-units, or at least part of the functionality of any number thereof according to embodiments of the present disclosure may be implemented in one module. Any one or more of the modules, sub-modules, units, and sub-units according to the embodiments of the present disclosure may be implemented by being split into a plurality of modules. Any one or more of the modules, sub-modules, units, sub-units according to embodiments of the present disclosure may be implemented at least in part as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system on a chip, a system on a substrate, a system on a package, an Application Specific Integrated Circuit (ASIC), or may be implemented in any other reasonable manner of hardware or firmware by integrating or packaging a circuit, or in any one of or a suitable combination of software, hardware, and firmware implementations. Alternatively, one or more of the modules, sub-modules, units, sub-units according to embodiments of the disclosure may be at least partially implemented as a computer program module, which when executed may perform the corresponding functions.
For example, any number of the obtaining module 510, the first processing module 520, the second processing module 530 and the comparing module 540 may be combined and implemented in one module/unit/sub-unit, or any one of the modules/units/sub-units may be split into a plurality of modules/units/sub-units. Alternatively, at least part of the functionality of one or more of these modules/units/sub-units may be combined with at least part of the functionality of other modules/units/sub-units and implemented in one module/unit/sub-unit. According to an embodiment of the present disclosure, at least one of the obtaining module 510, the first processing module 520, the second processing module 530 and the comparing module 540 may be implemented at least partially as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system on a chip, a system on a substrate, a system on a package, an Application Specific Integrated Circuit (ASIC), or may be implemented in hardware or firmware by any other reasonable manner of integrating or packaging a circuit, or may be implemented in any one of three implementations of software, hardware and firmware, or in a suitable combination of any of them. Alternatively, at least one of the obtaining module 510, the first processing module 520, the second processing module 530 and the comparing module 540 may be at least partially implemented as a computer program module, which when executed may perform the respective functions.
It should be noted that the decision tree testing apparatus portion in the embodiment of the present disclosure corresponds to the decision tree testing method portion in the embodiment of the present disclosure, and the description of the decision tree testing apparatus portion specifically refers to the decision tree testing method portion, which is not described herein again.
FIG. 6 schematically illustrates a block diagram of an electronic device suitable for implementing a decision tree testing method in accordance with an embodiment of the present disclosure. The electronic device shown in fig. 6 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 6, a computer electronic device 600 according to an embodiment of the present disclosure includes a processor 601, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. Processor 601 may include, for example, a general purpose microprocessor (e.g., a CPU), an instruction set processor and/or associated chipset, and/or a special purpose microprocessor (e.g., an Application Specific Integrated Circuit (ASIC)), among others. The processor 601 may also include onboard memory for caching purposes. Processor 601 may include a single processing unit or multiple processing units for performing different actions of a method flow according to embodiments of the disclosure.
In the RAM 603, various programs and data necessary for the operation of the electronic apparatus 600 are stored. The processor 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. The processor 601 performs various operations of the method flows according to the embodiments of the present disclosure by executing programs in the ROM 602 and/or RAM 603. It is to be noted that the programs may also be stored in one or more memories other than the ROM 602 and RAM 603. The processor 601 may also perform various operations of the method flows according to embodiments of the present disclosure by executing programs stored in the one or more memories.
According to embodiments of the present disclosure, method flows according to embodiments of the present disclosure may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable storage medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 609, and/or installed from the removable medium 611. The computer program, when executed by the processor 601, performs the above-described functions defined in the system of the embodiments of the present disclosure. The systems, devices, apparatuses, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the present disclosure.
The present disclosure also provides a computer-readable storage medium, which may be contained in the apparatus/device/system described in the above embodiments; or may exist separately and not be assembled into the device/apparatus/system. The computer-readable storage medium carries one or more programs which, when executed, implement the method according to an embodiment of the disclosure.
According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium. Examples may include, but are not limited to: a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
For example, according to embodiments of the present disclosure, a computer-readable storage medium may include the ROM 602 and/or RAM 603 described above and/or one or more memories other than the ROM 602 and RAM 603.
Embodiments of the present disclosure also include a computer program product comprising a computer program containing program code for performing the method provided by the embodiments of the present disclosure, when the computer program product is run on an electronic device, the program code being adapted to cause the electronic device to carry out the decision tree testing method provided by the embodiments of the present disclosure.
The computer program, when executed by the processor 601, performs the above-described functions defined in the system/apparatus of the embodiments of the present disclosure. The systems, apparatuses, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the present disclosure.
In one embodiment, the computer program may be hosted on a tangible storage medium such as an optical storage device, a magnetic storage device, or the like. In another embodiment, the computer program may also be transmitted, distributed in the form of a signal on a network medium, downloaded and installed through the communication section 609, and/or installed from the removable medium 611. The computer program containing program code may be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the foregoing.
In accordance with embodiments of the present disclosure, program code for executing computer programs provided by embodiments of the present disclosure may be written in any combination of one or more programming languages, and in particular, these computer programs may be implemented using high level procedural and/or object oriented programming languages, and/or assembly/machine languages. The programming language includes, but is not limited to, programming languages such as Java, C + +, python, the "C" language, or the like. The program code may execute entirely on the user computing device, partly on the user device, partly on a remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., through the internet using an internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions. Those skilled in the art will appreciate that various combinations and/or combinations of features recited in the various embodiments and/or claims of the present disclosure can be made, even if such combinations or combinations are not expressly recited in the present disclosure. In particular, various combinations and/or combinations of the features recited in the various embodiments and/or claims of the present disclosure may be made without departing from the spirit or teaching of the present disclosure. All such combinations and/or associations are within the scope of the present disclosure.
The embodiments of the present disclosure have been described above. However, these examples are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Although the embodiments are described separately above, this does not mean that the measures in the embodiments cannot be used in advantageous combination. The scope of the disclosure is defined by the appended claims and equivalents thereof. Various alternatives and modifications can be devised by those skilled in the art without departing from the scope of the present disclosure, and such alternatives and modifications are intended to be within the scope of the present disclosure.
Claims (10)
1. A decision tree testing method, comprising:
obtaining a plurality of decision tree paths of a target decision tree, wherein each decision tree path has a leaf node which is represented as an expected result of the decision tree path;
screening a plurality of test examples corresponding to the decision tree paths from an example library;
respectively inputting the plurality of test cases into the target decision tree to obtain a plurality of execution results; and
and comparing the expected results with the execution results to obtain a test result of the target decision tree.
2. The method of claim 1, wherein the decision tree path further has at least one logical node, each configured with a logical branch;
wherein the screening a plurality of test instances corresponding to the plurality of decision tree paths from an instance base comprises:
for each decision tree path, performing keyword matching in the example base by taking fields corresponding to the logic nodes of the decision tree path as keywords;
under the condition that a first target instance is obtained from the instance base in a matching mode, screening is carried out in at least one first target instance based on the logic branch of the logic node; and
and under the condition that second target examples are obtained by screening from the first target examples, selecting a preset number of examples from the second target examples as test examples corresponding to the decision tree path.
3. The method of claim 2, further comprising:
generating a test instance corresponding to the decision tree path based on the field corresponding to the logical node and the logical branch of the logical node in case of failing to match a first target instance from the instance base or in case of failing to screen a second target instance from the first target instance; and
and storing the test case into the case base.
4. The method of claim 1, wherein the inputting the plurality of test cases corresponding to the plurality of decision tree paths into the target decision tree respectively to obtain a plurality of execution results comprises:
for each test case, inputting the test case into the target decision tree for multiple times to obtain multiple decision results; and
and determining the execution result of the test case as the decision result under the condition that the decision results are consistent.
5. The method of claim 4, further comprising:
and under the condition that a decision result inconsistent with other decision results exists in the decision results, returning the path information of the decision tree path corresponding to the test example to the terminal equipment so as to perform manual verification.
6. The method of claim 1, further comprising:
and for each decision tree path, under the condition that an expected result corresponding to the decision tree path is inconsistent with an execution result corresponding to the decision tree path, returning the path information of the decision tree path to the terminal equipment so as to perform manual verification.
7. A decision tree testing apparatus comprising:
an obtaining module, configured to obtain multiple decision tree paths of a target decision tree, where each decision tree path has a leaf node, and the leaf node represents an expected result of the decision tree path;
the first processing module is used for screening a plurality of test examples corresponding to the decision tree paths from an example library;
the second processing module is used for respectively inputting the test cases into the target decision tree to obtain a plurality of execution results; and
and the comparison module is used for comparing the expected results with the execution results to obtain the test result of the target decision tree.
8. An electronic device, comprising:
one or more processors;
a memory to store one or more instructions that,
wherein the one or more instructions, when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-6.
9. A computer readable storage medium having stored thereon executable instructions which, when executed by a processor, cause the processor to carry out the method of any one of claims 1 to 6.
10. A computer program product comprising computer executable instructions for implementing the method of any one of claims 1 to 6 when executed.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210447373.8A CN114817036A (en) | 2022-04-26 | 2022-04-26 | Decision tree testing method and device, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210447373.8A CN114817036A (en) | 2022-04-26 | 2022-04-26 | Decision tree testing method and device, electronic equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114817036A true CN114817036A (en) | 2022-07-29 |
Family
ID=82508065
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210447373.8A Pending CN114817036A (en) | 2022-04-26 | 2022-04-26 | Decision tree testing method and device, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114817036A (en) |
-
2022
- 2022-04-26 CN CN202210447373.8A patent/CN114817036A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10956311B2 (en) | White box code concurrency testing for transaction processing | |
WO2019085061A1 (en) | Automatic test management method, apparatus and device for fund system, and storage medium | |
US20210073107A1 (en) | Testing source code changes | |
CN111290941A (en) | Method and device for testing multiple interfaces, computing equipment and medium | |
CN111897724A (en) | Automatic testing method and device suitable for cloud platform | |
US11232020B2 (en) | Fault detection using breakpoint value-based fingerprints of failing regression test cases | |
US11681511B2 (en) | Systems and methods for building and deploying machine learning applications | |
CN111831573A (en) | Method, device, computer system and medium for determining code branch coverage condition | |
US11663113B2 (en) | Real time fault localization using combinatorial test design techniques and test case priority selection | |
CN114281803A (en) | Data migration method, device, equipment, medium and program product | |
CN115080433A (en) | Testing method and device based on flow playback | |
CN113032256B (en) | Automated testing method, apparatus, computer system, and readable storage medium | |
CN113535577A (en) | Application testing method and device based on knowledge graph, electronic equipment and medium | |
CN113918864A (en) | Website page testing method, testing system, testing device, electronic equipment and medium | |
US11347533B2 (en) | Enhanced virtual machine image management system | |
US20230141948A1 (en) | Analysis and Testing of Embedded Code | |
CN116483888A (en) | Program evaluation method and device, electronic equipment and computer readable storage medium | |
CN116166547A (en) | Code change range analysis method, device, equipment and storage medium | |
CN114817036A (en) | Decision tree testing method and device, electronic equipment and storage medium | |
CN111813691B (en) | Test problem investigation method, device, electronic equipment and medium | |
CN117370145A (en) | Program testing method, device, electronic equipment and storage medium | |
CN114116519A (en) | Interface test method and device, electronic equipment and storage medium | |
CN116661857A (en) | Data extraction method, device, equipment and storage medium | |
CN117992051A (en) | Loop detection method, device, equipment, storage medium and program product of codes | |
CN114003492A (en) | Demand test integrated generation method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |