CN110851343A - Test method and device based on decision tree - Google Patents

Test method and device based on decision tree Download PDF

Info

Publication number
CN110851343A
CN110851343A CN201810954871.5A CN201810954871A CN110851343A CN 110851343 A CN110851343 A CN 110851343A CN 201810954871 A CN201810954871 A CN 201810954871A CN 110851343 A CN110851343 A CN 110851343A
Authority
CN
China
Prior art keywords
test
path
decision tree
value
data
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
Application number
CN201810954871.5A
Other languages
Chinese (zh)
Inventor
周雪梅
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201810954871.5A priority Critical patent/CN110851343A/en
Publication of CN110851343A publication Critical patent/CN110851343A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3692Test management for test results analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • G06F18/243Classification techniques relating to the number of classes
    • G06F18/24323Tree-organised classifiers

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Data Mining & Analysis (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Evolutionary Biology (AREA)
  • Evolutionary Computation (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a test method and a test device based on a decision tree, and relates to the technical field of computers. One embodiment of the method comprises: constructing a decision tree based on a decision tree algorithm, and compiling a test case according to the decision tree; reading each path in the decision tree, and generating a test table so as to determine the interval of the path value; selecting a target path value from the interval of the path values, taking the target path value as an input parameter value, and splicing the target path value into a test case; and executing the spliced test case to obtain a test result. The implementation method can solve the technical problem that some test scenes or combination points can be missed.

Description

Test method and device based on decision tree
Technical Field
The invention relates to the technical field of computers, in particular to a test method and a test device based on a decision tree.
Background
With the rapid development of services, new challenges are provided for the traditional function test method and means. Particularly, aiming at the application of flow class, the theoretical idea of test case design is adopted, an effective test case is designed by utilizing a causality graph method, and the automatic test of the case is executed on the basis.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art:
the causality graph method considers the logic provided by the service, if the causality graph method is used in the function test, some test scenes or combination points may be omitted, so that one variable does not influence the result in practice, and the irrelevance (namely the variable does not influence the result) is not tested; in addition, corresponding to a complex business process, maintaining the expected result corresponding to the test case is also complex.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for testing based on a decision tree, so as to solve the technical problem that some test scenarios or combination points may be missed.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a test method based on a decision tree, including:
constructing a decision tree based on a decision tree algorithm, and compiling a test case according to the decision tree;
reading each path in the decision tree, and generating a test table so as to determine the interval of the path value;
selecting a target path value from the interval of the path values, taking the target path value as an input parameter value, and splicing the target path value into a test case;
and executing the spliced test case to obtain a test result.
Optionally, reading each path in the decision tree, and generating a test table, so as to determine an interval of path values, including:
reading each path in the decision tree to generate a test table, wherein each row of data of the test table records each node of a certain path in the decision tree;
filling elements in each row of data of the test table to obtain a fully-combined data table;
and sequentially splicing elements in each row of data in the fully-combined data table according to the sequence of each node in the path, thereby determining the interval of the path value.
Optionally, sequentially concatenating the elements in each row of data in the fully-combined data table according to the order of each node in the path, so as to determine the interval of the path value, including:
converting elements in each row of data in the fully-assembled data table into binary character strings;
sequentially splicing elements in each row of data in the fully-combined data table according to the sequence of each node in the path, thereby obtaining a binary character string corresponding to each row of data;
and respectively converting the binary character string corresponding to each line of data into an int value, thereby determining the interval of the path value.
Optionally, selecting a target path value from the interval of the path values, taking the target path value as a parameter value, and splicing the target path value into a test case, including:
selecting a target path value from the interval of the path values, and converting the target path value into a binary string;
and splicing the binary character strings into the test cases by taking the binary character strings as parameter values.
Optionally, the splicing the binary string into the test case with the binary string as the parameter includes:
taking the binary character string as a reference value, and splitting the binary character string into binary character strings corresponding to all nodes;
and splicing the binary character strings corresponding to the nodes into the test cases according to the sequence of the nodes in the path.
Optionally, the method further comprises:
matching the full combination data table by adopting the target path value to obtain an expected result;
and determining whether the test passes or not by judging whether the expected result is the same as the test structure.
In addition, according to another aspect of the embodiments of the present invention, there is provided a decision tree-based testing apparatus, including:
the construction module is used for constructing a decision tree based on a decision tree algorithm and compiling a test case according to the decision tree;
the reading module is used for reading each path in the decision tree and generating a test table so as to determine the interval of the path value;
the splicing module is used for selecting a target path value from the path value interval, taking the target path value as a parameter value, and splicing the target path value into a test case;
and the test module is used for executing the spliced test case to obtain a test result.
Optionally, the reading module is configured to:
reading each path in the decision tree to generate a test table, wherein each row of data of the test table records each node of a certain path in the decision tree;
filling elements in each row of data of the test table to obtain a fully-combined data table;
and sequentially splicing elements in each row of data in the fully-combined data table according to the sequence of each node in the path, thereby determining the interval of the path value.
Optionally, sequentially concatenating the elements in each row of data in the fully-combined data table according to the order of each node in the path, so as to determine the interval of the path value, including:
converting elements in each row of data in the fully-assembled data table into binary character strings;
sequentially splicing elements in each row of data in the fully-combined data table according to the sequence of each node in the path, thereby obtaining a binary character string corresponding to each row of data;
and respectively converting the binary character string corresponding to each line of data into an int value, thereby determining the interval of the path value.
Optionally, the splicing module is configured to:
selecting a target path value from the interval of the path values, and converting the target path value into a binary string;
and splicing the binary character strings into the test cases by taking the binary character strings as parameter values.
Optionally, the splicing the binary string into the test case with the binary string as the parameter includes:
taking the binary character string as a reference value, and splitting the binary character string into binary character strings corresponding to all nodes;
and splicing the binary character strings corresponding to the nodes into the test cases according to the sequence of the nodes in the path.
Optionally, the test module is further configured to:
matching the full combination data table by adopting the target path value to obtain an expected result;
and determining whether the test passes or not by judging whether the expected result is the same as the test structure.
According to another aspect of the embodiments of the present invention, there is also provided an electronic device, including:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any of the embodiments described above.
According to another aspect of the embodiments of the present invention, there is also provided a computer readable medium, on which a computer program is stored, which when executed by a processor implements the method of any of the above embodiments.
One embodiment of the above invention has the following advantages or benefits: because the technical means of reading each path in the decision tree, generating the test table, determining the interval of the path value and taking the target path value in the interval as the parameter value is adopted, the technical problem that some test scenes or combination points can be missed is solved. The invention utilizes the thought of the decision tree, generates the test table based on the decision tree, obtains the interval of the path value through the full-coverage permutation and combination of each element in the test table, and then takes the path value as the input parameter value to complete the automatic test to obtain the test result. And finally, matching the full combination data table by adopting the path value to obtain an expected result, and comparing whether the test result is the same as the expected result or not, so that the full-coverage automatic test is performed on the service flow, the test efficiency is improved, and the problem of some test scenes or combination points is avoided.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of the main flow of a decision tree based testing method according to one embodiment of the present invention;
FIG. 2 is a schematic diagram of a decision tree structure according to one embodiment of the present invention;
FIG. 3 is a schematic diagram of a main flow of a decision tree based test method according to a referential embodiment of the present invention;
FIG. 4 is a schematic diagram of the main blocks of a decision tree based test apparatus according to an embodiment of the present invention;
FIG. 5 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 6 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server of an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
FIG. 1 is a schematic diagram of the main flow of a decision tree based test method according to one embodiment of the present invention. As an embodiment of the present invention, as shown in fig. 1, the decision tree-based testing method may include:
step 101, constructing a decision tree based on a decision tree algorithm, and compiling a test case according to the decision tree.
Firstly, constructing a decision tree based on a decision tree algorithm, historical data and the like; and then, compiling a test case according to each path in the decision tree and each node in the path.
The decision tree is a tree structure in which each internal node represents a decision on an attribute, each branch represents the output of a decision result, and each leaf node represents a classification result.
As shown in fig. 2, the corresponding decision tree is constructed by taking six characteristics of "whether it is a gift", "whether it is a new gift", "whether it is a warehouse offer is 0", "whether it is an entry class", "whether there is a return policy (RMA)" "whether there is another (such as a residual value)", as an example. Wherein nodes in the decision tree other than leaf nodes represent various features, and the leaf nodes represent output results, such as "new item", "policy of returning or changing", "entry class", "other", and "no matching item". Thus, a corresponding result may be obtained by traversing the paths in the decision tree.
Then, based on the above six features, a feature class is established, and a method judgment with corresponding features is performed to obtain the parameter values corresponding to the features, as shown below, for inputting the parameter values corresponding to the features.
class FEATUREFORCANZHI()
def_init_(self,data):
def zpValue(self):
def xpValue(self):
def cbjValue(self):
def rkValue(self):
def rmaValue(self):
def elseValue(self):
The test results are obtained by calling six methods, namely 'new product', 'returning and changing policy', 'entry class', 'other' and 'no matching item'. For the decision tree shown in fig. 2, there are five result classes, i.e., new product, entry class, return policy, other, no matching item. There is a method in each class to obtain the specific result information corresponding to the class.
And 102, reading each path in the decision tree, and generating a test table so as to determine the interval of the path value.
In this step, each path in the decision tree created in step 101 is read first, so as to produce a test table, and each row of data of the test table records each node of a certain path in the decision tree; then filling elements in each row of data of the test table to obtain a fully-combined data table; and finally, sequentially splicing elements in each row of data in the fully-combined data table according to the sequence of each node in the path, thereby determining the interval of the path value.
Optionally, sequentially concatenating the elements in each row of data in the fully-combined data table according to the order of each node in the path, so as to determine the interval of the path value, including: converting elements in each row of data in the fully-assembled data table into binary character strings; sequentially splicing elements in each row of data in the fully-combined data table according to the sequence of each node in the path, thereby obtaining a binary character string corresponding to each row of data; and respectively converting the binary character string corresponding to each line of data into an int value, thereby determining the interval of the path value.
Still taking the decision tree shown in fig. 2 as an example, the following is illustrated:
1) reading each path (from root node to leaf node) in the decision tree shown in fig. 2, automatically filling a CSV (Comma-Separated Values file format) file, if the corresponding feature is "yes", filling a "1" under the corresponding feature, and if the corresponding feature is "no", filling a "0" under the corresponding feature, thereby generating the following test table:
Figure BDA0001772434920000081
in the test table, each row of data corresponds to each node of a certain path in the decision tree, for example, the first row records a path of line1 [ '1', "," ], corresponding to "being a gift-bin quote is 0-result is new", the second row records a path of line2 [ '1', ",", "' 0',", "1 '," ], corresponding to "being a gift-bin quote is not 0-entry class-there is RMA-result is RMA".
2) And filling elements in each row of data of the test table to obtain a fully-combined data table.
Taking the first line record line1 [ '1', "," ] as an example, each element in the first line is first converted to a binary string and filled in. If the element is 1, filling the element into [1,1 ]; if an element is 0, then the element is filled to [0,0 ]; if an element is empty, the element is filled to [0,1 ]. Each element in line1 is then arranged in full combination in the order of the nodes in the path (i.e., the order of the features in the test table from left to right).
Taking "1" from [1,1], taking "0" from [0,0 ", taking" 0 "or" 1 "from [0,1], performing full combinatorial permutation on each element in line1 in turn, and then removing the repeated permutation combinations to obtain the following full combinatorial permutation data set:
1 0 1 0 0 1
1 1 1 1 1 1
1 1 1 1 0 0
1 0 1 0 0 0
1 1 1 0 0 0
1 0 1 1 1 0
1 0 1 1 0 0
1 0 1 1 1 1
1 1 1 0 1 1
1 0 1 0 1 0
1 0 1 1 0 1
1 1 1 0 1 1
1 0 1 0 1 1
1 1 1 1 1 0
1 1 1 1 0 1
1 1 1 0 1 0
and then sequentially splicing the elements in each row of data after the full combination arrangement, namely forming a binary character string by the elements in the combination arrangement in order, and finally converting the binary character string into an int value to obtain a path value corresponding to the line1, namely that the path value corresponding to [41,63,60,40,56,46,44,47,57,42,45,59,43,62,61,58] is a "new product".
Similarly, the same processing is performed on the second line record line2 [ '1', ", '0', '1', '1'," ], the third line record, the fourth line record, and the like, so as to obtain a fully-combined data table, and then elements in each line of the fully-combined data table are spliced and converted, and finally the interval of the path value is determined to be [0,63 ].
Because the position of the character string which is empty is uncertain, and if the character string is not filled, the arrangement and the combination are inconvenient, the embodiment of the invention improves the convenience in combination by filling first and then carrying out full combination arrangement on each element.
And 103, selecting a target path value from the path value interval, taking the target path value as a parameter value, and splicing the target path value into a test case.
And selecting any one path value from the range of the path values determined in the step 102 as a target path value, converting the target path value into a binary string, and splicing the binary string into the test case in the step 101 by using the binary string as a parameter. And converting the path value into a binary string, and selecting a specific value corresponding to each characteristic by combining the judgment logics of the characteristics to finish the splicing work of the input parameter values.
As another embodiment of the present invention, the splicing the binary string as a parameter into a test case includes: taking the binary character string as a reference value, and splitting the binary character string into binary character strings corresponding to all nodes; and splicing the binary character strings corresponding to the nodes into the test cases according to the sequence of the nodes in the path. I.e. a splice is made to the features to complete the assembly of the test entries.
For example, in the above example, there are a total of six features, i.e., a maximum of 23For 64 combinations, the parameter values are accordingly [0,63]]The path values in the interval. When the logic test of the service is needed, the test work can be automatically completed only by inputting a parameter enumeration.
And 104, executing the spliced test case to obtain a test result.
And executing the spliced test case on the basis of the step 103 to obtain a test result.
For example, the interval of the path value is [0,63], when the input is 0, a non-gift non-new bin quotation non-0 non-entry class non-RMA and an entry object without other logic are obtained, and the entry object is taken to call the test case to obtain the actually called test result.
In yet another embodiment of the present invention, the method further comprises: matching the full combination data table by adopting the target path value to obtain an expected result; and determining whether the test passes or not by judging whether the expected result is the same as the test structure.
Still taking the entry value 0 as an example, matching the full combination data table by using the entry value 0 to obtain that the expected result is 'none', and verifying the actual test result and the expected result to obtain the test result of the path. If the test result is the same as the expected result, the test passes, and if the test result is different from the expected result, the test fails.
According to the various embodiments described above, it can be seen that the present invention solves the problem that some test scenarios or combination points may be missed by adopting the technical means of reading each path in the decision tree, generating a test table, determining the interval of the path values, and using the target path value in the interval as the reference value. That is, the prior art may miss some test scenarios or combination points. The invention utilizes the thought of the decision tree, generates the test table based on the decision tree, obtains the interval of the path value through the full-coverage permutation and combination of each element in the test table, and then takes the path value as the input parameter value to complete the automatic test to obtain the test result. And finally, matching the full combination data table by adopting the path value to obtain an expected result, and comparing whether the test result is the same as the expected result or not, so that the full-coverage automatic test is performed on the service flow, the test efficiency is improved, and the problem of some test scenes or combination points is avoided.
Fig. 3 is a schematic diagram of a main flow of a decision tree based test method according to a referential embodiment of the present invention, and the decision tree based test method may include:
step 301, constructing a decision tree based on a decision tree algorithm, and compiling a test case according to the decision tree;
step 302, reading each path in the decision tree, and generating a test table, wherein each row of data of the test table records each node of a certain path in the decision tree;
step 303, filling elements in each row of data of the test table to obtain a fully-combined data table;
step 304, converting the elements in each row of data in the fully-combined data table into binary character strings;
305, sequentially splicing elements in each row of data in the fully-combined data table according to the sequence of each node in the path, thereby obtaining a binary character string corresponding to each row of data;
step 306, converting the binary character string corresponding to each row of data into int values respectively, thereby determining the interval of the path value;
step 307, selecting a target path value from the path value interval, and converting the target path value into a binary string;
step 308, taking the binary string as a parameter value, and splitting the binary string into binary strings corresponding to each node;
309, splicing the binary character strings corresponding to the nodes into a test case according to the sequence of the nodes in the path;
step 310, executing the spliced test case to obtain a test result;
311, matching the full combination data table with the target path value to obtain an expected result;
step 312, determining whether the test passes by determining whether the expected result is the same as the test structure.
In addition, in a reference embodiment of the present invention, the detailed implementation of the decision tree based test method is described in detail in the above-mentioned decision tree based test method, so that the repeated content will not be described again.
Fig. 4 is a schematic diagram of main modules of a decision tree based test apparatus according to an embodiment of the present invention, and as shown in fig. 4, the decision tree based test apparatus 400 includes a construction module 401, a reading module 402, a splicing module 403, and a test module 404. The building module 401 builds a decision tree based on a decision tree algorithm, and compiles a test case according to the decision tree; the reading module 402 reads each path in the decision tree to generate a test table, so as to determine a path value interval; the splicing module 403 selects a target path value from the interval of the path values, and splices the target path value into a test case by taking the target path value as a parameter value; the test module 404 executes the spliced test case to obtain a test result.
Optionally, the reading module 402 further reads each path in the decision tree to generate a test table, where each row of data of the test table records each node of a certain path in the decision tree; filling elements in each row of data of the test table to obtain a fully-combined data table; and sequentially splicing elements in each row of data in the fully-combined data table according to the sequence of each node in the path, thereby determining the interval of the path value.
Optionally, sequentially concatenating the elements in each row of data in the fully-combined data table according to the order of each node in the path, so as to determine the interval of the path value, including: converting elements in each row of data in the fully-assembled data table into binary character strings; sequentially splicing elements in each row of data in the fully-combined data table according to the sequence of each node in the path, thereby obtaining a binary character string corresponding to each row of data; and respectively converting the binary character string corresponding to each line of data into an int value, thereby determining the interval of the path value.
Optionally, the concatenation module 403 further selects a target path value from the range of path values, and converts the target path value into a binary string; and splicing the binary character strings into the test cases by taking the binary character strings as parameter values.
Optionally, the splicing the binary string into the test case with the binary string as the parameter includes: taking the binary character string as a reference value, and splitting the binary character string into binary character strings corresponding to all nodes; and splicing the binary character strings corresponding to the nodes into the test cases according to the sequence of the nodes in the path.
Optionally, the test module 404 further matches the full combination data table with the target path value to obtain an expected result; and determining whether the test passes or not by judging whether the expected result is the same as the test structure.
According to the various embodiments described above, it can be seen that the present invention solves the problem that some test scenarios or combination points may be missed by adopting the technical means of reading each path in the decision tree, generating a test table, determining the interval of the path values, and using the target path value in the interval as the reference value. That is, the prior art may miss some test scenarios or combination points. The invention utilizes the thought of the decision tree, generates the test table based on the decision tree, obtains the interval of the path value through the full-coverage permutation and combination of each element in the test table, and then takes the path value as the input parameter value to complete the automatic test to obtain the test result. And finally, matching the full combination data table by adopting the path value to obtain an expected result, and comparing whether the test result is the same as the expected result or not, so that the full-coverage automatic test is performed on the service flow, the test efficiency is improved, and the problem of some test scenes or combination points is avoided.
It should be noted that, in the implementation of the decision tree based test apparatus of the present invention, the details are already described in the above decision tree based test method, and therefore, the repeated description is not repeated here.
FIG. 5 illustrates an exemplary system architecture 500 of a decision tree based testing method or decision tree based testing apparatus to which embodiments of the present invention may be applied.
As shown in fig. 5, the system architecture 500 may include terminal devices 501, 502, 503, a network 504, and a server 505. The network 504 serves to provide a medium for communication links between the terminal devices 501, 502, 503 and the server 505. Network 504 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 501, 502, 503 to interact with a server 505 over a network 504 to receive or send messages or the like. The terminal devices 501, 502, 503 may have installed thereon various communication client applications, such as shopping-like applications, web browser applications, search-like applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 501, 502, 503 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 505 may be a server providing various services, such as a background management server (for example only) providing support for shopping websites browsed by users using the terminal devices 501, 502, 503. The background management server may analyze and process the received data such as the product information query request, and feed back a processing result (for example, target push information and product information — only an example) to the terminal device.
It should be noted that the test method based on the decision tree provided in the embodiment of the present invention may be executed on the server 505, or may be executed on the terminal devices 501, 502, and 503. Accordingly, the test device based on the decision tree may be disposed in the server 505, or may be disposed in the terminal equipment 501, 502, 503.
It should be understood that the number of terminal devices, networks, and servers in fig. 5 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 6, a block diagram of a computer system 600 suitable for use with a terminal device implementing an embodiment of the invention is shown. The terminal 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 invention.
As shown in fig. 6, the computer system 600 includes a Central Processing Unit (CPU)601 that 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. In the RAM603, various programs and data necessary for the operation of the system 600 are also stored. The CPU 601, ROM 602, and RAM603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
The following components are connected to the I/O interface 605: an input portion 606 including a keyboard, a mouse, and the like; an output portion 607 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The driver 610 is also connected to the I/O interface 605 as needed. A removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 610 as necessary, so that a computer program read out therefrom is mounted in the storage section 608 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts 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 medium, the computer program comprising program code for performing the method illustrated in 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 performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 601.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, 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), an optical fiber, 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 invention, 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. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
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 invention. 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.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes a build module, a read module, a splice module, and a test module, where the names of the modules do not in some way constitute a limitation on the modules themselves.
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: constructing a decision tree based on a decision tree algorithm, and compiling a test case according to the decision tree; reading each path in the decision tree, and generating a test table so as to determine the interval of the path value; selecting a target path value from the interval of the path values, taking the target path value as an input parameter value, and splicing the target path value into a test case; and executing the spliced test case to obtain a test result.
According to the technical scheme of the embodiment of the invention, because the technical means of reading each path in the decision tree, generating the test table, determining the interval of the path value and taking the target path value in the interval as the input parameter value is adopted, the technical problem that some test scenes or combination points can be missed is solved. The invention utilizes the thought of the decision tree, generates the test table based on the decision tree, obtains the interval of the path value through the full-coverage permutation and combination of each element in the test table, and then takes the path value as the input parameter value to complete the automatic test to obtain the test result. And finally, matching the full combination data table by adopting the path value to obtain an expected result, and comparing whether the test result is the same as the expected result or not, so that the full-coverage automatic test is performed on the service flow, the test efficiency is improved, and the problem of some test scenes or combination points is avoided.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (14)

