CN115225557A - Method and device for generating device test case, device test method and device - Google Patents

Method and device for generating device test case, device test method and device Download PDF

Info

Publication number
CN115225557A
CN115225557A CN202210802903.6A CN202210802903A CN115225557A CN 115225557 A CN115225557 A CN 115225557A CN 202210802903 A CN202210802903 A CN 202210802903A CN 115225557 A CN115225557 A CN 115225557A
Authority
CN
China
Prior art keywords
input variable
path
configuration
independent
flow chart
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
CN202210802903.6A
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.)
Shanghai Dongtu Zhiyuan Intelligent Technology Development Co ltd
Original Assignee
Shanghai Dongtu Zhiyuan Intelligent Technology Development 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 Shanghai Dongtu Zhiyuan Intelligent Technology Development Co ltd filed Critical Shanghai Dongtu Zhiyuan Intelligent Technology Development Co ltd
Priority to CN202210802903.6A priority Critical patent/CN115225557A/en
Publication of CN115225557A publication Critical patent/CN115225557A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/50Testing arrangements

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The embodiment of the application relates to the field of industrial automation, and relates to a method and a device for generating a device test case, a device test method and computing equipment. The specific scheme is as follows: acquiring a configuration input variable from the equipment configuration information; acquiring a processing flow chart formulated according to the configuration input variables; determining a set of independent paths of the process flow graph; aiming at each independent path in the independent path set, obtaining an input variable combination and an expected result corresponding to the independent path; and generating a device test case according to the input variable combination and the expected result. According to the embodiment of the application, a small number of equipment test cases can be used for covering more test points, so that higher test efficiency is achieved, and the use safety of equipment is improved.

Description

