Automatic interface testing device for TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) communication
By designing an interface automation test device for TCP and UDP communication, and using external simulation equipment and test drivers to realize automated testing of equipment or software interfaces, the problems of low efficiency and error prone in manual testing in the prior art are solved, and the testing efficiency and quality are improved.
Patent Information
- Application Number
- CN202411808006.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-10
- Publication Date
- 2025-04-18
AI Technical Summary
When conducting interface testing of TCP and UDP communications, the prior art relies on manual testing, which is inefficient and prone to errors. Especially when there are many types of data and large amounts of data, it is difficult to meet the testing needs.
Design an interface automation test device for TCP and UDP communication, and realize automated testing of device or software interfaces through a combination of external simulation equipment and test drivers. The external simulation equipment simulates the external communication equipment or objects of the equipment or software under test, provides input data and receives output data, and responds automatically in real time; the test drive centrally manages and controls the external simulation equipment, schedules the simulation equipment according to the test script, and completes the interface automation test.
Through the interface automated testing device, automated testing of equipment or software interfaces is realized, testing efficiency and quality are improved, and the complexity and error rate of manual testing are reduced, providing guarantees for the stable and reliable operation of equipment or software.
Smart Images

Figure CN119854188A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of interface testing, and in particular relates to an interface automation testing device oriented to TCP and UDP communications. Background Art
[0002] Ethernet communication is widely used in all walks of life. Ethernet communication has many types and flexible configuration. In order to ensure the correctness and reliability of various devices or software during operation, it is necessary to conduct sufficient testing before the equipment or software is put into operation. As an important type of test, interface testing plays an extremely prominent role in the testing of various devices or software that use TCP and UDP as the main communication methods.
[0003] For various devices or software that use TCP and UDP as communication methods, the traditional interface testing method is to connect the computer to the device or software, use the network debugging tool to send raw data instructions to the device or software under test, and observe whether the device or software's actions are consistent with expectations; or collect the output data of the device or software under test, manually analyze the data, and determine whether the device or software works as expected. The traditional testing method relies entirely on manual testing, which combines raw data for testing and observes the results. It is very inefficient and prone to errors. If the types of device or software communication data involved are large and the data volume is large, the network debugging tool is far from meeting the needs of interface testing. Summary of the invention
[0004] 1. Technical issues to be resolved
[0005] The technical problem to be solved by the present invention is: how to construct an interface automation testing device for TCP and UDP communications, support automated testing of device or software interfaces, improve test efficiency and quality, and provide guarantee for stable and reliable operation of devices or software.
[0006] (II) Technical solution
[0007] In order to solve the above technical problems, the present invention provides a method for constructing an interface automation test device for TCP and UDP communication, wherein the interface automation test device is designed to consist of two parts: an external simulation device and a test driver, wherein the external simulation device provides an external communication device or object, i.e., a companion test device or object, for device or software interface testing; the test driver provides automated support for device or software interface testing; the method for constructing the interface automation test device is specifically as follows:
[0008] Step 1: External simulation device identification
[0009] The external simulation device provides input data for the device or software under test, receives output data from the device or software under test, and automatically responds in real time based on the output data to ensure the continuity of the communication process of the device or software under test; the steps of external simulation device identification include:
[0010] (1) Analyze the set L of all TCP and UDP communication links of the device or software under test;
[0011] (2) For the device or software under test, there is a TCP communication link t∈L. If the device or software under test in the TCP communication link t is a TCP server, then the corresponding external communication device or object is a TCP client, that is, the corresponding external simulation device needs to implement the TCP client, and the external simulation device needs to implement the TCP client according to the IP address and connection port number of the TCP server; if the device or software under test in the TCP communication link t is a TCP client, then the corresponding external communication device or object is a TCP server, that is, the corresponding external simulation device needs to implement the TCP server, and the external simulation device needs to implement the TCP server according to the connection port number of the TCP client; an external simulation device can simulate the communication function of one or more TCP communication links. If an external simulation device simulates multiple TCP communication links, the multiple TCP communication links are divided according to the command space to achieve isolation of each communication link;
[0012] (3) For the device or software under test, there is a UDP communication link u∈L. If the device or software under test in the UDP communication link u is a UDP data frame receiver, then the corresponding external communication device or object is a UDP data frame sender, that is, the corresponding external simulation device needs to implement the UDP data frame sender, and the external simulation device needs to implement the UDP data frame sender according to the IP address and port number of the UDP data frame receiver; if the device or software under test in the UDP communication link u is a UDP data frame sender, then the corresponding external communication device or object is a UDP data frame receiver, that is, the corresponding external simulation device needs to implement the UDP data frame receiver, and the external simulation device needs to implement the UDP data frame receiver according to the IP address and port number of the UDP data frame sender; an external simulation device can simulate the communication function of one or more pairs of UDP communication links. If an external simulation device simulates multiple pairs of UDP communication links, the multiple pairs of UDP communication links are divided according to the command space to achieve isolation of each communication link; a pair of UDP communication links includes a UDP data frame sender and a data frame receiver;
[0013] Step 2: External simulation device construction
[0014] Based on the identification of several external simulation devices that need to be built in the first step, an external simulation device is built to replace the external communication device or object of the device or software under test to achieve interactive communication with the device or software under test; the external simulation device consists of three layers: network communication layer, function simulation layer and device control layer;
[0015] (1) Network Communication Layer
[0016] The network communication layer realizes interactive communication with the device or software under test. On the one hand, the network communication layer is responsible for sending network data to the device or software under test and receiving output data from the device or software under test. On the other hand, it receives control from the device control layer of the external simulation device, including establishing connection, disconnecting connection, and sending data.
[0017] (2) Functional simulation layer
[0018] The functional simulation layer realizes the functional simulation of the external communication device or object of the device or software under test, including the simulation of the input, output and interaction timing of the external communication device or object;
[0019] (3) Equipment control layer
[0020] The device control layer provides external management and control interfaces for simulation devices. The device control layer is implemented using remote call technology, publishing the relevant functions for management and control of external simulation devices as interface functions that can be called externally.
[0021] Step 3: Test drive build
[0022] The test driver is used to centrally manage and control external simulation devices, schedule external simulation devices according to the test process described by the test script, and collaboratively complete automated testing of devices or software interfaces.
[0023] The invention also provides an interface automation testing device for TCP and UDP communications constructed based on the method.
[0024] The invention also provides an interface testing method implemented by adopting the device.
[0025] (III) Beneficial effects
[0026] (1) The device or software interface protocol is described by the data model, and the device or software interaction behavior is described by the interaction model, so as to realize the functional simulation of external communication devices or objects based on the interface data, thereby reducing the complexity and difficulty of constructing external test devices or objects.
[0027] (2) By providing external simulation device management and control interfaces, the control capability of external simulation devices is enhanced, and the flexibility and controllability of the test are improved.
[0028] (3) Tests are described through scripts, supporting automated interface testing according to business processes, thus improving test effectiveness and efficiency;
[0029] (4) Through the simulation device registration center, the test driver and the specific external simulation device are completely decoupled, realizing the universalization of the test driver. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 It is a composition and technical principle diagram of the interface automation test device of the present invention;
[0031] Figure 2 It is the composition and technical principle diagram of the external simulation device of the present invention;
[0032] Figure 3 It is a composition and technical principle diagram of the test driver of the present invention. DETAILED DESCRIPTION
[0033] In order to make the purpose, content and advantages of the present invention more clear, the specific implementation methods of the present invention are further described in detail below in conjunction with the drawings and examples.
[0034] The present invention provides a method for constructing an interface automation test device for TCP and UDP communications. The method replaces external communication equipment or objects with simulation equipment, provides input data for the tested equipment or software, receives output data of the equipment or software, and performs real-time automatic response according to the output data to ensure the continuity of the equipment or software communication process; centrally manages external simulation equipment through test drivers, and schedules simulation equipment according to business process tests to collaboratively complete the automatic test of equipment or software interfaces.
[0035] The composition and technical principle diagram of the interface automation test device for TCP and UDP communication are as follows: Figure 1 As shown. The interface automation test device consists of two parts: an external simulation device and a test driver. The external simulation device provides an external communication device or object for the device or software interface test, that is, a companion test device or object; the test driver provides automated support for the device or software interface test. The following details the specific construction steps of the interface automation test device for TCP and UDP communication.
[0036] Step 1: External simulation device identification
[0037] External simulation equipment is mainly used to simulate the external communication equipment or objects of the device or software under test, provide input data for the device or software under test, receive output data from the device or software under test, and make real-time automatic responses based on the output data to ensure the continuity of the communication process of the device or software under test. The main steps of external simulation equipment identification include:
[0038] (1) Analyze the set L of all TCP and UDP communication links of the device or software under test;
[0039] (2) For the device or software under test, there is a TCP communication link t∈L. If the device or software under test in the TCP communication link t is a TCP server, then the corresponding external communication device or object is a TCP client, that is, the corresponding external simulation device needs to implement the TCP client, and the external simulation device needs to implement the TCP client according to the IP address and connection port number of the TCP server; if the device or software under test in the TCP communication link t is a TCP client, then the corresponding external communication device or object is a TCP server, that is, the corresponding external simulation device needs to implement the TCP server, and the external simulation device needs to implement the TCP server according to the connection port number of the TCP client. An external simulation device can simulate the communication function of one or more TCP communication links. If an external simulation device simulates multiple TCP communication links, it is necessary to divide the multiple TCP communication links according to the command space in order to achieve isolation of each communication link.
[0040] (3) For the device or software under test, there is a UDP communication link u∈L. If the device or software under test in the UDP communication link u is a UDP data frame receiver, then the corresponding external communication device or object is a UDP data frame sender, that is, the corresponding external simulation device needs to implement the UDP data frame sender, and the external simulation device needs to implement the UDP data frame sender according to the IP address and port number of the UDP data frame receiver; if the device or software under test in the UDP communication link u is a UDP data frame sender, then the corresponding external communication device or object is a UDP data frame receiver, that is, the corresponding external simulation device needs to implement the UDP data frame receiver, and the external simulation device needs to implement the UDP data frame receiver according to the IP address and port number of the UDP data frame sender. An external simulation device can simulate the communication function of one or more pairs of UDP communication links. If an external simulation device simulates multiple pairs of UDP communication links, the multiple pairs of UDP communication links need to be divided according to the command space to achieve isolation of each communication link. A pair of UDP communication links includes a UDP data frame sender and a data frame receiver.
[0041] Step 2: External simulation device construction
[0042] Based on the identification of several external simulation devices that need to be built in "Step 1, external simulation device identification", build external simulation devices to replace the external communication devices or objects of the device or software under test to achieve interactive communication with the device or software under test. The external simulation device consists of three layers: network communication layer, function simulation layer and device control layer, such as Figure 2 shown.
[0043] (1) Network Communication Layer
[0044] The network communication layer mainly realizes interactive communication with the device or software under test. On the one hand, the network communication layer is responsible for sending network data to the device or software under test, and receiving the output data of the device or software under test. On the other hand, it accepts the control of the "device control layer" of the external simulation device, such as establishing connections, disconnecting connections, sending data, etc.
[0045] (2) Functional simulation layer
[0046] The functional simulation layer mainly realizes the functional simulation of the external communication device or object of the device or software under test, and mainly simulates the input, output and interaction timing of the external communication device or object. The "functional simulation layer" of the external simulation device includes four parts: simulation model, data frame parser, command frame responder and data frame encoder.
[0047] The simulation model mainly includes a data model and an interaction model. The data model describes the device or software interface protocol and is the basis for parsing and identifying request commands, as well as constructing stimulus and response commands. The interaction model describes the device or software interaction behavior and is the basis for implementing real-time response processing. The data frame parser is based on the data model to parse and identify request commands from the device or software output data. The command frame responder is based on the interaction model to complete the real-time response processing of the device or software request command (device or software output data). The data frame encoder is based on the data model to implement the construction of device or software stimulus and response commands (device or software input data).
[0048] (3) Equipment control layer
[0049] The device control layer mainly provides management and control interfaces for simulation devices. The device control layer is implemented using remote call technology, publishing the related functions of external simulation device management and control as interface functions that can be called externally, such as obtaining simulation device information, obtaining simulation device data models, turning on / off devices, turning on / off automatic response functions, turning on / off automatic status feedback functions, sending command frames, preparing command frames, etc.
[0050] Step 3: Test drive build
[0051] The test driver is mainly used to centrally manage and control external simulation devices, schedule external simulation devices according to the test process described by the test script, and collaboratively complete the automated testing of devices or software interfaces. The test driver consists of four parts: script engine, general function library, simulation device related function library, and simulation device registration center. Figure 3 shown.
[0052] The script engine mainly implements the interpretation and operation of the test script, and is the key to realize the automation of device or software interface testing. The general function library provides general operation functions for the test script, such as file operations (opening files, reading data, writing data, closing files, etc.), string operations (string concatenation, string interception, obtaining string length, obtaining characters at a specific position, etc.), and mathematical operations (trigonometric functions, square root functions, maximum value, minimum value, random number generation, etc.).
[0053] The simulation device related function library provides the test script with interface functions for operating the simulation device. These interface functions are encapsulations of the interface functions released by the "device control layer" of the external simulation device, such as obtaining simulation device information, obtaining simulation device data model, turning on / off the device, turning on / off the automatic response function, turning on / off the automatic status return function, sending command frames, preparing command frames, etc. By calling these interface functions, on the one hand, the external simulation device information can be obtained, and then according to the simulation device identification, control commands and stimulus commands can be sent to the simulation device to control the behavior of the simulation device; on the other hand, the external simulation device data model can be obtained, and then according to the simulation device data model, response or stimulus data that meets the reception requirements of the simulation device can be constructed.
[0054] The simulation device registration center mainly realizes the centralized management and maintenance of external simulation devices. According to the name of the external simulation device, the external simulation device proxy object is queried in the "Simulation Device Registration Center", and then the real external simulation device is called through the proxy object to complete the external simulation device status acquisition or behavior control.
[0055] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for constructing an interface automation test device for TCP and UDP communications, characterized in that: The interface automation test device is designed to consist of two parts: an external simulation device and a test driver. The external simulation device provides an external communication device or object for device or software interface testing, that is, a companion test device or object; the test driver provides automated support for device or software interface testing. The construction method of the interface automation test device is as follows: Step 1: External simulation device identification The external simulation device provides input data for the device or software under test, receives output data from the device or software under test, and automatically responds in real time based on the output data to ensure the continuity of the communication process of the device or software under test; the steps of external simulation device identification include: (1) Analyze the set L of all TCP and UDP communication links of the device or software under test; (2) For the device or software under test, there is a TCP communication link t∈L. If the device or software under test in the TCP communication link t is a TCP server, then the corresponding external communication device or object is a TCP client, that is, the corresponding external simulation device needs to implement the TCP client, and the external simulation device needs to implement the TCP client according to the IP address and connection port number of the TCP server; if the device or software under test in the TCP communication link t is a TCP client, then the corresponding external communication device or object is a TCP server, that is, the corresponding external simulation device needs to implement the TCP server, and the external simulation device needs to implement the TCP server according to the connection port number of the TCP client; an external simulation device can simulate the communication function of one or more TCP communication links. If an external simulation device simulates multiple TCP communication links, the multiple TCP communication links are divided according to the command space to achieve isolation of each communication link; (3) For the device or software under test, there is a UDP communication link u∈L. If the device or software under test in the UDP communication link u is a UDP data frame receiver, then the corresponding external communication device or object is a UDP data frame sender, that is, the corresponding external simulation device needs to implement the UDP data frame sender, and the external simulation device needs to implement the UDP data frame sender according to the IP address and port number of the UDP data frame receiver; if the device or software under test in the UDP communication link u is a UDP data frame sender, then the corresponding external communication device or object is a UDP data frame receiver, that is, the corresponding external simulation device needs to implement the UDP data frame receiver, and the external simulation device needs to implement the UDP data frame receiver according to the IP address and port number of the UDP data frame sender; an external simulation device can simulate the communication function of one or more pairs of UDP communication links. If an external simulation device simulates multiple pairs of UDP communication links, the multiple pairs of UDP communication links are divided according to the command space to achieve isolation of each communication link; a pair of UDP communication links includes a UDP data frame sender and a data frame receiver; Step 2: External simulation device construction Based on the identification of several external simulation devices that need to be built in the first step, an external simulation device is built to replace the external communication device or object of the device or software under test to achieve interactive communication with the device or software under test; the external simulation device consists of three layers: network communication layer, function simulation layer and device control layer; (1) Network Communication Layer The network communication layer realizes interactive communication with the device or software under test. On the one hand, the network communication layer is responsible for sending network data to the device or software under test and receiving output data from the device or software under test. On the other hand, it receives control from the device control layer of the external simulation device, including establishing connection, disconnecting connection, and sending data. (2) Functional simulation layer The functional simulation layer realizes the functional simulation of the external communication device or object of the device or software under test, including the simulation of the input, output and interaction timing of the external communication device or object; (3) Equipment control layer The device control layer provides external management and control interfaces for simulation devices. The device control layer is implemented using remote call technology, publishing the relevant functions for management and control of external simulation devices as interface functions that can be called externally. Step 3: Test drive build The test driver is used to centrally manage and control external simulation devices, schedule external simulation devices according to the test process described by the test script, and collaboratively complete automated testing of devices or software interfaces.
2. The method according to claim 1, characterized in that The functional simulation layer of the external simulation device includes four parts: simulation model, data frame parser, command frame responder and data frame encoder; the simulation model includes data model and interaction model. The data model describes the device or software interface protocol and is the basis for parsing and identifying request commands and constructing stimulus and response commands; the interaction model describes the device or software interaction behavior and is the basis for achieving real-time response processing. The data frame parser is based on the data model to parse and identify request commands from the device or software output data; The command frame responder completes the real-time response processing of the device or software request command based on the interaction model; The data frame encoder implements the construction of device or software stimulus and response commands based on the data model.
3. The method according to claim 2, characterized in that The device or software request command is the output data of the device or software.
4. The method according to claim 2, characterized in that Device or software stimulus and response commands are input data for the device or software.
5. The method according to claim 2, characterized in that The related functions for managing and controlling external simulation devices include obtaining simulation device information, obtaining simulation device data model, turning on / off the device, turning on / off the automatic response function, turning on / off the automatic status feedback function, sending command frames, and preparing command frames.
6. The method according to claim 2, characterized in that The test driver consists of four parts: script engine, general function library, simulation device related function library, and simulation device registration center. The script engine implements the interpretation and operation of test scripts, which is the key to realize the automation of device or software interface testing. The general function library provides general operation functions for test scripts. The simulation device related function library provides interface functions for operating simulation devices for test scripts. These interface functions are encapsulations of interface functions released by the device control layer of external simulation devices. By calling these interface functions, on the one hand, it is possible to obtain external simulation device information, and then send control commands and stimulus commands to the simulation device according to the simulation device identification to control the behavior of the simulation device. On the other hand, it is possible to obtain an external simulation device data model, and then construct response or stimulus data that meets the reception requirements of the simulation device according to the simulation device data model; The simulation device registration center realizes centralized management and maintenance of external simulation devices. According to the name of the external simulation device, the simulation device registration center queries the external simulation device proxy object, and then calls the real external simulation device through the proxy object to complete the external simulation device status acquisition or behavior control.
7. The method according to claim 6, characterized in that The operation functions provided by the general function library for the test script involve file operations, string operations, and mathematical operations.
8. The method according to any one of claims 1 to 7, characterized in that Used in the field of interface testing technology.
9. An interface automation testing device for TCP and UDP communications constructed based on the method as claimed in any one of claims 1 to 8.
10. An interface testing method implemented by the device as claimed in claim 9.