1. A test method based on decision tree is characterized by comprising the following steps:
constructing a decision tree based on a decision tree algorithm, and compiling a test case according to the decision tree;
reading each path in the decision tree, and generating a test table so as to determine the interval of the path value;
selecting a target path value from the interval of the path values, taking the target path value as an input parameter value, and splicing the target path value into a test case;
and executing the spliced test case to obtain a test result.
2. The method of claim 1, wherein reading each path in the decision tree and generating a test table to determine an interval of path values comprises:
reading each path in the decision tree to generate a test table, wherein each row of data of the test table records each node of a certain path in the decision tree;
filling elements in each row of data of the test table to obtain a fully-combined data table;
and sequentially splicing elements in each row of data in the fully-combined data table according to the sequence of each node in the path, thereby determining the interval of the path value.
3. The method of claim 2, wherein sequentially concatenating the elements in each row of data in the fully assembled data table in the order of the nodes in the path to determine the range of path values comprises:
converting elements in each row of data in the fully-assembled data table into binary character strings;
sequentially splicing elements in each row of data in the fully-combined data table according to the sequence of each node in the path, thereby obtaining a binary character string corresponding to each row of data;
and respectively converting the binary character string corresponding to each line of data into an int value, thereby determining the interval of the path value.
4. The method according to claim 1, wherein selecting a target path value from the range of path values, and stitching the target path value into a test case with the target path value as a parameter, comprises:
selecting a target path value from the interval of the path values, and converting the target path value into a binary string;
and splicing the binary character strings into the test cases by taking the binary character strings as parameter values.
5. The method of claim 4, wherein the splicing the binary string into the test case with the binary string as the parameter comprises:
taking the binary character string as a reference value, and splitting the binary character string into binary character strings corresponding to all nodes;
and splicing the binary character strings corresponding to the nodes into the test cases according to the sequence of the nodes in the path.
6. The method of claim 1, further comprising:
matching the full combination data table by adopting the target path value to obtain an expected result;
and determining whether the test passes or not by judging whether the expected result is the same as the test structure.
7. A decision tree based testing apparatus, comprising:
the construction module is used for constructing a decision tree based on a decision tree algorithm and compiling a test case according to the decision tree;
the reading module is used for reading each path in the decision tree and generating a test table so as to determine the interval of the path value;
the splicing module is used for selecting a target path value from the path value interval, taking the target path value as a parameter value, and splicing the target path value into a test case;
and the test module is used for executing the spliced test case to obtain a test result.
8. The apparatus of claim 7, wherein the read module is configured to:
reading each path in the decision tree to generate a test table, wherein each row of data of the test table records each node of a certain path in the decision tree;
filling elements in each row of data of the test table to obtain a fully-combined data table;
and sequentially splicing elements in each row of data in the fully-combined data table according to the sequence of each node in the path, thereby determining the interval of the path value.
9. The apparatus of claim 8, wherein determining the interval of path values by sequentially concatenating the elements in each row of data in the fully-assembled data table in the order of the nodes in the path comprises:
converting elements in each row of data in the fully-assembled data table into binary character strings;
sequentially splicing elements in each row of data in the fully-combined data table according to the sequence of each node in the path, thereby obtaining a binary character string corresponding to each row of data;
and respectively converting the binary character string corresponding to each line of data into an int value, thereby determining the interval of the path value.
10. The apparatus of claim 7, wherein the splicing module is configured to:
selecting a target path value from the interval of the path values, and converting the target path value into a binary string;
and splicing the binary character strings into the test cases by taking the binary character strings as parameter values.
11. The apparatus of claim 10, wherein the splicing the binary string into the test case with the binary string as the argument comprises:
taking the binary character string as a reference value, and splitting the binary character string into binary character strings corresponding to all nodes;
and splicing the binary character strings corresponding to the nodes into the test cases according to the sequence of the nodes in the path.
12. The apparatus of claim 1, wherein the testing module is further configured to:
matching the full combination data table by adopting the target path value to obtain an expected result;
and determining whether the test passes or not by judging whether the expected result is the same as the test structure.
13. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
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.
14. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-6.
CN201810954871.5A 2018-08-21 2018-08-21 Test method and device based on decision tree Pending CN110851343A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810954871.5A CN110851343A (en) 2018-08-21 2018-08-21 Test method and device based on decision tree

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810954871.5A CN110851343A (en) 2018-08-21 2018-08-21 Test method and device based on decision tree