Method and device for generating device test case, device test method and device
Technical Field
The invention relates to the field of industrial automation, in particular to a method and a device for generating a device test case, a device test method and a device.
Background
Generally, before a network device is put into use, it is necessary to comprehensively test various aspects such as the configuration and the function of the device. Taking an industrial gateway as an example, many test case design methods of the industrial gateway at present are all designed by using a full black box according to protocol functions, such as equivalence class division, a boundary value method, and the like. The use case input designed by the method is many. However, many product problems in practical application are hidden deeply, and especially, in the case of abnormal testing under the condition of multi-input variable combination, the industrial gateway cannot be tested comprehensively within a limited time. The function is not tested in place, so that the safety problem of the use of the industrial gateway can be caused, and an application platform is damaged.
Disclosure of Invention
In view of the above problems in the prior art, embodiments of the present application provide a method and an apparatus for generating device test cases, a device test method and a device, which can use a small number of device test cases to cover more test points, so as to achieve higher test efficiency, thereby improving the safety of using devices.
In order to achieve the above object, a first aspect of the present application provides a method for generating a device test case, including:
acquiring configuration input variables from the equipment configuration information;
acquiring a processing flow chart formulated according to the configuration input variables;
determining a set of independent paths of the process flow graph;
aiming at each independent path in the independent path set, obtaining an input variable combination and an expected result corresponding to the independent path;
and generating a device test case according to the input variable combination and the expected result.
As a possible implementation manner of the first aspect, the determining the independent path set of the processing flow diagram includes:
determining a trunk path of the processing flow chart, wherein the trunk path is a path formed by branches corresponding to a first value of a judgment result of a judgment node in the processing flow chart;
determining a branch path of the processing flow chart, wherein the branch path comprises at least one branch corresponding to the value except the first value of the judgment result of the judgment node;
and determining an independent path set of the processing flow chart according to the main path and the branch path.
As a possible implementation manner of the first aspect, the obtaining, for each independent path in the independent path set, an input variable combination and an expected result corresponding to the independent path includes:
traversing each judgment node in the independent path to obtain a configuration input variable corresponding to each judgment node;
and obtaining an input variable combination corresponding to the independent path according to the configuration input variable corresponding to each judgment node.
As a possible implementation manner of the first aspect, the obtaining, for each independent path in the independent path set, an input variable combination and an expected result corresponding to the independent path includes:
obtaining an expected result corresponding to each configuration input variable in the input variable combination according to a preset corresponding relation between the configuration input variables and the expected results;
and obtaining an expected result of the input variable combination according to the expected result corresponding to each configuration input variable.
A second aspect of the present application provides an apparatus for generating a device test case, including:
the device comprises a first acquisition unit, a second acquisition unit and a control unit, wherein the first acquisition unit is used for acquiring a configuration input variable from device configuration information;
a second acquisition unit, configured to acquire a processing flowchart formulated according to the configuration input variable;
a determining unit, configured to determine an independent path set of the processing flow chart;
the processing unit is used for obtaining an input variable combination and an expected result corresponding to each independent path in the independent path set;
and the generating unit is used for generating the equipment test case according to the input variable combination and the expected result.
As a possible implementation manner of the second aspect, the determining unit is configured to:
determining a trunk path of the processing flow chart, wherein the trunk path is a path formed by branches corresponding to a first value of a judgment result of a judgment node in the processing flow chart;
determining a branch path of the processing flow chart, wherein the branch path comprises at least one branch corresponding to the value except the first value of the judgment result of the judgment node;
and determining an independent path set of the processing flow chart according to the main path and the branch path.
As a possible implementation manner of the second aspect, the processing unit is configured to:
traversing each judgment node in the independent path to obtain a configuration input variable corresponding to each judgment node;
and obtaining an input variable combination corresponding to the independent path according to the configuration input variable corresponding to each judgment node.
As a possible implementation manner of the second aspect, the processing unit is configured to:
obtaining an expected result corresponding to each configuration input variable in the input variable combination according to a preset corresponding relation between the configuration input variables and the expected results;
and obtaining an expected result of the input variable combination according to the expected result corresponding to each configuration input variable.
A third aspect of the present application provides an apparatus testing method, including:
generating the device test case by adopting the method for generating the device test case in any one of the first aspect;
and testing the case testing equipment by using the equipment.
A fourth aspect of the present application provides a computing device comprising:
a communication interface;
at least one processor coupled with the communication interface; and
at least one memory coupled to the processor and storing program instructions, the program instructions, when executed by the at least one processor, causing the at least one processor to perform the method for generating device test cases according to the first aspect, or the program instructions, when executed by the at least one processor, causing the at least one processor to perform the method for device testing according to the third aspect.
A fifth aspect of the present application provides a computer-readable storage medium, on which program instructions are stored, and when the program instructions are executed by a computer, the computer executes the method for generating the device test case according to any one of the first aspect or the method for testing the device according to the third aspect.
These and other aspects of the invention will be apparent from and elucidated with reference to the embodiment(s) described hereinafter.
Drawings
The various features and the connections between the various features of the present invention are further described below with reference to the attached figures. The figures are exemplary, some features are not shown to scale, and some of the figures may omit features that are conventional in the art to which the application relates and are not essential to the application, or show additional features that are not essential to the application, and the combination of features shown in the figures is not intended to limit the application. In addition, the same reference numerals are used throughout the specification to designate the same components. The specific drawings are illustrated as follows:
fig. 1 is a schematic diagram of an embodiment of a method for generating a device test case according to an embodiment of the present application;
fig. 2 is a processing flow diagram of an embodiment of a method for generating a device test case according to an embodiment of the present application;
fig. 3 is a schematic diagram of an embodiment of a method for generating a device test case according to an embodiment of the present application;
fig. 4 is a schematic diagram of an embodiment of a method for generating a device test case according to an embodiment of the present application;
fig. 5 is a schematic diagram of an embodiment of a method for generating a device test case according to an embodiment of the present application;
fig. 6 is a schematic diagram of an embodiment of a device for generating a device test case according to an embodiment of the present disclosure;
fig. 7 is a schematic diagram of a computing device provided in an embodiment of the present application.
Detailed Description
The terms "first, second, third and the like" or "module a, module B, module C and the like in the description and in the claims, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order, it being understood that specific orders or sequences may be interchanged where permissible to effect embodiments of the present application in other than those illustrated or described herein.
In the following description, reference numbers indicating steps, such as S110, S120 … …, etc., do not necessarily indicate that the steps are executed in this order, and the order of the preceding and following steps may be interchanged or executed simultaneously, if permitted.
The term "comprising" as used in the specification and claims should not be construed as being limited to the contents listed thereafter; it does not exclude other elements or steps. It should therefore be interpreted as specifying the presence of the stated features, integers, steps or components as referred to, but does not preclude the presence or addition of one or more other features, integers, steps or components, and groups thereof. Thus, the expression "an apparatus comprising the devices a and B" should not be limited to an apparatus consisting of only the components a and B.
Reference in the specification to "one embodiment" or "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one embodiment of the invention. Thus, appearances of the phrases "in one embodiment" or "in an embodiment" in various places throughout this specification are not necessarily all referring to the same embodiment, but may. Furthermore, the particular features, structures, or characteristics may be combined in any suitable manner in one or more embodiments, as would be apparent to one of ordinary skill in the art from this disclosure.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. In the case of inconsistency, the meaning described in the present specification or the meaning derived from the content described in the present specification shall control. In addition, the terminology used herein is for the purpose of describing embodiments of the present application only and is not intended to be limiting of the present application.
The prior art method is described first, and then the technical solution of the present application is described in detail.
Before a network device is put into use, it is necessary to comprehensively test various aspects of the configuration, functions and the like of the device to verify whether the configuration and functions of the device can achieve a desired result. Taking an industrial gateway as an example, many test case design methods of the industrial gateway at present are all designed by using a full black box according to protocol functions, such as equivalence class division, a boundary value method, and the like. The use case input designed by the method is many. However, many product problems in practical application are hidden deeply, and especially, in the case of abnormal testing under the condition of multi-input variable combination, the industrial gateway cannot be tested comprehensively within a limited time.
The prior art has the following defects: the designed cases are input in a plurality of ways, and the industrial gateway cannot be comprehensively tested within a limited time. The function is not tested in place, so that the safety problem of the use of the industrial gateway can be caused, and an application platform is damaged.
Based on the technical problems in the prior art, the application provides a method for generating a device test case. The method designs a processing flow by taking the configuration input variables in the configuration information as a reference, generates an equipment test case aiming at each independent path of a processing flow chart, and can find out the full-path test case of the relevant configuration input variables, thereby using a small number of equipment test cases to cover more tests, achieving higher test efficiency, and solving the problems of insufficient test and equipment safety in the prior art.
Fig. 1 is a schematic diagram of an embodiment of a method for generating a device test case according to an embodiment of the present application. As shown in fig. 1, the method for generating the device test case may include:
step S110, obtaining configuration input variables from the equipment configuration information;
step S120, acquiring a processing flow chart formulated according to the configuration input variables;
step S130, determining an independent path set of the processing flow chart;
step S140, aiming at each independent path in the independent path set, obtaining an input variable combination and an expected result corresponding to the independent path;
and S150, generating an equipment test case according to the input variable combination and the expected result.
The embodiment of the application provides a black box test case generation method combined with a basic path method. Specifically, a data opposite-end receiving instrument can be provided to test whether the opposite-end receiving instrument and the device to be tested can normally communicate. In the test process, the opposite-end receiving instrument can be used as a server, and the server is set to be configured into target connection.
Taking the test of an industrial gateway as an example, the device configuration information may include information in a file such as a gateway configuration manual. From the gateway configuration manual, all configuration input variables for establishing a connection can be obtained. All configuration input variables for establishing a connection may be stored in a preset format in the gateway configuration manual in advance. For example: the preset format may include a table, a specific separator, a specific marker, and the like. In step S110, a preset format for storing configuration input variables may be identified in the device configuration information. For example, a table, a specific separator, a specific mark symbol, or the like can be recognized in a predetermined format. And then obtaining the configuration input variables stored according to the preset format. Still taking the test of the industrial gateway as an example, the configuration input variables may include a service IP (Internet Protocol) configuration, a port configuration, a public address configuration, and the like.
After the configuration input variables are obtained, a corresponding processing flow chart can be formulated according to the configuration input variables. Specifically, a serial number of each configuration input variable for establishing connection may be marked first; then, an opposite-end receiving instrument is set to set a server-end configuration as a target connection; and finally, formulating an input variable processing flow chart for establishing connection according to the sequence of the network layer, the transmission layer and the application layer. Fig. 2 is a processing flow chart of an embodiment of a method for generating a device test case according to an embodiment of the present application. As shown in fig. 2, the IP configuration and the port configuration belong to configuration input variables of a network layer, and the public address configuration belongs to configuration input variables of an application layer. Then in the processing flow chart, processing is performed first for IP configuration and port configuration, and then processing is performed for configuration input variables such as public address configuration. In step S120, a processing flowchart formulated according to the above configuration input variables is acquired. And in the subsequent processing process, generating a device test case according to the path information in the processing flow chart.
In step S130, the processing flowchart may be scanned, and the processing nodes are scanned sequentially in the processing order from the start node to the end node. Wherein the decision nodes represented by the diamonds identify different branches in the process flow. By scanning the processing flow chart, the main path and the independent path of the processing flow chart can be obtained. For example, the process flow diagram has N independent paths, and the N independent paths constitute the independent path set of the process flow diagram. In subsequent processes, each individual path in the process flow diagram may be guaranteed to be executed at least once.
In step S140, a relevant input variable combination of each device test case is obtained according to the N independent paths forming the independent path set, and an expected result of the opposite-end receiving instrument under each piece of independent path data is listed. In general, the configuration input variables are extracted from the content of the decision nodes represented by the diamonds in the independent path. Corresponding expected results can be obtained according to the configuration input variables. And combining each configuration input variable and the corresponding expected result to obtain an input variable combination and an expected result corresponding to the independent path.
In step S150, test case paths connecting the receiving instruments at the opposite end are generated one by one according to the input variable combinations and expected results obtained in step S140. And aiming at the N independent paths forming the independent path set, generating a corresponding equipment test case under each independent path.
According to the embodiment of the application, a small number of equipment test cases can be used for covering more test points, so that higher test efficiency is achieved, and the use safety of equipment is improved.
Fig. 3 is a schematic diagram of an embodiment of a method for generating a device test case according to an embodiment of the present application. As shown in fig. 3, in one embodiment, step S130 in fig. 1, the determining the independent path set of the processing flow chart includes:
step S210, determining a trunk path of the processing flow chart, where the trunk path is a path formed by branches corresponding to the first value of the determination result of the determination node in the processing flow chart;
step S220, determining a branch path of the processing flow chart, wherein the branch path comprises at least one branch corresponding to the value except the first value of the judgment result of the judgment node;
step S230, determining an independent path set of the processing flowchart according to the trunk path and the branch path.
In the embodiment of the present application, taking the power protocol IEC104 state quantity input test as an example, all configuration input variables for establishing a connection may be obtained from the IEC104 protocol configuration manual in step S110. For example, the configuration input variables may include a server IP configuration, a port configuration, a public address byte count configuration, a public address configuration, a point number configuration, a value type configuration, and the like. The IP configuration and the port configuration belong to configuration input variables of a network layer, and the public address byte number configuration, the public address configuration, the point number configuration and the value type configuration belong to configuration input variables of an application layer.
A flow chart of the process formulated according to the configuration input variables is shown in fig. 2. As shown in fig. 2, the judgment nodes represented by the diamonds include node 1, node 3, node 6, node 10, node 14, and node 18. The judgment processing executed by the judgment node shown in the node 1 is that whether the server IP is the same as the configuration of the opposite-end instrument, and the configuration input variable corresponding to the node is the server IP configuration. Similarly, the judgment processing performed by the judgment node shown in the node 3 is "whether the port is configured correctly", and the configuration input variable corresponding to the node is the port configuration. In fig. 2, the judgment nodes represented by each diamond correspond to the judgment processes executed by the configuration input variables, which are not described in detail herein.
In step S210, the first value of the determination result of the determination node may be yes. And determining the path formed by the branches corresponding to the judgment result of the judgment node in the processing flow chart as 'yes' as the main path of the processing flow chart. For example, in FIG. 2, the stem path of the process flow diagram can be determined to be 1- >3- >5- >6- >9- >10- >13- >14- >17- >18- >21- >22.
In step S220, it is determined that the other value of the determination result of the node than the first value may be "no". And determining the branch corresponding to the judgment result of the at least one judgment node as 'no' as a branch path of the processing flow chart. For example, in FIG. 2, the branch path of the process flow diagram may be determined to be 1- >2- >22. Specifically, a judgment node of the trunk path may be found according to the processing flow chart, and another independent path branch other than the trunk path is found at the judgment node, that is, the branch path.
In step S230, the trunk paths and branch paths of the processing flow chart are listed, so as to form N independent paths, which form an independent path set of the processing flow chart.
In the example shown in fig. 2, all the independent paths listed are:
route 1:1- >2- >22
Route 2:1- >3- >4- >22
Route 3:1- >3- >5- >6- >7- >8- >10- >13- >14- >17- >18- >21- >22
Path 4:1- >3- >5- >6- >9- >10- >11- >12- >14- >17- >18- >21- >22
Path 5:1- >3- >5- >6- >9- >10- >13- >14- >15- >16- >18- >21- >22
Path 6:1- >3- >5- >6- >9- >10- >13- >14- >17- >18- >19- >20- >22
Path 7:1- >3- >5- >6- >9- >10- >13- >14- >17- >18- >21- >22
The path 7 is a trunk path, and the paths 1 to 6 are branch paths. In an independent set of paths, introducing a new path should include at least a new branch that was not included in the set. Thus, each individual path in the process flow diagram can be guaranteed to be executed at least once in subsequent processes. By utilizing the independent path set, the full path test case of the relevant configuration input variable can be found out, so that more tests can be covered by using a small number of equipment test cases, and higher test efficiency can be achieved.
Fig. 4 is a schematic diagram of an embodiment of a method for generating a device test case according to an embodiment of the present application. As shown in fig. 4, in an embodiment, in step S140 in fig. 1, the obtaining, for each independent path in the independent path set, an input variable combination and an expected result corresponding to the independent path includes:
step S410, traversing each judgment node in the independent path to obtain a configuration input variable corresponding to each judgment node;
step S420, obtaining an input variable combination corresponding to the independent path according to the configuration input variable corresponding to each of the determination nodes.
For each independent path, each judgment node in the independent path can be traversed, and configuration input variables can be extracted from the content of the judgment nodes. For example, for the judgment node 1 in the path 2, the configuration input variable may be extracted from the node content "whether the server IP is the same as the peer instrument configuration". And acquiring the judgment result of the judgment node as yes, and combining the extracted service end IP configuration with the judgment result of yes to obtain the service end IP configuration which is the same as the opposite end instrument. Similarly, for the judgment node 3 in the path 2, the configuration input variable can be extracted from the node content "whether the port configuration is correct" to be the port configuration. And acquiring whether the judgment result of the judgment node is negative, and combining the extracted port configuration and the judgment result of the negative to obtain different ports. The variables are then input according to the two configurations: and (3) server IP configuration and port configuration, and finally obtaining an input variable combination corresponding to the path 2, wherein the server IP configuration is the same as that of an opposite-end instrument and the ports are different.
Fig. 5 is a schematic diagram of an embodiment of a method for generating a device test case according to an embodiment of the present application. As shown in fig. 5, in an embodiment, in step S140 in fig. 1, the obtaining, for each independent path in the independent path set, an input variable combination and an expected result corresponding to the independent path includes:
step S510, obtaining an expected result corresponding to each configuration input variable in the input variable combination according to a preset corresponding relation between the configuration input variables and the expected results;
and step S520, obtaining an expected result of the input variable combination according to the expected result corresponding to each configuration input variable.
In the embodiment of the application, the corresponding relation between the configuration input variable and the expected result can be preset. For example:
1) If the IP configuration of the server is different from that of the opposite-end instrument, the expected result is no connection display and abnormal communication of the opposite-end instrument;
2) If the ports are different, the expected result is no connection display and abnormal communication of the opposite-end instrument;
3) If the server IP and the port configuration are the same, the expected result is that the opposite-end instrument displays connection and interactive messages exist.
According to the above correspondence, a path that the judgment result of the judgment node 1 corresponding to the configuration input variable is "no" can be obtained for the service end IP configuration, and the corresponding expected result is "no connection display of the opposite end instrument, abnormal communication"; for port configuration, the path with the judgment result of the judgment node 3 corresponding to the configuration input variable being "no" also has the corresponding expected result of "no connection display to the opposite end instrument and abnormal communication"; and for the above two configuration input variables, the judgment results of the corresponding judgment nodes 1 and 3 are yes, and the corresponding expected result is 'opposite end instrument display connection with interactive message'.
For another example, if the number of bytes of the public address is configured differently, the expected result is a resolution error. Then the number of bytes of the input variable public address is configured to configure a path with a "no" judgment result of the corresponding judgment node 6, and the corresponding expected result is "interactive message analysis error". As another example, if the public address configurations are different, the expected result is also a resolution error. The input variable public address is configured to configure a path with a "no" judgment result of the corresponding judgment node 10, and the corresponding expected result is also an "interactive message analysis error".
According to the above configuration input variables and the judgment results of the corresponding judgment nodes, the corresponding relationship between the configuration input variables and the expected results can be preset. Then, according to the preset corresponding relationship between the configuration input variables and the expected result, the expected result corresponding to each configuration input variable in the input variable combination and the judgment result in the path obtained in step S420 is obtained. And combining the expected results corresponding to each configuration input variable in the input variable combination to obtain the expected results of the input variable combination.
In another implementation, referring to fig. 2, content identification may also be performed on the nodes represented by the rectangles for each independent path in the processing flow diagram. From the contents of the nodes represented by the rectangles, the expected result corresponding to the branch can be extracted.
Referring to fig. 1 and 2, in step S150, the result of generating the device test case according to the input variable combination and the expected result is as follows:
device test case 1
Input variable combination: the server IP configuration is different from that of the opposite terminal instrument;
it is expected that: and the instrument at the opposite end is not connected to display, and the communication is abnormal.
Device test case 2
Input variable combination: the IP configuration of the server is the same as that of an opposite terminal instrument, and the ports are different;
it is expected that: and the instrument at the opposite end is not connected to display, and the communication is abnormal.
Device test case 3
Input variable combination: the IP configuration and the port configuration of the server are the same, the byte number configuration of the public address is different, and the public address configuration, the point number configuration and the value type configuration are the same;
it is expected that: the opposite end instrument displays connection, and has interactive messages, but the analysis is wrong: the number of public address bytes is different.
Device test case 4
Input variable combination: the IP configuration, the port configuration and the byte number configuration of the public address of the server are the same, the public address configuration is different, and the point number configuration and the value type configuration are the same;
it is expected that: the opposite end instrument displays connection, and has interactive messages, but the analysis is wrong: the public addresses are different.
Device test case 5
Input variable combination: the IP configuration, the port configuration, the byte number configuration and the public address configuration of the server are the same, the point number configuration is different, and the value type configuration is the same;
it is expected that: and the opposite-end instrument displays connection, interactive messages exist, the messages are normally analyzed, and the point numbers are staggered.
Device test case 6
Input variable combination: the IP configuration, the port configuration, the byte number configuration, the public address configuration and the point number configuration of the service end are the same, and the value type configuration is different;
it is expected that: the opposite end instrument displays connection, interactive messages exist, the messages are analyzed normally, the point number change is correct, and the value types are not correct.
Device test case 7
Input variable combination: the IP configuration, the port configuration, the byte number configuration, the public address configuration, the point number configuration and the value type configuration of the service end are the same;
it is expected that: the opposite end instrument displays connection, interactive messages exist, the messages are analyzed normally, the point number change is correct, the value type is correct, and the communication is normal.
Among them, the device test cases 1 to 7 correspond to the paths 1 to 7, respectively. In the above configuration input variables, "common address word" refers to the content in bytes. For example, in an example of the "public address word" test, it may be tested whether the contents represented by the fifth and sixth bytes in the interactive message of the communication protocol are consistent. The data type of the interactive data of the network communication can comprise analog quantity, state quantity, accumulated quantity and the like. For the analog example, the value types may include floating point, integer, etc.
As shown in fig. 6, the present application further provides an embodiment of a device for generating a device test case, and for beneficial effects or technical problems to be solved by the device, reference may be made to descriptions in methods respectively corresponding to the devices, or to descriptions in the summary of the invention, and details are not repeated here.
In an embodiment of the apparatus for generating the device test case, the apparatus includes:
a first obtaining unit 100, configured to obtain a configuration input variable from the device configuration information;
a second obtaining unit 200, configured to obtain a processing flowchart formulated according to the configuration input variable;
a determining unit 300, configured to determine an independent path set of the processing flow chart;
a processing unit 400, configured to obtain, for each independent path in the independent path set, an input variable combination and an expected result corresponding to the independent path;
a generating unit 500, configured to generate a device test case according to the input variable combination and the expected result.
In one embodiment, the determining unit 300 is configured to:
determining a trunk path of the processing flow chart, wherein the trunk path is a path formed by branches corresponding to a first value of a judgment result of a judgment node in the processing flow chart;
determining a branch path of the processing flow chart, wherein the branch path comprises at least one branch corresponding to the value except the first value of the judgment result of the judgment node;
and determining an independent path set of the processing flow chart according to the main path and the branch path.
In one embodiment, the processing unit 400 is configured to:
traversing each judgment node in the independent path to obtain a configuration input variable corresponding to each judgment node;
and obtaining an input variable combination corresponding to the independent path according to the configuration input variable corresponding to each judgment node.
In one embodiment, the processing unit 400 is configured to:
obtaining an expected result corresponding to each configuration input variable in the input variable combination according to a preset corresponding relation between the configuration input variables and the expected results;
and obtaining an expected result of the input variable combination according to the expected result corresponding to each configuration input variable.
The application also provides a corresponding equipment testing method, which comprises the following steps:
generating the equipment test case by adopting the method for generating the equipment test case;
and testing the case testing equipment by using the equipment.
The equipment testing method provided by the embodiment of the invention can be applied to the industrial automation fields of electric power, chemical industry, machinery, light industry and the like. The method can be used for conveniently and efficiently testing the equipment and can be used for testing whether the configuration and the function of the embedded equipment can achieve the expected result. Taking an industrial gateway as an example, as a bridge between an industrial internet device sensing layer and a network layer, the industrial gateway has multiple functions of data communication, edge calculation and the like, and the technical characteristics of the industrial gateway directly influence the overall performance of the industrial internet. By applying the equipment testing method provided by the embodiment of the invention, the full-path test case of the relevant configuration input variable can be found out, more tests are covered by a small number of equipment test cases, and higher testing efficiency is achieved, so that the use safety of the equipment is improved.
Fig. 7 is a schematic structural diagram of a computing device 900 provided in an embodiment of the present application. The computing device 900 includes: a processor 910, a memory 920, and a communication interface 930.
It is to be appreciated that the communication interface 930 in the computing device 900 shown in fig. 7 may be used to communicate with other devices.
The processor 910 may be connected to the memory 920. The memory 920 may be used to store the program codes and data. Therefore, the memory 920 may be a storage unit inside the processor 910, an external storage unit independent of the processor 910, or a component including a storage unit inside the processor 910 and an external storage unit independent of the processor 910.
Optionally, computing device 900 may also include a bus. The memory 920 and the communication interface 930 may be connected to the processor 910 through a bus. The bus may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc.
It should be understood that, in the embodiment of the present application, the processor 910 may employ a Central Processing Unit (CPU). The processor may also be other general purpose processors, digital Signal Processors (DSPs), application Specific Integrated Circuits (ASICs), field Programmable Gate Arrays (FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, and the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. Or the processor 910 may employ one or more integrated circuits for executing related programs to implement the technical solutions provided in the embodiments of the present application.
The memory 920 may include a read-only memory and a random access memory, and provides instructions and data to the processor 910. A portion of the processor 910 may also include non-volatile random access memory. For example, the processor 910 may also store information of the device type.
When the computing device 900 is running, the processor 910 executes the computer-executable instructions in the memory 920 to perform the operational steps of the above-described method.
It should be understood that the computing device 900 according to the embodiment of the present application may correspond to a corresponding main body for executing the method according to the embodiments of the present application, and the above and other operations and/or functions of each module in the computing device 900 are respectively for implementing corresponding flows of each method of the embodiment, and are not described herein again for brevity.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one type of logical functional division, and other divisions may be realized in practice, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The present embodiments also provide a computer-readable storage medium, on which a computer program is stored, the program being used for executing a diversification problem generation method when executed by a processor, the method including at least one of the solutions described in the above embodiments.
The computer storage media of the embodiments of the present application may take any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. 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 (a non-exhaustive list) of the computer readable storage medium would include the following: 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 context of this document, 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.
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, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present application may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It should be noted that the foregoing is only illustrative of the preferred embodiments of the present application and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present application has been described in more detail with reference to the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention.

Claims (10)

1. A method for generating a device test case is characterized by comprising the following steps:
acquiring configuration input variables from the equipment configuration information;
acquiring a processing flow chart formulated according to the configuration input variables;
determining a set of independent paths of the process flow graph;
aiming at each independent path in the independent path set, obtaining an input variable combination and an expected result corresponding to the independent path;
and generating a device test case according to the input variable combination and the expected result.
2. The method of claim 1, wherein determining the set of independent paths for the process flow graph comprises:
determining a trunk path of the processing flow chart, wherein the trunk path is a path formed by branches corresponding to a first value of a judgment result of a judgment node in the processing flow chart;
determining a branch path of the processing flow chart, wherein the branch path comprises at least one branch corresponding to a value except the first value of the judgment result of the judgment node;
and determining an independent path set of the processing flow chart according to the main path and the branch path.
3. The method according to claim 1 or 2, wherein the obtaining, for each independent path in the independent path set, an input variable combination and an expected result corresponding to the independent path comprises:
traversing each judgment node in the independent path to obtain a configuration input variable corresponding to each judgment node;
and obtaining an input variable combination corresponding to the independent path according to the configuration input variable corresponding to each judgment node.
4. The method according to claim 3, wherein obtaining, for each independent path in the independent path set, the input variable combination and the expected result corresponding to the independent path comprises:
obtaining an expected result corresponding to each configuration input variable in the input variable combination according to a preset corresponding relation between the configuration input variables and the expected results;
and obtaining an expected result of the input variable combination according to the expected result corresponding to each configuration input variable.
5. An apparatus for generating a device test case, comprising:
the device comprises a first acquisition unit, a second acquisition unit and a control unit, wherein the first acquisition unit is used for acquiring a configuration input variable from device configuration information;
the second acquisition unit is used for acquiring a processing flow chart formulated according to the configuration input variables;
a determining unit, configured to determine an independent path set of the processing flow chart;
the processing unit is used for obtaining an input variable combination and an expected result corresponding to each independent path in the independent path set;
and the generating unit is used for generating the equipment test case according to the input variable combination and the expected result.
6. The apparatus of claim 5, wherein the determining unit is configured to:
determining a trunk path of the processing flow chart, wherein the trunk path is a path formed by branches corresponding to a first value of a judgment result of a judgment node in the processing flow chart;
determining a branch path of the processing flow chart, wherein the branch path comprises at least one branch corresponding to a value except the first value of the judgment result of the judgment node;
and determining an independent path set of the processing flow chart according to the main path and the branch path.
7. The apparatus according to claim 5 or 6, wherein the processing unit is configured to:
traversing each judgment node in the independent path to obtain a configuration input variable corresponding to each judgment node;
and obtaining an input variable combination corresponding to the independent path according to the configuration input variable corresponding to each judgment node.
8. The apparatus of claim 7, wherein the processing unit is configured to:
obtaining an expected result corresponding to each configuration input variable in the input variable combination according to a preset corresponding relation between the configuration input variables and the expected results;
and obtaining an expected result of the input variable combination according to the expected result corresponding to each configuration input variable.
9. A method of device testing, comprising:
generating the equipment test case by adopting the method for generating the equipment test case according to any one of claims 1 to 4;
and testing the case testing equipment by using the equipment.
10. A computing device, comprising:
a communication interface;
at least one processor coupled with the communication interface; and
at least one memory coupled to the processor and storing program instructions that, when executed by the at least one processor, cause the at least one processor to perform the method for generating a device test case of any one of claims 1-4, or cause the at least one processor to perform the method for device testing of claim 9.
CN202210802903.6A 2022-07-07 2022-07-07 Method and device for generating device test case, device test method and device Pending CN115225557A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210802903.6A CN115225557A (en) 2022-07-07 2022-07-07 Method and device for generating device test case, device test method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210802903.6A CN115225557A (en) 2022-07-07 2022-07-07 Method and device for generating device test case, device test method and device

Publications (1)

Publication Number Publication Date
CN115225557A true CN115225557A (en) 2022-10-21

Family

ID=83609683

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210802903.6A Pending CN115225557A (en) 2022-07-07 2022-07-07 Method and device for generating device test case, device test method and device

Country Status (1)

Country Link
CN (1) CN115225557A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105337801A (en) * 2015-11-10 2016-02-17 上海斐讯数据通信技术有限公司 State machine-based test case design method applicable to switch protocol
CN105391598A (en) * 2015-11-10 2016-03-09 上海斐讯数据通信技术有限公司 Block-box testing case design method based on combination with basic path method
CN107273297A (en) * 2017-06-28 2017-10-20 百度在线网络技术(北京)有限公司 Method and apparatus for generating test case
CN109960639A (en) * 2017-12-14 2019-07-02 北京京东尚科信息技术有限公司 A kind of method and apparatus generating test case

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105337801A (en) * 2015-11-10 2016-02-17 上海斐讯数据通信技术有限公司 State machine-based test case design method applicable to switch protocol
CN105391598A (en) * 2015-11-10 2016-03-09 上海斐讯数据通信技术有限公司 Block-box testing case design method based on combination with basic path method
CN107273297A (en) * 2017-06-28 2017-10-20 百度在线网络技术(北京)有限公司 Method and apparatus for generating test case
CN109960639A (en) * 2017-12-14 2019-07-02 北京京东尚科信息技术有限公司 A kind of method and apparatus generating test case

Similar Documents

Publication Publication Date Title
US8627290B2 (en) Test case pattern matching
US8645761B2 (en) Precise fault localization
US8752023B2 (en) System, method and program product for executing a debugger
US8539466B2 (en) Determining suitable insertion points for string sanitizers in a computer code
EP3264274B1 (en) Input discovery for unknown program binaries
CN111831321A (en) Code coverage rate analysis method and device and electronic equipment thereof
US20190094300A1 (en) Ensuring completeness of interface signal checking in functional verification
CN115344866A (en) Cross-architecture binary executable file vulnerability detection method and system based on symbolic execution
US11119886B2 (en) Software analysis apparatus, software analysis method, and computer readable medium
CN115576828A (en) Test case generation method, device, equipment and storage medium
CN110648126A (en) Payment type configuration method, device, server and storage medium
CN115225557A (en) Method and device for generating device test case, device test method and device
CN115310087A (en) Website backdoor detection method and system based on abstract syntax tree
CN115576831A (en) Test case recommendation method, device, equipment and storage medium
CN111507080B (en) Data quality inspection method and device, electronic equipment and storage medium
CN110866492B (en) Baseline branch identification method and device and computer system
US20150199183A1 (en) Program analysis apparatus and program analysis method
US10565078B2 (en) Detecting and reporting unintended state changes
CN112433943A (en) Method, device, equipment and medium for detecting environment variable based on abstract syntax tree
CN113419739B (en) Node map difference detection method and device, electronic equipment and storage medium
CN116305131B (en) Static confusion removing method and system for script
US9703688B2 (en) Progress metric for combinatorial models
CN116933267B (en) Intelligent contract vulnerability detection method, system and equipment for symbol execution
CN114115907A (en) Instruction detection method and device
CN117251334A (en) Method, device, equipment and medium for checking chip module interface connection

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