Internet of Things equipment testing method and device, electronic equipment and storage medium
By automatically generating test cases in virtual machines, the problem of low efficiency in IoT device testing is solved and an efficient automated testing process is achieved.
Patent Information
- Application Number
- CN202511044691.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-28
- Publication Date
- 2025-09-16
AI Technical Summary
In the existing technology, test cases need to be manually written for different types of IoT devices, resulting in low testing efficiency.
By creating a virtual machine, providing the operating environment and tools required for testing, automatically generating test cases and running them to test IoT devices, reducing the need for manual writing.
It improves the efficiency of IoT device testing, reduces the time for manually writing test cases, and reduces hardware resource requirements and user labor intensity.
Smart Images

Figure CN120658634A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of Internet of Things technology, and in particular to an Internet of Things device testing method, apparatus, electronic device, and storage medium. Background Art
[0002] Internet of Things (IoT) devices are the fundamental building blocks of IoT systems. They are intelligent devices capable of collecting, transmitting, or receiving data. IoT devices enable interaction between the physical and digital worlds through sensors, software, or embedded systems. These devices are used in smart homes, building control, industrial, healthcare, and other fields. During the production and deployment of IoT devices, they must be tested to ensure that their functions are functioning properly.
[0003] Currently, test cases are manually written for different types of IoT devices. After the IoT devices are tested using the test cases, the test results of the IoT devices are determined based on the test output data.
[0004] However, due to the diverse types of IoT devices, even if the requirements documents and workflows of multiple IoT devices included in the same suite are similar, test cases for each type of IoT device still need to be manually written, resulting in low efficiency in IoT device testing. Summary of the Invention
[0005] In view of this, the IoT device testing method, apparatus, electronic device, and storage medium provided in the present disclosure can improve the testing efficiency of IoT devices.
[0006] According to a first aspect of an embodiment of the present disclosure, a method for testing an IoT device is provided, comprising: running a virtual machine for IoT device testing, wherein the virtual machine provides at least one of an operating environment, development tools, a development environment, and a development kit required for testing the IoT device; importing test requirement information of the IoT device to be tested into the virtual machine; generating a test case based on the virtual machine according to the test requirement information, running the test case to test the IoT device to be tested, and generating a test report based on the test results.
[0007] In one possible implementation, generating test cases based on the test requirement information includes: converting the test requirement information in a tabular format into a first file in a data exchange format, wherein the first file includes multiple first data groups, each first data group includes at least one data point, the data points included in the same first data group correspond to the same upper-level resource locator, and the data points included in different first data groups correspond to different upper-level resource locators; generating multiple test cases based on the first file, wherein different first data groups correspond to different test cases.
[0008] In one possible implementation, generating multiple test cases based on the first file includes: generating the title, storage path and header file of the test case corresponding to each of the first data groups included in the first file; and generating the use case code and assertion code of the test case corresponding to the first data group based on the data included in the first data group.
[0009] In one possible implementation, the method further includes: converting the test requirement information in tabular form into a second file in a data exchange format; wherein the second file includes multiple one-dimensional arrays, and the second file is used to provide reference data for judging the test results of the first test case, and the first test case is the test case used to test individual data points in the first data group.
[0010] In one possible implementation, the method further includes: converting the test requirement information in tabular form into a third file in a data exchange format; wherein the third file includes multiple second data groups, each second data group includes at least one data point, the data points included in the same second data group correspond to the same upper-level resource locator, and the second data group does not include a data point whose corresponding last-level resource locator is the upper-level resource locator; the second data group provides reference data for judging the test results of the second test case, and the second test case is the test case used to test the collection information of the data points included in the second data group.
[0011] In one possible implementation, running the test case to test the IoT device to be tested includes: running the test case based on the core logic code built into the virtual machine to test the IoT device to be tested, wherein the core logic code includes a code file and a resource file, the code file includes at least one of a sending request code, a verification response code, a parsing scenario code, and a connection router code, and the resource file includes at least one of an automated testing framework keyword and a public parameter.
[0012] In one possible implementation, the method further includes: obtaining network information built into the virtual machine for establishing a communication connection with the IoT device to be tested, wherein the network information includes the IP address of the gateway, the user name for logging into the gateway, the password for logging into the gateway, the serial number of the IoT device to be tested, the network identifier of the IoT device to be tested, and at least one of the pre-shared key of the IoT device to be tested.
[0013] According to a second aspect of an embodiment of the present disclosure, an IoT device testing apparatus is provided, comprising: a loading unit for running a virtual machine for IoT device testing, wherein the virtual machine provides at least one of an operating environment, development tools, a development environment, and a development package required for testing the IoT device; an import unit for importing test requirement information of the IoT device to be tested into the virtual machine; a testing unit for generating test cases based on the virtual machine and the test requirement information, running the test cases to test the IoT device to be tested, and generating a test report based on the test results.
[0014] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, comprising: a processor, a communication interface, a memory, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other via the communication bus; the memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform operations corresponding to the Internet of Things device testing method provided in the first aspect above.
[0015] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which computer instructions are stored. When the computer instructions are executed by a processor, the processor performs operations corresponding to the Internet of Things device testing method provided in the first aspect above.
[0016] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, which is tangibly stored on a computer-readable medium and includes computer-executable instructions, which, when executed, cause at least one processor to perform operations corresponding to the Internet of Things device testing method provided in the first aspect above.
[0017] Using the above technical solution, after creating a virtual machine and importing the test requirements of the IoT device to be tested into the virtual machine, the test software running in the virtual machine can automatically generate test cases based on the test requirements, run the test cases to test the IoT device to be tested, and then automatically generate a test report based on the test results. Because the virtual machine provides the various environments, drivers, development kits, and core logic required to test IoT devices, based on these pre-configured test support conditions, the test software in the running virtual machine can automatically generate test cases and test the IoT device to be tested, eliminating the need for users to manually write test cases, thereby improving the efficiency of IoT device testing. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 This is a flow chart of a method for testing an IoT device provided by an embodiment of the present disclosure;
[0019] Figure 2 Schematic diagram of an IoT device testing device provided by an embodiment of the present disclosure;
[0020] Figure 3 is a schematic diagram of an electronic device provided by an embodiment of the present disclosure.
[0021] List of reference numerals:
[0022] 100: IoT device testing method 101-104: Method steps 200: IoT device testing device
[0023] 201: Loading unit 202: Import unit 203: Test unit
[0024] 300: Electronic device 302: Processor 304: Communication interface
[0025] 306: Memory 308: Communication bus 310: Program DETAILED DESCRIPTION
[0026] As previously mentioned, during the production and deployment of Internet of Things (IoT) devices, IoT devices need to be tested to verify that their various functions are functioning properly. Currently, testing IoT devices requires manually writing test cases, which are then used to test the IoT devices. While the same type of IoT devices can be tested using the same test case, IoT systems include a wide variety of IoT devices. For example, an IoT kit for a room may include a room sensor, radiator actuator, room unit, door contact, energy harvesting actuator, push buttons, lighting and shading actuators, people counters, occupancy detectors, and other IoT devices. When testing different types of IoT devices, test cases need to be manually written for each type of IoT device. Manually writing test cases is time-consuming, resulting in low IoT device testing efficiency.
[0027] In an embodiment of the present disclosure, IoT devices are tested using a testing tool. The testing tool runs in a virtual machine, which provides the testing tool with the operating environment, development tools, development environment, and development kits required to test the IoT devices. After importing the test requirement information of the IoT device to be tested into the testing tool, the testing tool can automatically generate test cases based on the test requirement information and run the test cases to test the IoT device to be tested. The testing tool can automatically generate test cases for IoT devices and is applicable to various types of IoT devices. Compared to manually writing test cases, it reduces the time required to obtain test cases, thereby improving the efficiency of testing IoT devices.
[0028] The following describes in detail the IoT device testing method, apparatus, electronic device, and storage medium provided by the embodiments of the present disclosure in conjunction with the accompanying drawings.
[0029] Figure 1 FIG. 1 is a flow chart of an IoT device testing method 100 according to an embodiment of the present disclosure. Figure 1 As shown, the IoT device testing method 100 includes the following steps:
[0030] Step 101: Run a virtual machine for IoT device testing.
[0031] The virtual machine can provide the operating environment, development tools, development environment, development kit, and continuous integration / continuous deployment configuration files required for testing IoT devices. The operating environment can be a virtual machine built based on virtual machine software VMware or LinuxUbanto. The development tool can be an integrated development environment (IDE) such as VS Code (Visual Studio Code), so that test cases and test control logic can be automatically developed using IDEs such as VS Code. The development environment can be an environment such as Python, Git, etc., which relies on environments such as Python, Git, etc. to generate test cases and control the test process. The development kit can include development kits such as robot, json, pandas, etc. The continuous integration / continuous deployment (CI / CD) configuration file can include a configuration file of the CI / CD tool GitLab Runner. Based on the CI / CD configuration file, the build, test, and deployment processes can be automated during the software development process, thereby realizing the automation of IoT device testing.
[0032] In one example, when testing an IoT device, a virtual machine image file is copied to a physical machine for testing, such as a VMware .iso file. The virtual machine is then run on the physical machine using the VMware .iso file. The physical machine is connected to the IoT device to be tested via a wired or wireless network.
[0033] Step 102: Import the test requirement information of the IoT device to be tested into the virtual machine.
[0034] The test requirements for the IoT device under test include multiple data points. A data point is the smallest unit of data collected, processed, or transmitted by an IoT device, representing the status, measurement value, or control instruction of a sensor or actuator. In IoT devices, data points are the most basic information carriers used to monitor, analyze, and control objects or environments in the physical world.
[0035] Different IoT devices have different numbers and types of data points. A data point can include a name, value, timestamp, type, unit, and quality. The name uniquely identifies the data point, such as temperature or humidity. The value is the actual measurement (such as 35°C, ON / OFF, etc.). The timestamp indicates when the data was generated or collected. The type indicates the data type (such as numeric, Boolean, string, etc.). The unit indicates the physical unit of the data (such as °C, %, kPa, etc.). The quality is an indicator of data reliability (such as GOOD, BAD, etc.).
[0036] During the product development process of the IoT device under test, test requirements information is generated, such as those written by product developers such as product managers. When testing the IoT device under test, this test requirements information generated during the product development process can be directly accessed, eliminating the need to compile test requirements separately for testing.
[0037] The virtual machine runs test software for IoT device testing. After the virtual machine runs, the test requirement information of the IoT device to be tested is imported into a specific storage address of the virtual machine to ensure that the test software can read the test requirement information from the storage address.
[0038] Step 103: Generate test cases based on the virtual machine and test requirement information.
[0039] The testing software running in the virtual machine can read the test requirement information and automatically generate test cases for the IoT device to be tested based on the hardware environment, drivers, integrated development environment, development kit, CI / CD environment, etc. provided by the virtual machine. The testing software can generate a corresponding test case for each data point included in the test requirement information, or generate a corresponding test case for multiple data points included in the test requirement information, which is not limited to this embodiment of the present disclosure.
[0040] Step 104: Run the test case based on the virtual machine to test the IoT device to be tested, and generate a test report based on the test results.
[0041] After generating test cases for the IoT device to be tested, the test software running in the virtual machine can automatically run the test cases to test the IoT device to be tested based on the environment, driver, core logic, etc. provided by the virtual machine, and can automatically generate a test report based on the test results.
[0042] In the disclosed embodiments, a virtual machine can provide the operating environment, development tools, development environment, and development kits required for testing IoT devices. After creating a virtual machine and importing the test requirement information of the IoT device to be tested into the virtual machine, the test software running in the virtual machine can automatically generate test cases based on the test requirement information, run the test cases to test the IoT device to be tested, and then automatically generate a test report based on the test results. Because the virtual machine provides the various environments, drivers, development kits, and core logic required for testing IoT devices, based on these preset test support conditions, the test software in the running virtual machine can automatically generate test cases and test the IoT device to be tested. Users do not need to manually write test cases, thereby improving the efficiency of testing IoT devices.
[0043] In a possible implementation, when generating test cases according to test requirement information, the test requirement information may be first converted into a first file in a data exchange format, and then a plurality of test cases may be generated according to the first file.
[0044] The test requirement information can be a file in a tabular format, such as an Excel file, which facilitates the writing and modification of test requirements during the development of the IoT device to be tested. The first file is a file in a data exchange format, such as a JSON (JavaScript Object Notation) file. JSON files are lightweight data exchange format files that store and represent structured data in plain text, making them easy for humans to read and write, as well as for machines to parse and produce. Since most programming languages support the processing of JSON files, converting the test requirement information into a first file in JSON format facilitates the test software to generate test cases based on the first file.
[0045] The testing software running in the virtual machine can use the data analysis tools provided by the virtual machine to convert the test requirement information of the IoT device to be tested into a first file in a data exchange format. In one example, the virtual machine has a built-in Python Pandas library, and the testing software can use the Pandas library to convert the test requirement information in Excel format into the first file in JSON format.
[0046] The data points included in the test requirements document have corresponding resource locators, and the resource locators of the data points have at least one level. The resource locator can be a Uniform Resource Locator (URL). In one example, if the resource locator of a first data point is T / class3, then the resource locator of the first data point has two levels, and if the resource locator of a second data point is T / class3 / 001, then the resource locator of the second data point has three levels.
[0047] When converting the test requirement information into a first file, a first file including multiple first data groups can be generated based on the resource locators of the data points included in the test requirement information, so that each first data group includes at least one data point in the test requirement information, the data points included in the same first data group correspond to the same upper-level resource locator, and the data points included in different first data groups correspond to different upper-level resource locators.
[0048] When generating a first data group, a data group name for the first data group can be generated based on the parent resource locator of the data point in the first data group. The data group name can be used as an object or array in the first data group. The data group name can include at least part of the fields of the parent resource locator.
[0049] In one example, the test requirement information includes data points ' / class3 / ':{}, ' / class3 / 001':{}, and ' / class3 / 002':{}. Since these three data points have the same parent resource locator ' / class3 / ', a first data group including these three data points is generated. The data group name ' / class3_summary' of the first data group is generated based on the parent resource locator ' / class3 / '. The first data group is shown below:
[0050]
[0051] In another example, the test requirement information includes data points ' / class1 / ':{}, ' / class1 / 001':{}, ' / class1 / 002':{}, and ' / class1 / 003':{}. Since these four data points have the same parent resource locator ' / class1 / ', a first data group including these four data points is generated, and the data group name ' / class1_summary' of the first data group is generated based on the parent resource locator ' / class1 / '. The first data group is shown below:
[0052]
[0053] In the test requirement information, the resource locator of the data point corresponds to the function of the data point. The data points with the same upper-level resource locator correspond to similar functions of the IoT device to be tested. Therefore, the first data group is generated based on the upper-level resource locator of the data point, so that the data points included in the first data group have the same upper-level resource locator, that is, the data points included in the first data group have similar functions, so that a corresponding test case can be generated for each first data group, and then the functions corresponding to the data points included in the first data group can be tested through the same test case, thereby reducing the number of test cases and improving the efficiency of testing IoT devices.
[0054] After generating the first file, the test software running in the virtual machine can automatically generate corresponding test cases for each first data group included in the first file based on the development environment provided by the virtual machine, so that each first data group has a corresponding test case, and different first data groups correspond to different test cases.
[0055] In an embodiment of the present disclosure, the test requirement information is converted into a first file in a data exchange format so that the first file is easy for the test software to parse and generate. The first file obtained by the conversion includes multiple first data groups, the data points included in the same first data group correspond to the same upper-level resource locator, and the data points included in different first data groups correspond to different upper-level resource locators. Since the data points with the same upper-level resource locator correspond to similar functions of the IoT device to be tested, the data points included in the same first data group correspond to the same upper-level resource locator, so that a corresponding test case can be generated based on each first data group, so that the same test case can test the functions corresponding to multiple data points, reducing the number of test cases, thereby improving the time required for test case generation, reducing the storage space required for storing test cases, and thus improving the testing efficiency of IoT devices and reducing the hardware resources required for IoT device testing.
[0056] In one possible implementation, when multiple test cases are generated based on a first file, the title, storage path, and header file of the test case corresponding to each first data group included in the first file can be generated, and based on the data points included in the first data group, the case code and assertion code of the test case corresponding to the first data group can be generated.
[0057] For each first data group included in the first file, the testing software can automatically generate the title of the test case corresponding to the first data group based on the data group name of the first data group, and automatically create the file of the test case corresponding to the first data group in the specified storage path, and generate the header file of the test case.
[0058] For each first data group included in the first file, after creating the test case file and title corresponding to the first data group, the test software can traverse the data points included in the first data group, generate use case code and assertion code based on the data points included in the first data group, and then store the use case code and assertion code in the test case file to obtain the test case corresponding to the first data group.
[0059] Use case code and assertion code are the core content of test cases, used to verify whether IoT devices function as expected. Use case code is the main body of the test, executing specific test steps to simulate user or system interaction with IoT devices. Use case code defines the test scenario, test data, and execution flow. Test scenarios can include sending commands, reading sensor data, verifying device state changes, etc. Test data can include input parameters, configuration values, expected results, etc. The execution flow refers to the sequential execution of operational steps. Assertion code verifies whether the test results meet expectations and is key to determining whether the test passes. Assertion code defines the expected results and verification logic. Expected results can include sensor reading ranges, device state changes, response time thresholds, etc. Verification logic compares the actual results with the expected results to generate a pass / fail judgment.
[0060] Generated test cases can be divided into data point test cases and persistence test cases. Data point test cases are used to verify the functionality and performance of single or multiple data points in the IoT device under test, and the test scope focuses on the accuracy, completeness, and timeliness of the data points. Persistence test cases are used to verify the overall status and data storage of the IoT device under test during long-term, continuous operation. The test scope includes not only data points, but also the validity and stability of the configuration information and historical data records of the IoT device under test over different time spans, as well as the data integrity in situations such as the IoT device under test restart and network interruption recovery.
[0061] It should be noted that when the test software generates test cases, the connectivity code and OTA code included in the test cases can directly copy the core logic code built into the virtual machine without having to regenerate it. The connectivity code is used to establish a communication connection, and the Over-the-Air Technology (OTA) code is used to remotely manage the IoT device under test.
[0062] In an embodiment of the present disclosure, when the test software generates a test case based on the first file, it first creates a test case file according to each first data group included in the first file, and generates a title for the test case file to facilitate distinguishing the test cases corresponding to different first data groups. Then, based on the data points included in the first data group, it generates a test case code and an assertion code, and stores the test case code and the assertion code in the test case file corresponding to the first data group, thereby obtaining the test case corresponding to the first data group.
[0063] In a possible implementation, before the IoT device to be tested is tested using a test case, a second file may be generated according to the test requirement information. The second file is used to provide expected test results for the test of the IoT device to be tested.
[0064] The testing software running in the virtual machine can automatically convert the test requirements information of the IoT device under test into a second file. The test requirements information can be in a tabular format, such as an Excel file, to facilitate the writing and modification of test requirements during the development of the IoT device under test. The second file is in a data exchange format, such as a JSON file.
[0065] The second file includes multiple one-dimensional arrays. The testing software may convert each data point included in the test requirement information into a one-dimensional array, thereby generating the second file including the multiple one-dimensional arrays. The second file may provide reference data for judging the test results of the first test case, where the first test case is a test case for testing a single data point in the first data set.
[0066] In one example, the test requirement information includes data points ' / class1 / ':{}, ' / class1 / 001':{}, ' / class1 / 002':{}, ' / class3 / ':{}, ' / class3 / 001':{}, ' / class3 / 002':{}, ' / class8 / ':{}, and ' / class8 / 001':{}. The second file generated by the test software may be as follows:
[0067] {' / class1 / ':{},
[0068] ' / class1 / 001':{},
[0069] ' / class1 / 002':{},
[0070] ' / class3 / ':{},
[0071] ' / class3 / 001':{},
[0072] ' / class3 / 002':{},
[0073] ' / class8 / ':{},
[0074] ' / class8 / 001':{},
[0075] }.
[0076] When a first test case is generated based on a first data group including multiple data points, the first test case can test each data point included in the first data group separately. For example, a first test case generated based on the following first data group is used to test the data points ' / class3 / ':{}, ' / class3 / 001':{}, and ' / class3 / 002':{} respectively:
[0077]
[0078] In an embodiment of the present disclosure, a second file in a data exchange format is automatically generated based on the test requirement information, and the second file includes a plurality of one-dimensional arrays, each of which corresponds to a data point in the test requirement information. After the IoT device to be tested is tested by a first test case for testing a single data point and the test result is obtained, the corresponding one-dimensional array can be obtained from the second file as the expected test result, and then the assertion code included in the first test case can determine whether the corresponding data point has passed the test based on the actual test result and the expected test result. Since the second file includes the various data points included in the test requirement information in a flat organization, after the IoT device to be tested is tested by the first test case, the corresponding one-dimensional array can be quickly found from the second file as the expected test result, thereby ensuring the efficiency of testing the IoT device to be tested.
[0079] In a possible implementation, before the IoT device to be tested is tested using a test case, a third file may be generated according to the test requirement information. The third file is used to provide expected test results for the test of the IoT device to be tested.
[0080] The testing software running in the virtual machine can automatically convert the test requirements of the IoT device under test into a third file. The test requirements information can be in a tabular format, such as an Excel file, to facilitate the writing and modification of test requirements during the development of the IoT device under test. The third file is in a data exchange format, such as a JSON file.
[0081] The third file includes multiple second data groups, each second data group includes at least one data point, the data points included in the same second data group correspond to the same upper-level resource locator, the data points included in different second data groups correspond to different upper-level resource locators, and the second data group does not include a data point whose corresponding last-level resource locator is the upper-level resource locator corresponding to the second data group.
[0082] In one example, the test requirement information includes data points ' / class3 / ':{}, ' / class3 / 001':{}, and ' / class3 / 002':{}. Since these three data points have the same upper-level resource locator ' / class3 / ', but the lower-level resource locator of the data point ' / class3 / ':{} is also ' / class3 / ', a second data group including the data point ' / class3 / 001':{} and the data point ' / class3 / 002':{} can be generated based on these three data points. The second data group is shown below:
[0083]
[0084] In another example, the test requirement information includes data points ' / class1 / ':{}, ' / class1 / 001':{}, ' / class1 / 002':{}, and ' / class1 / 003':{}. Since these four data points have the same upper-level resource locator ' / class1 / ', but the lower-level resource locator of the data point ' / class1 / ':{} is also ' / class1 / ', a second data group including the data points ' / class1 / 001':{}, ' / class1 / 002':{}, and ' / class1 / 003':{} can be generated based on these four data points. The second data group is shown below:
[0085]
[0086] The second data group can provide reference data for judging the test results of the second test case. The second test case is a test case for testing the collection information of the data points included in the second data group. The collection information of the data points can be the number of sub-devices, network parameters, etc.
[0087] In an embodiment of the present disclosure, a third file in a data exchange format is automatically generated based on the test requirement information, and the third file includes a plurality of second data groups. The data points included in the second data groups correspond to the same upper-level resource locator, but the second data group does not include a data point whose corresponding final-level resource locator is the same as the upper-level resource locator corresponding to the second data group. The second test case is used to test the collection information of the data points included in the corresponding second data group. After the IoT device to be tested is tested by the second test case and the test results are obtained, the expected test results can be obtained from the corresponding second data group, and then the assertion code of the second test case can determine whether the collection information of the data points has passed the test based on the actual test results and the expected test results. A third file including a plurality of second data groups is generated based on the test requirement information to provide expected test results for the root-level test case, so that the root-level test can be automatically performed on the IoT device to be tested, ensuring the comprehensiveness of the test of the IoT device.
[0088] In one possible implementation, a virtual machine contains built-in core logic code, which can be used to run test cases against the IoT device under test. The built-in core logic code in the virtual machine includes code files and resource files. The code files include at least one of code for sending requests, code for verifying responses, code for parsing scenarios, and code for connecting to routers. The resource files include at least one of automated testing framework keywords and common parameters.
[0089] The code file can be a Python file. The code file can also be OTA code. The automated testing framework keyword can be the Robot keyword.
[0090] In the disclosed embodiments, a virtual machine contains built-in core logic code, which includes code files and resource files. These code files and resource files are used when testing different types of IoT devices. During the process of generating and running test cases for the IoT devices to be tested, the code and resource information provided by the core logic code can be directly used to generate and run test cases. By directly reusing the core logic code, the amount of code required during test case generation and execution is reduced, thereby improving the efficiency of testing IoT devices.
[0091] In one possible implementation, when testing the IoT device to be tested, it is necessary to establish a communication connection between the virtual machine and the IoT device to be tested, and the network information required for establishing the communication connection between the virtual machine and the IoT device to be tested is related to the IoT device to be tested. Therefore, the network information required for testing different types of IoT devices can be built into the virtual machine in advance. When testing the IoT device to be tested, the user can select the network information that is suitable for the IoT device to be tested from the built-in network information, and then the test software running in the virtual machine can establish a communication connection with the IoT device to be tested based on the network information selected by the user when starting to test the IoT device to be tested.
[0092] The network information may include at least one of the IP address of the gateway, the username for logging into the gateway, the password for logging into the gateway, the serial number of the IoT device to be tested, the network identifier of the IoT device to be tested, and the pre-shared key of the IoT device to be tested.
[0093] In the embodiment of the present disclosure, by building network information into the virtual machine, the user can select network information suitable for the IoT device to be tested from the built-in multiple network information, and then the testing software can connect the communication connection with the IoT device to be tested based on the network information selected by the user, without the need for the user to manually configure the network information, thereby improving the efficiency of testing IoT devices and reducing the labor intensity of users during the testing of IoT devices.
[0094] Figure 2 FIG is a schematic diagram of an IoT device testing apparatus 200 according to an embodiment of the present disclosure. Figure 2 As shown, the IoT device testing apparatus 200 includes a loading unit 201 , an importing unit 202 and a testing unit 203 .
[0095] A loading unit 201 is configured to run a virtual machine for IoT device testing, wherein the virtual machine provides at least one of an operating environment, development tools, a development environment, and a development kit required for testing the IoT device;
[0096] An importing unit 202 is used to import the test requirement information of the IoT device to be tested into the virtual machine;
[0097] The testing unit 203 is configured to generate a test case based on the virtual machine according to the test requirement information, run the test case to test the IoT device to be tested, and generate a test report based on the test result.
[0098] In the disclosed embodiment, after the loading unit 201 runs the virtual machine, the importing unit 202 imports the test requirement information of the IoT device to be tested into the virtual machine. Then, the testing unit 203 can generate test cases based on the test requirement information based on the virtual machine and run the test cases to test the IoT device to be tested. Because the virtual machine provides the various environments, drivers, development kits, and core logic required to test IoT devices, based on these preset test support conditions, the test software in the running virtual machine can automatically generate test cases and test the IoT device to be tested. Users do not need to manually write test cases, thereby improving the efficiency of testing IoT devices.
[0099] It should be noted that the interaction between the various units in the above-mentioned IoT device testing device and other contents are based on the same concept as the above-mentioned IoT device testing method embodiment. The specific contents and beneficial effects can be found in the description in the above-mentioned IoT device testing method embodiment, and will not be repeated here.
[0100] Figure 3 This is a schematic diagram of an electronic device provided by an embodiment of the present disclosure. The specific embodiments of the present disclosure do not limit the specific implementation of the electronic device. Figure 3 The electronic device 300 provided in the embodiment of the present disclosure includes: a processor 302, a communication interface 304, a memory 306, and a communication bus 308.
[0101] The processor 302 , the communication interface 304 , and the memory 306 communicate with each other via a communication bus 308 .
[0102] The communication interface 304 is used to communicate with other electronic devices or servers.
[0103] The processor 302 is configured to execute the program 310 , and specifically may execute the relevant steps in any of the aforementioned embodiments of the IoT device testing method.
[0104] Specifically, the program 310 may include program codes, which include computer operation instructions.
[0105] Processor 302 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present disclosure. The one or more processors included in a smart device may be processors of the same type, such as one or more CPUs, or processors of different types, such as one or more CPUs and one or more ASICs.
[0106] The memory 306 is used to store the program 310. The memory 306 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0107] The program 310 can be specifically used to enable the processor 302 to execute the Internet of Things device testing method in any of the aforementioned embodiments.
[0108] The specific implementation of each step in program 310 can be found in the corresponding descriptions of the corresponding steps and units in any of the aforementioned IoT device testing method embodiments, and will not be repeated here. Those skilled in the art will clearly understand that for ease and brevity of description, the specific operating processes of the devices and modules described above can refer to the corresponding process descriptions in the aforementioned method embodiments, and will not be repeated here.
[0109] Through the electronic device of the embodiment of the present disclosure, the virtual machine can provide the operating environment, development tools, development environment and development kit required for testing IoT devices. After creating the virtual machine and importing the test requirement information of the IoT device to be tested into the virtual machine, the test software running in the virtual machine can automatically generate test cases based on the test requirement information, run the test cases to test the IoT device to be tested, and then automatically generate a test report based on the test results. Because the virtual machine provides the various environments, drivers, development kits and core logic required for testing IoT devices, based on these preset test support conditions, the test software in the running virtual machine can automatically generate test cases and test the IoT device to be tested. Users do not need to manually write test cases, thereby improving the efficiency of testing IoT devices.
[0110] The present disclosure also provides a computer-readable storage medium storing instructions for causing a machine to execute the IoT device testing method described herein. Specifically, a system or device equipped with a storage medium can be provided, storing software program code that implements the functions of any of the above-described embodiments, and causing a computer (or CPU or MPU) of the system or device to read and execute the program code stored in the storage medium.
[0111] In this case, the program code read from the storage medium itself can realize the function of any one of the above embodiments, and thus the program code and the storage medium storing the program code constitute part of the present disclosure.
[0112] Examples of storage media for providing program code include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), magnetic tapes, non-volatile memory cards, and ROMs. Alternatively, the program code can be downloaded from a server computer via a communication network.
[0113] In addition, it should be clear that the functions of any of the above embodiments can be achieved not only by executing the program code read by the computer, but also by enabling the operating system operating on the computer to complete part or all of the actual operations based on the instructions of the program code.
[0114] In addition, it can be understood that the program code read from the storage medium is written into a memory provided in an expansion board inserted into the computer or into a memory provided in an expansion module connected to the computer, and then based on the instructions of the program code, a CPU installed on the expansion board or expansion module is enabled to perform part or all of the actual operations, thereby realizing the functions of any of the above embodiments.
[0115] The present disclosure also provides a computer program product tangibly stored on a computer-readable medium and comprising computer-executable instructions that, when executed, cause at least one processor to perform the device testing methods provided in the aforementioned embodiments. It should be understood that each solution in this embodiment has the corresponding technical effects of the aforementioned method embodiments and will not be further elaborated here.
[0116] It should be noted that not all steps and modules in the above processes and system structure diagrams are required, and certain steps or modules can be omitted according to actual needs. The execution order of each step is not fixed and can be adjusted as needed. The system structure described in the above embodiments can be a physical structure or a logical structure, that is, some modules may be implemented by the same physical entity, or some modules may be implemented by multiple physical entities, or may be implemented by certain components in multiple independent devices.
[0117] Nouns and pronouns referring to persons in this patent application are not limited to a specific gender.
[0118] In the above embodiments, the hardware module can be implemented mechanically or electrically. For example, a hardware module can include a permanent dedicated circuit or logic (such as a dedicated processor, FPGA or ASIC) to complete the corresponding operation. The hardware module can also include programmable logic or circuits (such as a general-purpose processor or other programmable processors), which can be temporarily set by software to complete the corresponding operation. The specific implementation method (mechanical method, or dedicated permanent circuit, or temporarily set circuit) can be determined based on cost and time considerations.
[0119] The present disclosure has been presented and described in detail above through the accompanying drawings and preferred embodiments. However, the present disclosure is not limited to these disclosed embodiments. Based on the above multiple embodiments, those skilled in the art can know that the code review methods in the above different embodiments can be combined to obtain more embodiments of the present disclosure, and these embodiments are also within the scope of protection of the present disclosure.
Claims
1. A method (100) for testing an Internet of Things device, characterized in that: include: Running a virtual machine for IoT device testing, wherein the virtual machine provides at least one of an operating environment, development tools, a development environment, and a development kit required for testing the IoT device; Importing the test requirement information of the IoT device to be tested into the virtual machine; Based on the virtual machine, a test case is generated according to the test requirement information, and the test case is run to test the IoT device to be tested, and a test report is generated based on the test result.
2. The method according to claim 1, characterized in that Generating a test case according to the test requirement information includes: Converting the test requirement information in a table format into a first file in a data exchange format, wherein the first file includes a plurality of first data groups, each first data group includes at least one data point, the data points included in the same first data group correspond to the same upper-level resource locator, and the data points included in different first data groups correspond to different upper-level resource locators; A plurality of test cases are generated according to the first file, wherein different first data groups correspond to different test cases.
3. The method according to claim 2, characterized in that Generating a plurality of test cases according to the first file includes: Respectively generate a title, a storage path, and a header file for each test case corresponding to each of the first data groups included in the first file; Generate, based on the data included in the first data group, a test case code and an assertion code for the test case corresponding to the first data group.
4. The method according to claim 2, characterized in that The method further comprises: converting the test requirement information in a tabular form into a second file in a data exchange format; wherein, The second file includes multiple one-dimensional arrays, and the second file is used to provide reference data for judging the test results of the first test case. The first test case is the test case used to test individual data points in the first data group.
5. The method according to claim 2, characterized in that The method further comprises: converting the test requirement information in a tabular form into a third file in a data exchange format; wherein, The third file includes multiple second data groups, each second data group includes at least one data point, the data points included in the same second data group correspond to the same upper-level resource locator, and the second data group does not include a data point whose corresponding last-level resource locator is the upper-level resource locator; the second data group provides reference data for judging the test results of the second test case, and the second test case is the test case used to test the collection information of the data points included in the second data group.
6. The method according to claim 1, wherein Running the test case to test the IoT device to be tested includes: The test case is run based on the core logic code built into the virtual machine to test the IoT device to be tested, wherein the core logic code includes a code file and a resource file, the code file includes at least one of a sending request code, a verification response code, a parsing scenario code, and a connection router code, and the resource file includes at least one of an automated testing framework keyword and a public parameter.
7. The method according to any one of claims 1 to 6, characterized in that: The method further comprises: Obtain network information built into the virtual machine for establishing a communication connection with the IoT device to be tested, wherein the network information includes at least one of the IP address of the gateway, the user name for logging into the gateway, the password for logging into the gateway, the serial number of the IoT device to be tested, the network identifier of the IoT device to be tested, and the pre-shared key of the IoT device to be tested.
8. An Internet of Things device testing device (200), characterized in that: include: A loading unit (201) is used to run a virtual machine for testing an Internet of Things device, wherein the virtual machine provides at least one of an operating environment, a development tool, a development environment, and a development kit required for testing the Internet of Things device; An importing unit (202), configured to import test requirement information of an IoT device to be tested into the virtual machine; A testing unit (203) is used to generate a test case based on the virtual machine and the test requirement information, run the test case to test the IoT device to be tested, and generate a test report based on the test result.
9. An electronic device (300), characterized in that include: A processor (302), a communication interface (304), a memory (306), and a communication bus (308), wherein the processor (302), the memory (306), and the communication interface (304) communicate with each other via the communication bus (308); The memory (306) is used to store at least one executable instruction, and the executable instruction enables the processor (302) to execute the Internet of Things device testing method (100) according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, which, when executed by a processor, cause the processor to execute the Internet of Things device testing method (100) according to any one of claims 1 to 7.
11. A computer program product, characterized in that The computer program product is tangibly stored on a computer-readable medium and includes computer-executable instructions that, when executed, cause at least one processor to perform the Internet of Things device testing method (100) according to any one of claims 1 to 7.