Publications (1)

Publication Number Publication Date
CN110851343A true CN110851343A (en) 2020-02-28

Family

ID=69594634

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810954871.5A Pending CN110851343A (en) 2018-08-21 2018-08-21 Test method and device based on decision tree

Country Status (1)

Country Link
CN (1) CN110851343A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112418599A (en) * 2020-10-15 2021-02-26 重庆市科学技术研究院 Enterprise growth path planning method and system based on index set
CN113760712A (en) * 2020-10-13 2021-12-07 北京沃东天骏信息技术有限公司 Test evaluation method and device
CN115827497A (en) * 2023-02-16 2023-03-21 江西汉辰信息技术股份有限公司 Test sample generation method and device, readable storage medium and electronic equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050043913A1 (en) * 2003-08-19 2005-02-24 Rex Hyde Method of determining the level of structural coverage testing of test cases which are written for a program that does not provide for structural coverage testing
CN104111920A (en) * 2013-04-16 2014-10-22 华为技术有限公司 Decision-making tree based prediction method and device
CN106294107A (en) * 2015-05-27 2017-01-04 富士通株式会社 The method and apparatus generating the test case of Webpage
CN107577603A (en) * 2017-08-31 2018-01-12 中国科学院软件研究所 A kind of procedure condition sentence automation repair system and method based on test case structure decision tree

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050043913A1 (en) * 2003-08-19 2005-02-24 Rex Hyde Method of determining the level of structural coverage testing of test cases which are written for a program that does not provide for structural coverage testing
CN104111920A (en) * 2013-04-16 2014-10-22 华为技术有限公司 Decision-making tree based prediction method and device
CN106294107A (en) * 2015-05-27 2017-01-04 富士通株式会社 The method and apparatus generating the test case of Webpage
CN107577603A (en) * 2017-08-31 2018-01-12 中国科学院软件研究所 A kind of procedure condition sentence automation repair system and method based on test case structure decision tree

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
梁秉毅;蔡延光;蔡颢;戚远航;黄何列;OLE HEJLESEN;: "基于优化决策树和EM的缺失数据填充算法", 自动化与信息工程, no. 05, 15 October 2017 (2017-10-15) *
马菁;顾景文;: "决策树在软件测试用例生成中的应用", 计算机技术与发展, no. 02, 10 February 2008 (2008-02-10) *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113760712A (en) * 2020-10-13 2021-12-07 北京沃东天骏信息技术有限公司 Test evaluation method and device
CN112418599A (en) * 2020-10-15 2021-02-26 重庆市科学技术研究院 Enterprise growth path planning method and system based on index set
CN112418599B (en) * 2020-10-15 2023-02-10 重庆市科学技术研究院 Enterprise growth path planning method and system based on index set
CN115827497A (en) * 2023-02-16 2023-03-21 江西汉辰信息技术股份有限公司 Test sample generation method and device, readable storage medium and electronic equipment

