A testng-based internet of things device simulation access method, device and medium
By using the TestNG testing framework and simulator, the problem of high equipment resource investment in IoT device access testing is solved, achieving high testing efficiency and saving equipment resources.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-31
- Publication Date
- 2026-03-24
AI Technical Summary
When IoT devices are connected to an IoT platform, physical device testing needs to be specifically configured for different protocols and scenarios, resulting in low testing efficiency and high equipment resource investment.
The TestNG testing framework is used to simulate the access of IoT devices through a simulator, including determining the test scenario, instantiating test data, building the client, and modifying configuration parameters to achieve access simulation under different protocols and scenarios.
It can simulate various test scenarios without physical equipment, improve testing efficiency, reduce equipment resource investment, and achieve efficient IoT platform testing.
Smart Images

Figure CN116074207B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computers, in particular to a TestNG-based Internet of Things device simulation access method, device and medium. BACKGROUND
[0002] Internet of Things technology is widely used in intelligent transportation, environmental protection, public safety, industrial monitoring, environmental monitoring, building lighting control, water system monitoring, food traceability and other fields. However, due to the large number of Internet design industries, the corresponding Internet of Things devices are complex, which makes the Internet of Things system platform face certain difficulties from testing, implementation to application. Therefore, before the Internet of Things platform software goes online, it needs to be fully tested to ensure the function, performance and stability of the software.
[0003] However, when the Internet of Things device accesses the Internet of Things platform, it usually uses UDP, TCP, MQTT, CoAP and other protocols, and each protocol has multiple different scenarios due to different parameter settings. In the actual testing process, testers need to specially set up corresponding physical devices for testing according to different scenarios, which will affect the testing efficiency of the Internet of Things platform when there is a shortage of physical devices. SUMMARY
[0004] In order to solve the above problems, the present application provides a TestNG-based Internet of Things device simulation access method, which comprises:
[0005] determining the test scenario of the Internet of Things device, and instantiating the test data corresponding to the Internet of Things device according to the test scenario;
[0006] determining the access protocol corresponding to the Internet of Things device under the test scenario, constructing the Internet of Things device client corresponding to the Internet of Things device based on the open source library corresponding to the access protocol, and obtaining a simulator composed of the instantiated test data and the client;
[0007] obtaining the configuration file of the TestNG test framework, modifying the configuration parameters in the configuration file according to the test scenario to determine the running environment corresponding to the simulator;
[0008] running the simulator in the running environment through the TestNG test framework to simulate the access of the Internet of Things device to the Internet of Things platform.
[0009] In an implementation manner of the present application, before the test data corresponding to the Internet of Things device is instantiated according to the test scenario, the method further comprises:
[0010] determining a to-be-selected access protocol corresponding to the IoT device; wherein the to-be-selected access protocol at least includes a message queue transmission detection protocol and a transmission control protocol;
[0011] for the message queue transmission detection protocol, determining a plurality of attributes for describing the IoT device and attribute information respectively corresponding to the plurality of attributes, so as to obtain test data corresponding to the IoT device through the attribute information;
[0012] for the transmission control protocol, constructing a transmission control protocol packet transmitted between the IoT device client and the IoT platform, so as to obtain test data corresponding to the IoT device; wherein the transmission control protocol packet at least includes a registration packet, a heartbeat packet and a data packet.
[0013] In an implementation manner of the present application, the test data corresponding to the IoT device is obtained through the attribute information, specifically including:
[0014] constructing a thing model corresponding to the IoT device according to the attribute information respectively corresponding to the plurality of attributes; the thing model is a collection of the attribute information, and the attribute information includes an attribute identifier, an attribute name, an attribute read-write attribute and an attribute data type;
[0015] according to the attribute data type corresponding to the attribute, assigning a random value to an attribute value corresponding to the attribute, so as to obtain the test data corresponding to the IoT device.
[0016] In an implementation manner of the present application, the configuration parameters in the configuration file are modified according to the test scene, so as to determine a running environment corresponding to the simulator, specifically including:
[0017] determining configuration parameters corresponding to the simulator under the test scene; the configuration parameters include an online state, an online quantity, an online time and a data sending frequency of an IoT device client corresponding to the simulator;
[0018] determining a configuration section corresponding to the IoT device client in the configuration file, and configuring the configuration section according to the configuration parameters, so as to determine the running environment corresponding to the simulator.
[0019] In an implementation manner of the present application, the test data is an abstract description of a transmission data type, a transmission data metric scale, an attribute value and a thing model of the IoT device.
[0020] In an implementation manner of the present application, the simulator is executed under the running environment, so as to simulate that the IoT device is connected to an IoT platform, and the method further includes:
[0021] determining an online state of the IoT platform, and determining whether the IoT platform can access the IoT device according to the online state;
[0022] acquiring first simulation running data sent by the simulator and second simulation running data received by the IoT platform, and comparing the first simulation running data with the second simulation running data to verify whether the data amount and data content corresponding to the first simulation running data and the second simulation running data are consistent.
[0023] In an implementation manner of the present application, the simulator is run in the running environment to simulate that the IoT device accesses the IoT platform, and specifically includes:
[0024] based on the running environment, a data sending process corresponding to the simulator is established;
[0025] through the data sending process, the simulator sends the test data to the IoT platform according to a preset data sending frequency.
[0026] In an implementation manner of the present application, after the running environment corresponding to the simulator is determined, the method further includes:
[0027] through a preset synchronization tool class, a running time corresponding to a test main thread in the TestNG test framework is set, so that the simulator can execute the data sending process corresponding thereto within the running time.
[0028] The embodiment of the present application provides an IoT device simulation access device based on TestNG, and the device includes:
[0029] at least one processor; and
[0030] a memory in communication connection with the at least one processor; wherein
[0031] the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to:
[0032] determine a test scenario of an IoT device, and instantiate test data corresponding to the IoT device according to the test scenario;
[0033] determine an access protocol corresponding to the IoT device in the test scenario, construct an IoT device client corresponding to the IoT device based on an open source library corresponding to the access protocol, and obtain a simulator composed of the instantiated test data and the client;
[0034] Obtain the configuration file of the TestNG testing framework, and modify the configuration parameters in the configuration file according to the test scenario to determine the running environment corresponding to the simulator;
[0035] The simulator is run in the runtime environment using the TestNG testing framework to simulate connecting the IoT device to the IoT platform.
[0036] This application provides a non-volatile computer storage medium storing computer-executable instructions, characterized in that the computer-executable instructions are configured as follows:
[0037] Determine the test scenario for the IoT device, and instantiate the test data corresponding to the IoT device based on the test scenario;
[0038] Determine the access protocol corresponding to the IoT device in the test scenario, construct an IoT device client corresponding to the IoT device based on the open source library corresponding to the access protocol, and obtain a simulator composed of the instantiated test data and the client;
[0039] Obtain the configuration file of the TestNG testing framework, and modify the configuration parameters in the configuration file according to the test scenario to determine the running environment corresponding to the simulator;
[0040] The simulator is run in the runtime environment using the TestNG testing framework to simulate connecting the IoT device to the IoT platform.
[0041] The IoT device simulation access method based on TestNG proposed in this application can bring the following benefits:
[0042] The simulator can simulate various test scenarios for IoT devices, eliminating the need to set up dedicated physical equipment to test the IoT platform, effectively reducing the investment of equipment resources. Furthermore, by changing configuration parameters, it enables the simulation of IoT device access under different test scenarios, effectively improving testing efficiency. Attached Figure Description
[0043] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0044] Figure 1 A flowchart illustrating a TestNG-based method for simulating IoT device access is provided in this embodiment of the application.
[0045] Figure 2This is a schematic diagram of the structure of an IoT device simulation access device based on TestNG, provided as an embodiment of this application. Detailed Implementation
[0046] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0047] The technical solutions provided by the various embodiments of this application are described in detail below with reference to the accompanying drawings.
[0048] like Figure 1 As shown in the figure, an embodiment of this application provides a method for simulating IoT device access based on TestNG, comprising:
[0049] S101: Determine the test scenario for the IoT device, and instantiate the corresponding test data for the IoT device based on the test scenario.
[0050] Different IoT devices use different access protocols when connecting to an IoT platform, such as UDP, TCP, MQTT, and CoAP. Since each access protocol uses different parameters, the corresponding application scenarios also differ. Therefore, this application embodiment needs to first determine the test scenario for the IoT device, and then instantiate the corresponding test data for the IoT device under different test scenarios.
[0051] Test data is an abstract description of the data transmission types, data transmission metrics, attribute values, and object models of IoT devices. In this embodiment, test data exists in the form of abstract classes. Commonly used IoT devices are mostly sensor devices. The metrics for transmitted data typically include length, mass, density, area, volume, temperature, and humidity. Data transmission types include integers, strings, single-precision floating-point numbers, double-precision floating-point numbers, Booleans, and enumerations. Device attribute values are important attributes of IoT devices and serve as the carriers of transmitted data. IoT device attributes mainly include attribute identifiers, attribute names, data types, and read / write flags. Based on these attributes, object models describing the specific functions of IoT devices can be constructed.
[0052] The test data required to simulate access to an IoT platform varies greatly depending on the IoT device. For example, to test the access capability of an IoT device using Transmission Control Protocol (TCP), the test data required is TCP data packets. However, to test the access capability of an IoT device using Message Queuing Telemetry Transport (MQTT), since the MQTT protocol is also based on the TCP protocol, but the MQTT protocol only implements the format of the transmitted messages and does not restrict the user protocol format, the MQTT protocol data in this embodiment is in JSON format.
[0053] In one embodiment, before instantiating the test data, it is necessary to first construct the test data corresponding to the IoT device. At this time, it is necessary to determine the candidate access protocol corresponding to the IoT device.
[0054] When the candidate access protocol is MQTT, the IoT device test data is carried through a physical model. The physical model is a collection of attribute information, including attribute identifiers, attribute names, read / write attributes, and attribute data types. Therefore, it is necessary to determine multiple attributes used to describe the IoT device and the corresponding attribute information for each attribute. Based on the attribute information corresponding to each attribute, the physical model corresponding to the IoT device is constructed. The attribute information includes attribute identifiers, attribute names, read / write attributes, and attribute data types. After constructing the physical model corresponding to the IoT device, to simulate a real IoT device, the attribute values corresponding to the physical model need to be assigned values. At this time, random values can be assigned to the attribute values according to the attribute data types, thereby obtaining the test data corresponding to the MQTT device. It should be noted that the random values should be within a certain range to simulate the state of a real IoT device as closely as possible.
[0055] For example, the object model includes attributes such as device status, temperature value, and flow rate. Each attribute includes an attribute identifier, attribute name, attribute read / write attribute, and attribute data type. Taking the temperature value attribute as an example, its attribute identifier is "temperature", its attribute name is "temperature value", its attribute read / write attribute is "r" indicating that the attribute is readable, and its data type is "int". By generating random values for the temperature value, such as 35℃, 27℃, and 10℃, test data corresponding to the IoT device can be generated. This test data can be used to simulate data transmission between the IoT device and the IoT platform, thereby verifying the IoT platform's access capabilities.
[0056] When the candidate access protocol is TCP, the test data needs to be combined with the TCP communication protocol of the IoT platform. In this case, a Transmission Control Protocol (TCP) message needs to be constructed for transmission between the IoT device client and the IoT platform. The constructed TCP message is then used as the test data for the IoT device and transmitted to the IoT platform to verify the IoT platform's access capabilities. The TCP message includes at least a registration message, a heartbeat message, and a data message.
[0057] S102: Determine the access protocol corresponding to the IoT device in the test scenario, build the IoT device client corresponding to the IoT device based on the open source library corresponding to the access protocol, and obtain a simulator composed of instantiated test data and IoT device client.
[0058] After obtaining the instantiated test data, to successfully achieve the connection between the IoT device and the IoT platform and transmit this test data to the IoT platform, it is necessary to simulate and build the IoT device. This embodiment of the application can build an IoT device client corresponding to the IoT device based on the open-source library corresponding to the access protocol, and obtain a simulator composed of the instantiated test data and the IoT device client. The simulator can simulate various test scenarios. Its operating logic mainly involves building corresponding IoT device clients based on the object models and access protocols of different test scenarios, and then simulating real IoT devices through the IoT device clients to send data to the IoT platform.
[0059] IoT devices with different access protocol types can use the corresponding open-source libraries to build IoT device clients. For example, IoT devices using UDP and TCP protocols can choose Netty to build their clients, while IoT devices using the MQTT protocol can choose Eclipse.Paho.
[0060] S103: Obtain the configuration file of the TestNG testing framework, modify the configuration parameters in the configuration file according to the test scenario, and determine the corresponding runtime environment of the simulator.
[0061] Based on the test data and IoT device client obtained from the above process, a running IoT device can be constructed according to different operating parameters in practical applications. At this time, running the test script can achieve the function of establishing a connection between the IoT device and the IoT platform and realizing data reporting. This application embodiment uses the TestNG testing framework to implement the simulator operation. However, in order to meet the testing needs under different testing scenarios, various types of test scenarios can be simulated without dedicated physical devices by modifying the TestNG configuration file. These scenarios include simulating the single operation of a device of a certain protocol type, the batch operation of a device of a certain protocol type, the simultaneous single operation of multiple device types, and the simultaneous batch operation of multiple device types. The data transmission frequency and online time of the simulators for different protocol types can be preset. Especially for test scenarios involving multiple device types, simultaneous batch online operation, and long-term online operation, it is difficult to meet the testing requirements of this scenario using physical devices. Therefore, this application embodiment can improve testing efficiency while reducing the investment in testing equipment resources.
[0062] In one embodiment, to achieve IoT platform performance testing under various scenarios, it is first necessary to obtain the configuration file of the TestNG testing framework, and then determine the configuration parameters corresponding to the simulators of different access protocols in the test scenarios. The configuration parameters include the online status, number of online devices, online time, and data transmission frequency of the IoT device clients corresponding to the simulators. In other words, for each type of simulator with different access protocols, its online status, number of online devices, online time, and data transmission frequency can be determined by setting configuration parameters. For example, in a test scenario where multiple protocol types of devices run in batches simultaneously, both MQTT and TCP IoT devices are online. The number of online MQTT IoT devices can be 10, the data transmission frequency is 1 second / message, and the online time is 5 minutes. The number of online TCP IoT devices can be 5, the data transmission frequency is 10 seconds / message, and the online time is 10 minutes. After determining the configuration parameters corresponding to the simulators, the configuration section corresponding to the IoT device client can be found in the configuration file. The parameters in the configuration section can then be modified and configured according to the above configuration parameters, thus obtaining the runtime environment corresponding to the simulators. The simulator's operating environment corresponds to the testing scenario of IoT devices, indicating whether the currently online IoT devices use a single access protocol or multiple access protocols, and whether the IoT devices are running individually or in batches.
[0063] S104: Using the TestNG testing framework, run a simulator in the runtime environment to simulate connecting IoT devices to the IoT platform.
[0064] After determining the simulator's operating environment, it is necessary to simulate the operation of actual IoT devices using the simulator. This embodiment of the application uses test classes provided by the TestNG testing framework to run the simulator in the operating environment and establish a corresponding data sending process. Through this data sending process, the simulator can send corresponding test data to the IoT platform at a preset data sending frequency, completing the IoT platform access test.
[0065] It should be noted that, in order to solve the problem that the test main thread containing the test class exits before the data sending process during test runtime, this embodiment of the application sets the runtime of the test main thread through the preset synchronization utility class CountDownLatch. By calling the await method in CountDownLatch, the test main thread is kept running continuously. This ensures that the simulator can complete its corresponding data sending process within the runtime of the test main thread, guaranteeing that the data sending process exits first and the test main thread exits later, thus achieving the complete operation of the simulator.
[0066] After running the simulator, its simulation performance needs to be verified. This is to verify both the IoT platform's access capabilities and the data transmission functionality of IoT devices after connection, ensuring data accuracy and volume are guaranteed. Therefore, after simulating the connection of IoT devices to the IoT platform, the platform's online status must be determined to assess its ability to connect. If the IoT platform is online, it indicates its capability to connect devices. Simultaneously, the first set of simulated data sent by the simulator and the second set of simulated data received by the IoT platform must be obtained. Comparing these two sets of data verifies the consistency of data volume and content. If they match, it indicates good data transmission capabilities between the IoT devices and the IoT platform, ensuring the complete and accurate transmission of the vast majority of data.
[0067] The above are embodiments of the methods proposed in this application. Based on the same idea, some embodiments of this application also provide devices and non-volatile computer storage media corresponding to the above methods.
[0068] Figure 2 This is a schematic diagram illustrating the structure of a TestNG-based IoT device simulation access device, as provided in an embodiment of this application. Figure 2 As shown, it includes:
[0069] At least one processor; and,
[0070] At least one processor-communication-connected memory; wherein,
[0071] The memory stores instructions that can be executed by at least one processor, and the instructions, when executed by at least one processor, enable at least one processor to:
[0072] Determine the test scenarios for IoT devices, and instantiate the corresponding test data for IoT devices based on the test scenarios;
[0073] Determine the access protocol corresponding to the IoT device in the test scenario, build the IoT device client corresponding to the IoT device based on the open source library corresponding to the access protocol, and obtain a simulator composed of instantiated test data and IoT device client;
[0074] Obtain the configuration file of the TestNG testing framework, and modify the configuration parameters in the configuration file according to the test scenario to determine the corresponding runtime environment of the simulator;
[0075] The TestNG testing framework is used to run a simulator in a runtime environment to simulate connecting IoT devices to an IoT platform.
[0076] This application provides a non-volatile computer storage medium storing computer-executable instructions, which are configured as follows:
[0077] Determine the test scenarios for IoT devices, and instantiate the corresponding test data for IoT devices based on the test scenarios;
[0078] Determine the access protocol corresponding to the IoT device in the test scenario, build the IoT device client corresponding to the IoT device based on the open source library corresponding to the access protocol, and obtain a simulator composed of instantiated test data and IoT device client;
[0079] Obtain the configuration file of the TestNG testing framework, and modify the configuration parameters in the configuration file according to the test scenario to determine the corresponding runtime environment of the simulator;
[0080] The TestNG testing framework is used to run a simulator in a runtime environment to simulate connecting IoT devices to an IoT platform.
[0081] The various embodiments in this application are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the device and medium embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the description of the method embodiments.
[0082] The devices and media provided in this application are one-to-one with the methods. Therefore, the devices and media also have similar beneficial technical effects as their corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the devices and media will not be repeated here.
[0083] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0084] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0085] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0086] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0087] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0088] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0089] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0090] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0091] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A method for simulating IoT device access based on TestNG, characterized in that, The method includes: Determine the test scenario for the IoT device, and instantiate the test data corresponding to the IoT device based on the test scenario; Determine the access protocol corresponding to the IoT device in the test scenario, construct an IoT device client corresponding to the IoT device based on the open source library corresponding to the access protocol, and obtain a simulator composed of the instantiated test data and the IoT device client; Obtain the configuration file of the TestNG testing framework, and modify the configuration parameters in the configuration file according to the test scenario to determine the running environment corresponding to the simulator; The simulator is run in the runtime environment using the TestNG testing framework to simulate connecting the IoT device to the IoT platform. Based on the test scenario, the configuration parameters in the configuration file are modified to determine the runtime environment corresponding to the simulator, specifically including: Determine the configuration parameters of the simulator in the test scenario; the configuration parameters include the online status, number of online devices, online time and data transmission frequency of the IoT device client corresponding to the simulator; The configuration section corresponding to the IoT device client in the configuration file is determined, and the configuration section is configured according to the configuration parameters to determine the running environment corresponding to the simulator; Running the simulator in the aforementioned operating environment to simulate connecting the IoT device to the IoT platform specifically includes: Based on the aforementioned operating environment, establish the data sending process corresponding to the simulator; The data transmission process enables the simulator to send the test data to the IoT platform at a preset data transmission frequency. After determining the runtime environment corresponding to the simulator, the method further includes: By using a preset synchronization utility class, the runtime of the test main thread in the TestNG test framework is set so that the simulator can complete its corresponding data sending process within the runtime. After executing the simulator in the operating environment to simulate connecting the IoT device to the IoT platform, the method further includes: Determine the online status of the IoT platform, and based on the online status, determine whether the IoT platform can access the IoT device; The system acquires first simulated running data sent by the simulator and second simulated running data received by the IoT platform, and compares the first simulated running data with the second simulated running data to verify whether the data volume and data content corresponding to the first simulated running data and the second simulated running data are consistent.
2. The method for simulating IoT device access based on TestNG according to claim 1, characterized in that, Before instantiating the test data corresponding to the IoT device according to the test scenario, the method further includes: Determine the candidate access protocols corresponding to the IoT device; wherein, the candidate access protocols include at least the Message Queuing Transmission Probe Protocol and the Transmission Control Protocol. For the message queue transmission probe protocol, multiple attributes describing the IoT device and attribute information corresponding to each of the multiple attributes are determined, so as to obtain the test data corresponding to the IoT device through the attribute information; For the aforementioned transmission control protocol, a transmission control protocol message is constructed for transmission between the IoT device client and the IoT platform to obtain test data corresponding to the IoT device; wherein, the transmission control protocol message includes at least a registration message, a heartbeat message, and a data message.
3. The method for simulating IoT device access based on TestNG according to claim 2, characterized in that, The test data corresponding to the IoT device is obtained through the attribute information, specifically including: Based on the attribute information corresponding to the multiple attributes, a device model corresponding to the Internet of Things device is constructed; the device model is a collection of attribute information, and the attribute information includes attribute identifier, attribute name, attribute read / write attribute, and attribute data type. Based on the attribute data type corresponding to the attribute, a random value is assigned to the attribute value corresponding to the attribute to obtain the test data corresponding to the IoT device.
4. The method for simulating IoT device access based on TestNG according to claim 1, characterized in that, The test data is an abstract description of the data transmission type, data transmission measurement scale, attribute values, and object model of the IoT device.
5. An IoT device simulation access device based on TestNG, characterized in that the device... include: At least one processor; as well as, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, enable the at least one processor to: Determine the test scenario for the IoT device, and instantiate the test data corresponding to the IoT device based on the test scenario; Determine the access protocol corresponding to the IoT device in the test scenario, construct an IoT device client corresponding to the IoT device based on the open source library corresponding to the access protocol, and obtain a simulator composed of the instantiated test data and the client; Obtain the configuration file of the TestNG testing framework, and modify the configuration parameters in the configuration file according to the test scenario to determine the running environment corresponding to the simulator; The simulator is run in the runtime environment using the TestNG testing framework to simulate connecting the IoT device to the IoT platform. Based on the test scenario, the configuration parameters in the configuration file are modified to determine the runtime environment corresponding to the simulator, specifically including: Determine the configuration parameters of the simulator in the test scenario; the configuration parameters include the online status, number of online devices, online time and data transmission frequency of the IoT device client corresponding to the simulator; The configuration section corresponding to the IoT device client in the configuration file is determined, and the configuration section is configured according to the configuration parameters to determine the running environment corresponding to the simulator; Running the simulator in the aforementioned operating environment to simulate connecting the IoT device to the IoT platform specifically includes: Based on the aforementioned operating environment, establish the data sending process corresponding to the simulator; The data transmission process enables the simulator to send the test data to the IoT platform at a preset data transmission frequency. After determining the runtime environment corresponding to the simulator, the following is also included: By using a preset synchronization utility class, the runtime of the test main thread in the TestNG test framework is set so that the simulator can complete its corresponding data sending process within the runtime. After executing the simulator in the operating environment to simulate connecting the IoT device to the IoT platform, the method further includes: Determine the online status of the IoT platform, and based on the online status, determine whether the IoT platform can access the IoT device; The system acquires first simulated running data sent by the simulator and second simulated running data received by the IoT platform, and compares the first simulated running data with the second simulated running data to verify whether the data volume and data content corresponding to the first simulated running data and the second simulated running data are consistent.
6. A non-volatile computer storage medium storing computer-executable instructions, characterized in that, The computer-executable instructions are set as follows: Determine the test scenario for the IoT device, and instantiate the test data corresponding to the IoT device based on the test scenario; Determine the access protocol corresponding to the IoT device in the test scenario, construct an IoT device client corresponding to the IoT device based on the open source library corresponding to the access protocol, and obtain a simulator composed of the instantiated test data and the client; Obtain the configuration file of the TestNG testing framework, and modify the configuration parameters in the configuration file according to the test scenario to determine the running environment corresponding to the simulator; The simulator is run in the runtime environment using the TestNG testing framework to simulate connecting the IoT device to the IoT platform. Based on the test scenario, the configuration parameters in the configuration file are modified to determine the runtime environment corresponding to the simulator, specifically including: Determine the configuration parameters of the simulator in the test scenario; the configuration parameters include the online status, number of online devices, online time and data transmission frequency of the IoT device client corresponding to the simulator; The configuration section corresponding to the IoT device client in the configuration file is determined, and the configuration section is configured according to the configuration parameters to determine the running environment corresponding to the simulator; Running the simulator in the aforementioned operating environment to simulate connecting the IoT device to the IoT platform specifically includes: Based on the aforementioned operating environment, establish the data sending process corresponding to the simulator; The data transmission process enables the simulator to send the test data to the IoT platform at a preset data transmission frequency. After determining the runtime environment corresponding to the simulator, the following is also included: By using a preset synchronization utility class, the runtime of the test main thread in the TestNG test framework is set so that the simulator can complete its corresponding data sending process within the runtime. After executing the simulator in the operating environment to simulate connecting the IoT device to the IoT platform, the method further includes: Determine the online status of the IoT platform, and based on the online status, determine whether the IoT platform can access the IoT device; The system acquires first simulated running data sent by the simulator and second simulated running data received by the IoT platform, and compares the first simulated running data with the second simulated running data to verify whether the data volume and data content corresponding to the first simulated running data and the second simulated running data are consistent.
Citation Information
Patent Citations
Automatic verification architecture for Internet of Things
CN110460494A
Internet-of-things device access system and method, electronic device and storage medium
CN111770553A
Internet of Things data platform multi-protocol test efficiency improving method
CN114374632A