Similar Documents

Publication Publication Date Title
CN110019080B (en) Data access method and device
WO2021023149A1 (en) Method and apparatus for dynamically returning message
CN109901987B (en) Method and device for generating test data
US20160381151A1 (en) Dynamically generating solution stacks
WO2016101811A1 (en) Information arrangement method and apparatus
CN113076153B (en) Interface calling method and device
CN110851343A (en) Test method and device based on decision tree
CN111339743B (en) Account number generation method and device
CN113626223A (en) Interface calling method and device
CN108959294B (en) Method and device for accessing search engine
CN110795331A (en) Software testing method and device
CN116560661A (en) Code optimization method, device, equipment and storage medium
CN116881166A (en) Method, device and system for generating test script
CN111401684A (en) Task processing method and device
US10877805B2 (en) Optimization of memory usage by integration flows
CN112947919A (en) Method and device for constructing service model and processing service request
CN113536748A (en) Method and device for generating chart data
CN111026629A (en) Method and device for automatically generating test script
CN112256566A (en) Test case preservation method and device
CN112732471A (en) Error correction method and error correction device for interface return data
CN113704242A (en) Data processing method and device
CN113535221A (en) Method and device for managing application version
CN111177183B (en) Method and device for generating database access statement
CN113283923B (en) Resource processing method and device based on block chain
CN112925573B (en) Method, device, equipment and computer readable medium for loading web page

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