Power consumption test method and device, storage medium and computer equipment
Through wireless communication connection and power consumption acquisition equipment, the automated test actions are directly controlled on the terminal and data is collected, solving the problem of insufficient power consumption test accuracy in the existing technology, and achieving efficient and accurate power consumption testing, suitable for high-precision Required scenario.
Patent Information
- Application Number
- CN202411351848.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2024-11-29
AI Technical Summary
In the prior art, the power consumption automation testing method of terminals cannot be applied to test scenarios with high requirements for power consumption testing accuracy, especially because the installation of test tools and the connection of USB data cables cause interference to the power consumption data, resulting in inaccurate measurement.
By establishing a wireless communication connection with the terminal under test in the same wireless network, controlling it to establish a target business scenario and defining automated test actions, disconnect the communication connection and use the power consumption acquisition device to collect power consumption data, and restore the communication connection after the test is completed To obtain test data, avoid the impact of the continuous operation of the test application on the data and the plug-in and unplug interference of the USB data cable.
It realizes accurate recording of power consumption data and accuracy of test results, improves testing efficiency, is suitable for scenarios with high requirements for power consumption test accuracy, and is flexible, avoiding the impact of test applications and USB data cable on the results .
Smart Images

Figure CN119052849A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of power consumption automation testing, and in particular to a power consumption testing method, device, storage medium and computer equipment. Background Art
[0002] Automated power consumption testing of terminals refers to automatically executing test scripts on terminal devices to measure the power consumption of terminal devices in different application scenarios. This type of test helps to discover the energy consumption performance of terminal devices in actual use, which is very important for optimizing device battery life and energy efficiency.
[0003] In the prior art, the following two problems usually occur during the process of automated power consumption testing of terminals: on the one hand, the existing tests rely on Appium, UIAutomator or other mature tools for automated testing. The tools simulate user interaction behaviors by providing APIs, so that the interface testing can be completed efficiently. However, the testing tools usually need to install specific services or applications on the terminal under test, which may interfere with the power consumption of the terminal device and cannot be applied to test scenarios that require accurate measurement of power consumption changes. On the other hand, traditional testing methods often require connecting the test host to the terminal under test via a USB data cable to facilitate the transmission of commands and data. However, the USB data cable itself also has a small current passing through it, and is also not suitable for test scenarios that require extremely high power consumption test accuracy. Summary of the invention
[0004] In view of this, the present application provides a power consumption testing method, apparatus, storage medium and computer equipment, the main purpose of which is to solve the technical problem that the terminal power consumption automation testing method in the prior art cannot be applied to test scenarios with high requirements for power consumption testing accuracy.
[0005] According to a first aspect of the present invention, there is provided a power consumption test method, which is applied to a test host and comprises:
[0006] In the same wireless network, establish a wireless communication connection with the terminal under test, control the terminal under test to establish a target service scenario and define automated test actions;
[0007] Controlling the terminal under test to perform an automated test action in the target service scenario, and disconnecting the wireless communication connection with the terminal under test;
[0008] Using a power consumption collection device to collect power consumption data generated by the terminal under test based on the automated test action;
[0009] After the terminal under test completes the automated test action, the wireless communication connection with the terminal under test is restored, and test data generated by the terminal under test based on the automated test action is acquired.
[0010] Optionally, the test host is pre-installed with a command line tool; and establishing a wireless communication connection with the terminal under test in the same wireless network includes:
[0011] Accessing the wireless network where the terminal under test is located;
[0012] Acquiring connection parameters of the terminal under test, wherein the connection parameters include an Internet Protocol address;
[0013] Loading the connection parameters into the command line tool to generate a wireless communication connection command;
[0014] The wireless communication connection command is executed to establish a wireless communication connection with the terminal under test.
[0015] Optionally, the controlling the terminal under test to establish a target service scenario and define an automated test action includes:
[0016] Based on the wireless communication connection, sending a target business scenario construction instruction to the terminal under test, so that the terminal under test generates a target page;
[0017] Acquire page elements in the target page, generate an extensible markup language file based on the page elements, and parse the extensible markup language file to generate an element tree, wherein the element tree includes a plurality of root node elements;
[0018] Obtaining an initial input element and constructing a query function, loading the initial input element into the query function to query whether there is a root node element in the element tree that is consistent with the initial input element;
[0019] When any of the root node elements is consistent with the initial input element, the establishment of the target business scenario is completed, and an automated test action is defined based on the initial input element.
[0020] Optionally, the automated test action includes a click test action; and the step of defining the automated test action based on the initial input element includes:
[0021] Acquire boundary information of the initial input element, wherein the boundary information includes the upper left corner position coordinates and the lower right corner position coordinates of the initial input element in the target page;
[0022] Select any value within the numerical range of the abscissa of the upper left corner position coordinate and the abscissa of the lower right corner position coordinate to obtain the abscissa of the random position;
[0023] Select any value within the range of the ordinate of the upper left corner position coordinate and the ordinate of the lower right corner position coordinate to obtain the ordinate of the random position;
[0024] The random position is determined according to the horizontal coordinate of the random position and the vertical coordinate of the random position, and a click test action is defined based on the random position and preset click parameter information, wherein the click parameter information includes click frequency and click times.
[0025] Optionally, the automated test action includes a sliding test action, and the initial input element includes a first input element and a second input element; and defining the automated test action based on the initial input element includes:
[0026] Set the first input element as the sliding start point, and set the second input element as the sliding end point;
[0027] Generate a plurality of sliding trajectories based on the sliding starting point and the sliding end point, and select any one sliding trajectory from the plurality of sliding trajectories as a target sliding trajectory;
[0028] A sliding test action is defined based on the sliding start point, the sliding end point, the target sliding track and preset sliding parameters, wherein the sliding parameters include a sliding speed.
[0029] Optionally, the collecting power consumption data generated by the terminal under test based on the automated test action by using a power consumption collection device includes:
[0030] The test host is connected to the power supply end of the terminal under test through the power consumption acquisition device;
[0031] The power consumption collection device collects voltage data and current data generated by the terminal under test when performing an automated test action, and calculates the power consumption data of the terminal under test based on the voltage data and the current data;
[0032] The power consumption collection device sends the power consumption data to the test host.
[0033] Optionally, after acquiring the test data generated by the terminal under test based on the automated test action, the method includes:
[0034] Generating a test result of the terminal under test according to the power consumption data and the test data;
[0035] The operating status of the tested terminal is determined based on the test result, and a test report is generated.
[0036] According to a second aspect of the present invention, there is provided a power consumption testing device, which is applied to a testing host and includes:
[0037] A test action definition module is used to establish a wireless communication connection with a terminal under test in the same wireless network, control the terminal under test to establish a target service scenario and define an automated test action;
[0038] A test action execution module, used to control the terminal under test to execute an automated test action in the target service scenario and disconnect the wireless communication connection with the terminal under test;
[0039] A power consumption data acquisition module, used to collect power consumption data generated by the terminal under test based on the automated test action using a power consumption acquisition device;
[0040] The test data acquisition module is used to restore the wireless communication connection with the terminal under test after the terminal under test completes the automated test action, and to acquire the test data generated by the terminal under test based on the automated test action.
[0041] According to a third aspect of the present invention, there is provided a storage medium on which a computer program is stored, and when the program is executed by a processor, the above-mentioned power consumption test method is implemented.
[0042] According to a fourth aspect of the present invention, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the power consumption test method is implemented when the processor executes the program.
[0043] The power consumption test method, device, storage medium and computer equipment provided by the present application, the test host directly controls the terminal under test to establish the target business scenario and define and execute the automated test action based on the wireless communication connection, without the need to install the test application on the terminal under test in advance, effectively avoiding the continuous operation of the test application from affecting the collected power consumption data, and ensuring the accuracy of the power consumption data; the test host disconnects the wireless communication connection when the terminal under test performs the automated test action, and uses the power consumption acquisition device to collect power consumption data, simplifying the data acquisition process, and realizing the accurate recording of power consumption data; in the complete test process, the test host and the terminal under test successively experience the establishment, disconnection and recovery process of the wireless communication connection, and compared with the physical connection of the traditional USB data cable, effectively avoid the manual continuous plugging and unplugging of the USB data cable to affect the accuracy of the test results, and the use of wireless communication connection has strong flexibility, which improves the test efficiency. The above method effectively improves the test efficiency, avoids the installation of the test application on the terminal under test and the continuous plugging and unplugging of the USB data cable to affect the accuracy of the test results, can be applied to test scenarios with high requirements for power consumption test accuracy, and has strong flexibility.
[0044] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0046] Figure 1 A schematic diagram of a flow chart of a power consumption testing method provided by an embodiment of the present invention is shown;
[0047] Figure 2 A schematic diagram showing the principle of a power consumption testing method provided by an embodiment of the present invention is shown;
[0048] Figure 3 A schematic diagram of a flow chart of another power consumption testing method provided by an embodiment of the present invention is shown;
[0049] Figure 4 A schematic diagram showing the principle of a click test in another power consumption test method provided by an embodiment of the present invention is shown;
[0050] Figure 5 A schematic diagram of the structure of a power consumption automatic test device provided by an embodiment of the present invention is shown;
[0051] Figure 6 A schematic diagram showing the structure of another power consumption automatic testing device provided by an embodiment of the present invention is shown;
[0052] Figure 7 A schematic diagram of the device structure of a computer device provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0053] The exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.
[0054] The present application embodiment provides a power consumption test method, which is applied to a test host, such as Figure 1 As shown, the method comprises the following steps:
[0055] 101. In the same wireless network, establish a wireless communication connection with the terminal under test, control the terminal under test to establish a target service scenario and define automated test actions.
[0056] Specifically, the application scenario of the present application is to perform automated power consumption testing on terminal devices. Based on this, the present application constructs a system for automated power consumption testing, which specifically includes a test host and a terminal under test. The test host is wirelessly connected to the terminal under test, so that the test host controls the terminal under test based on the wireless communication connection to complete the automated power consumption testing, and the power consumption testing method provided by the present application is applied on the test host.
[0057] Among them, the target business scenario refers to the specific usage scenario or functional requirement of the terminal under test set in order to achieve the test purpose. For example, when the terminal under test is a smart phone, during the testing of the smart phone, the target business scenario can be functions that users use daily, such as sending text messages, browsing the web, and playing videos. The above target business scenarios are defined based on actual usage or product specifications, and are intended to simulate real usage in order to comprehensively evaluate the performance and reliability of the equipment; automated test actions refer to a series of operations automatically triggered by pre-written scripts or programs under the target business scenario. The automated test actions are designed to simulate user behavior as realistically as possible, while collecting power consumption data, test data and other key performance indicators of the terminal under test during the test.
[0058] In the embodiment of the present application, the test host and the terminal under test are set to be in the same wireless network, and a wireless communication connection is established between the two. Compared with the use of a traditional USB data cable to connect the test host and the terminal under test, on the one hand, there is no need to manually repeatedly plug and unplug the USB data cable during the subsequent test, and the test is fully automated, which improves the efficiency of the test; on the other hand, the power consumption data generated by the terminal under test will be affected in the process of plugging and unplugging the USB data cable, and the use of wireless communication connection can minimize the generation of such an impact, improve the accuracy of the acquired power consumption data, and can more flexibly control the connection and disconnection with the terminal under test, thereby improving the flexibility of the power consumption test. In addition, the test host and the terminal under test are wirelessly connected in the same wireless network, which can also enable the test host to connect to multiple terminals under test at the same time, and perform power consumption tests on multiple terminals under test at the same time, further improving the efficiency of the power consumption test.
[0059] 102. Control the terminal under test to execute an automated test action in a target service scenario, and disconnect the wireless communication connection with the terminal under test.
[0060] Specifically, after the test host establishes a wireless communication connection with the terminal under test, the test host controls the terminal under test to establish a target business scenario based on the test needs, and completes the definition of automated test actions under the target business scenario, that is, the preparation stage of the power consumption test is completed. Next, it is necessary to enter the specific test implementation stage, that is, the test host controls the terminal under test to execute the defined automated test actions under the established target business scenario. At the same time as the terminal under test starts the automated test action, the test host needs to disconnect the wireless communication connection with the terminal under test, so that the terminal under test completes the implementation stage of the test without interference.
[0061] In the embodiments of the present application, compared with the traditional automated testing method, it is usually necessary to install a fixed application on the terminal under test, and to achieve the purpose of testing the terminal under test by continuously running the application. However, the continuous running of the application will further affect the accuracy of the collected power consumption data. In the present application, a wireless communication connection is established between the test host and the terminal under test. In the preparation stage of the power consumption test, the test host has controlled the terminal under test to complete the establishment of the target business scenario and the definition of the automated test action. Therefore, in the testing stage, the terminal under test only needs to automatically perform the automated test action under the target business scenario. At the same time, in order to avoid the test host always being in communication connection with the terminal under test and thus affecting the accuracy of the power consumption data, the test host can directly disconnect the communication connection with the terminal under test when the test of the terminal under test starts, thereby further improving the accuracy of the test results.
[0062] 103. Use power consumption collection equipment to collect power consumption data generated by the terminal under test based on automated test actions.
[0063] Specifically, the power consumption collection device, as a hardware collection device, is connected between the test host and the terminal under test. It is used to measure the power consumption of the terminal under test in a certain operating mode. By accurately measuring the current and voltage of the terminal under test, the power consumption of the terminal under test performing automated test actions in the target business scenario is calculated. Common power consumption collection devices include portable power meters, current clamps, data recorders, dedicated power consumption analyzers, and battery emulators. Different power consumption collection devices are suitable for different application scenarios. The selection of power consumption collection devices is based on test requirements and test scenarios.
[0064] In this embodiment, after the test host disconnects the wireless communication connection between the tested terminal and the tested terminal, the tested terminal performs an automated test action. At this time, the test host needs to connect to the tested terminal through a hardware device to collect the power consumption data generated by the tested terminal when performing the automated test action. The power consumption data of the tested terminal can be accurately obtained by using the power consumption collection device, and real-time monitoring can be supported. It can instantly obtain power consumption information and automatically record power consumption data during the test, thereby simplifying the test process and data collection process and improving test efficiency.
[0065] 104. After the terminal under test completes the automated test action, restore the wireless communication connection with the terminal under test, and obtain test data generated by the terminal under test based on the automated test action.
[0066] Specifically, when the terminal under test performs automated test actions, the test host collects the power consumption data of the terminal under test through the power consumption collection device, and after the terminal under test completes the automated test actions, the test host obtains the test data of the terminal under test; among them, the power consumption data focuses on reflecting the energy consumption of the terminal under test, and is used to evaluate the energy efficiency of the terminal under test, while the test data focuses on reflecting the performance indicators of the terminal under test, and is used to evaluate the functionality, reliability and performance of the terminal under test, usually including network performance data, application layer data, system-level data, sensor data, and security data, etc.
[0067] In this embodiment, when the terminal under test has completed the automated test action, the test host also obtains the power consumption data of the terminal under test when executing the automated test action through the power consumption acquisition device. At this time, the test host can restore the wireless communication connection with the terminal under test to collect all test data of the terminal under test after completing the automated test, completing the whole process of collecting test data for the terminal under test, and thus being able to more accurately and comprehensively evaluate the terminal under test; the test host and the terminal under test complete the process of establishing, disconnecting and restoring the wireless communication connection, effectively improving the test efficiency, and having strong flexibility.
[0068] The present invention provides a power consumption test method, device, storage medium and computer equipment, wherein the overall principle of establishing, disconnecting and restoring a wireless communication connection between a test host and a terminal under test to complete the test on the terminal under test and collect the test results is as follows Figure 2As shown, the power consumption testing method includes first establishing a wireless communication connection with a terminal under test in the same wireless network, controlling the terminal under test to establish a target business scenario and define an automated test action, then controlling the terminal under test to perform the automated test action in the target business scenario, and disconnecting the wireless communication connection with the terminal under test, then using a power consumption acquisition device to collect power consumption data generated by the terminal under test based on the automated test action, and finally, after the terminal under test completes the automated test action, restoring the wireless communication connection with the terminal under test, and obtaining the test data generated by the terminal under test based on the automated test action. In this application, the test host directly controls the terminal under test to establish the target business scenario and define and execute the automated test action based on the wireless communication connection. There is no need to install the test application on the terminal under test in advance, which effectively avoids the continuous operation of the test application from affecting the collected power consumption data and ensures the accuracy of the power consumption data; the test host disconnects the wireless communication connection when the terminal under test performs the automated test action, and uses the power consumption acquisition device to collect power consumption data, simplifying the data acquisition process and realizing accurate recording of power consumption data; in the complete test process, the test host and the terminal under test successively experience the establishment, disconnection and recovery process of the wireless communication connection, and compared with the physical connection of the traditional USB data cable, it effectively avoids the continuous plugging and unplugging of the USB data cable to affect the accuracy of the test results, and the use of wireless communication connection has strong flexibility, which improves the test efficiency. The above method effectively improves the test efficiency, avoids the installation of the test application on the terminal under test and the continuous plugging and unplugging of the USB data cable to affect the accuracy of the test results, can be applied to test scenarios with high requirements for power consumption test accuracy, and has strong flexibility.
[0069] The present application embodiment provides another power consumption test method, such as Figure 3 As shown, the method comprises the following steps:
[0070] 201. Establish a wireless communication connection with a terminal under test in the same wireless network.
[0071] Specifically, the test host pre-installs a command line tool; establishes a wireless communication connection with the terminal under test in the same wireless network, including accessing the wireless network where the terminal under test is located; obtains connection parameters of the terminal under test, wherein the connection parameters include an Internet Protocol address; loads the connection parameters into the command line tool to generate a wireless communication connection command; and executes the wireless communication connection command to establish a wireless communication connection with the terminal under test.
[0072] Among them, taking the tested terminal as an Android device as an example, the command line tool can use the ADB (Android Debug Bridge) tool, that is, during the power consumption test of the Android device, the test host is allowed to send commands to the Android device and control it to perform various operations.
[0073] In the embodiment of the present application, the test host uses the ADB (Android Debug Bridge) tool to initiate a connection request to the Android device through a wireless network. First, it is necessary to ensure that the ADB tool has been installed on the test host, and then ensure that the test host and the Android device meet the prerequisites for establishing an ADB wireless communication connection, that is, the test host and the Android device are connected to the same wireless network, and then the Android's Internet Protocol address, that is, the IP address, is obtained through the settings menu of the Android device or other technical means. At the same time, the connect command of the ADB tool is used on the test host to generate a wireless communication connection command. The specific format is adb connect <ip>, here <ip>It is the IP address of the Android device. By running the wireless communication connection command, the test host and the Android device successfully establish a wireless communication connection. All subsequent ADB commands and data transmission will be carried out through the wireless communication network. The test host can control and exchange data with the terminal under test through the wireless communication connection.
[0074] In the present application, the test host and the terminal under test establish a connection through a wireless network, which can more conveniently disconnect and restore the communication connection without the need for manual plugging and unplugging of USB data cables, making the construction of the test environment simpler and faster, increasing the flexibility and scalability of the test environment, while ensuring the accuracy of the test results; the use of ADB commands facilitates automated testing, and a series of ADB commands can be automatically executed through scripts to perform testing, thereby improving test efficiency.
[0075] 202. Control the terminal under test to establish a target business scenario.
[0076] Specifically, based on the wireless communication connection, a target business scenario construction instruction is sent to the terminal under test to enable the terminal under test to generate a target page; the page elements in the target page are obtained, an extensible markup language file is generated based on the page elements, and the extensible markup language file is parsed to generate an element tree, wherein the element tree includes multiple root node elements; the initial input element is obtained and a query function is constructed, and the initial input element is loaded into the query function to query whether there is a root node element in the element tree that is consistent with the initial input element; when any root node element is consistent with the initial input element, the establishment of the target business scenario is completed.
[0077] In the embodiment of the present application, the terminal under test is still taken as an Android device as an example. After the Android device receives the target business scenario construction instruction, it generates a target page according to the content of the instruction. It can be to require the Android device to start a specific application, or to require the Android device to navigate to a specific Web page, and configure some environment variables or settings, etc. The specific needs are based on the instruction content to meet the test requirements; after the Android device generates the target page, the elements of the entire page are obtained (dumped) through the Android native system / bin / uiautomator program to generate an extended markup language file (xml file), and then the fromstring method in the xml.etree.ElementTree module (xml file processing module) is used to parse the string in the xml file into an element tree object, and the root node of the element tree is obtained, each root node corresponds to a root node element, and then the initial input element is obtained. It is necessary to determine whether the initial input element exists in the element tree, that is, to determine whether the initial input element is an element existing in the target page. The method of constructing a query function is adopted, that is, the xpath method is defined, and the initial input element is loaded into the query function to obtain the query result. If the query structure shows that the initial input element exists in the element tree, the establishment of the target business scenario is completed.
[0078] In the present application, based on the control of the test host, the terminal under test can build the target business scenario in an automated manner, effectively improving the efficiency and accuracy of the test. There is no need to pre-install the test application in the terminal under test, so as to avoid the continuous operation of the test application affecting the results. The page elements are converted into XML files and the element tree is constructed to structure the data, which is convenient for subsequent data processing and analysis, and makes the test process easy to integrate into the existing automated testing framework, which can be expanded as needed. The consistency of the page elements with the initial input elements is verified by the query function, which can ensure the correctness of the target business scenario and improve the reliability of the test results.
[0079] In another embodiment, when there is no root node element that is consistent with the initial input element, the test terminal throws an exception and re-acquires the page element, generates the extensible markup language file, and parses the generated element tree. The initial input element is then compared with the root node element in the newly generated element tree. If there is a root node element in the newly generated element tree that is consistent with the initial input element, the process of establishing the target business scenario is completed. Otherwise, exceptions are continuously thrown, and the steps of generating the element tree and re-comparing are repeated. When the number of failures exceeds the preset number of failures, the test process is terminated.
[0080] 203. Define a click test action based on the initial input element.
[0081] Specifically, the boundary information of the initial input element is obtained, wherein the boundary information includes the upper left corner position coordinates and the lower right corner position coordinates of the initial input element in the target page; any value is selected within the numerical range of the horizontal coordinate of the upper left corner position coordinate and the horizontal coordinate of the lower right corner position coordinate to obtain the horizontal coordinate of the random position; any value is selected within the numerical range of the vertical coordinate of the upper left corner position coordinate and the vertical coordinate of the lower right corner position coordinate to obtain the vertical coordinate of the random position; the random position is determined according to the horizontal coordinate of the random position and the vertical coordinate of the random position, and a click test action is defined based on the random position and preset click parameter information, wherein the click parameter information includes click frequency and number of clicks.
[0082] In the embodiment of the present application, after determining that the initial input element exists on the target page, the initial input element is defined so as to perform the automated test steps later. Specifically, taking the click test action as an example, the specific principle is as follows: Figure 4 As shown, when applied in the UI automated testing scenario, in the element tree obtained using uiautomator or other similar tools, each UI element will contain its position and size information on the screen, which is usually given in the form of a bounding box, that is, the coordinates of the upper left corner [X1, Y1] and the coordinates of the lower right corner [X2, Y2]. Then, the random numbers between X1 and X2 are taken to obtain the horizontal coordinate of a random position, and then the random numbers between Y1 and Y2 are taken to obtain the vertical coordinate of a random position. The random position is determined according to the horizontal coordinate of the random position and the vertical coordinate of the random position. The random position is used as a random click coordinate. Finally, based on the random position and some preset click parameter information, such as click frequency and number of clicks, the definition and attempt of the click test action are completed in cooperation with the ADB tool. The click action test definition method provided in this application can realize the automated testing of specific UI elements and improve the test efficiency; the generated random position as a random click coordinate can simulate the user's real click behavior, increase the randomness and diversity of the test, and use the ADB tool to execute the click command, which can be easily tested on different devices without writing complex cross-platform code.
[0083] 204. Define a sliding test action based on the initial input element.
[0084] Specifically, the initial input element includes a first input element and a second input element; the first input element is set as a sliding start point, and the second input element is set as a sliding end point; multiple sliding trajectories are generated based on the sliding start point and the sliding end point, and any sliding trajectory is selected from the multiple sliding trajectories as a target sliding trajectory; a sliding test action is defined based on the sliding start point, the sliding end point, the target sliding trajectory and preset sliding parameters, wherein the sliding parameters include a sliding speed.
[0085] In an embodiment of the present application, the automated test action also includes a sliding test action. The sliding test action needs to simulate a user sliding from one position to another position in the target page based on a certain specific sliding method. Therefore, the initial input element includes two first input elements and a second input element, one as the sliding starting point and the other as the sliding end point. There are multiple sliding tracks between the starting point and the end point. A target sliding track is selected to simulate the sliding gesture of the user in the actual use process. Finally, based on the sliding starting point, the sliding end point, the target sliding track and some preset sliding parameter information, such as the sliding speed, and in conjunction with the ADB tool, the definition and attempt of the sliding test action are completed. Using the sliding action test definition method provided in the present application, by generating multiple sliding tracks and selecting one of them as the target sliding track, the sliding gesture of the user in actual use can be more realistically simulated, thereby improving the authenticity and reliability of the test; generating multiple sliding tracks can cover different sliding paths, which is helpful to discover problems under different sliding paths and improve the comprehensiveness and coverage of the test; by defining sliding parameters, the action details of the sliding test can be better controlled, making the sliding test action more controllable and repeatable.
[0086] 205. Control the terminal under test to execute an automated test action in a target service scenario, and disconnect the wireless communication connection with the terminal under test.
[0087] In an embodiment of the present application, after a wireless communication connection is established between the test host and the terminal under test and the terminal under test completes the establishment of the target business scenario and the definition of the automated test action, the terminal under test enters the test execution phase, and the test host is required to disconnect the wireless communication connection with the terminal under test to improve the accuracy of the test results. The specific operation method has been described in detail in step 102 and will not be elaborated here.
[0088] 206. Use a power consumption collection device to collect power consumption data generated by the terminal under test based on the automated test action.
[0089] Specifically, the test host is connected to the power supply end of the terminal under test through the power consumption collection device; the power consumption collection device collects the voltage data and current data generated by the terminal under test when performing automated test actions, and calculates the power consumption data of the terminal under test based on the voltage data and current data; the power consumption collection device sends the power consumption data to the test host.
[0090] In the implementation mode of the present application, the test host is connected to the power supply end of the terminal under test through the power consumption acquisition device, so that the power consumption acquisition device can be connected to the power input port of the terminal under test to monitor its power consumption in real time. The power consumption acquisition device collects its voltage data and current data in real time during the execution of the automated test action by the terminal under test. The voltage data and current data are the basic elements for calculating the power consumption, and the power consumption acquisition device can also send the calculated power consumption data to the test host, which is responsible for further data processing and analysis. In the present application, the introduction of the power consumption acquisition device can monitor the power consumption of the terminal under test in real time and can provide accurate power consumption data. The real-time collection of power consumption data can better cooperate with the automated test process, which is conducive to the integrity and effectiveness of the automated test. The power consumption acquisition device monitors the power consumption data in real time and sends the data to the test host, which can ensure the consistency and repeatability of the test results and improve the credibility of the test.
[0091] 207. After the terminal under test completes the automated test action, restore the wireless communication connection with the terminal under test, and obtain test data generated by the terminal under test based on the automated test action.
[0092] In an embodiment of the present application, after the terminal under test completes the automated test, the test host restores the wireless communication connection with the terminal under test to collect all test data of the terminal under test, thereby being able to more accurately and comprehensively evaluate the terminal under test. The specific operation method has been described in detail in step 104 and will not be elaborated on here.
[0093] 208. Complete the test and generate a test report.
[0094] Specifically, a test result of the terminal under test is generated according to the power consumption data and the test data; an operation state of the terminal under test is determined based on the test result, and a test report is generated.
[0095] In an embodiment of the present application, based on the power consumption data collected by the tested terminal when executing the automated test action, and the test data collected by the tested terminal when completing the automated test action, the two types of data are integrated to form a comprehensive test result, and the integrated test result is analyzed to evaluate the operating status of the tested terminal, such as whether the device is operating within the normal range, whether there is abnormal power consumption, etc. The test result can also be compared with a preset threshold to determine whether it exceeds the normal range. Finally, the test results and operating status evaluation results are organized into a test report. The test report should contain detailed data analysis and help staff identify key indicators and potential problem points.
[0096] In this application, by integrating power consumption data and test data to generate test results, and determining the operating status of the terminal under test to generate a test report, it is possible to comprehensively evaluate the performance of the terminal under test in various test scenarios, ensure the comprehensiveness and accuracy of the test results, and quickly locate problems with the terminal under test, such as high power consumption problems, performance bottlenecks, etc., while reducing the time for manual data analysis and making the testing process more efficient.
[0097] The present invention provides a power consumption testing method, device, storage medium and computer equipment. First, in the same wireless network, a wireless communication connection is established with a terminal under test, the terminal under test is controlled to establish a target business scenario, and an automated test action is defined based on an initial input element, specifically including a click test action and a slide test action. Then, the terminal under test is controlled to perform the automated test action in the target business scenario, and the wireless communication connection with the terminal under test is disconnected. During this period, power consumption data generated by the terminal under test based on the automated test action is collected by a power consumption collection device. After the terminal under test completes the automated test action, the wireless communication connection with the terminal under test is restored, and the test data generated by the terminal under test based on the automated test action is obtained. Finally, the test is completed and a test report is generated. The above method can fully cover various operations of the terminal under test in the target business scenario, ensuring the comprehensiveness and reliability of the test; using the power consumption acquisition device to monitor the power consumption data in real time can timely discover power consumption anomalies, which is helpful to optimize the energy consumption management of the equipment; through the definition and execution of automated test actions, the test efficiency is improved, and the tediousness of manually plugging and unplugging USB data cables and the images produced on the test results are reduced; disconnecting the wireless communication connection can reduce external interference during the test process, ensure the purity of the test environment, and thus improve the accuracy and reliability of the test results; by obtaining complete test data, the performance of the terminal under test under automated test actions can be comprehensively evaluated to ensure the integrity of the test results.
[0098] Further, as Figure 1 The specific implementation of the method, the embodiment of the present application provides a power consumption test device, which is applied to a test host, such as Figure 5 As shown, the device includes: a test action definition module 301 , a test action execution module 302 , a power consumption data acquisition module 303 and a test data acquisition module 304 .
[0099] The test action definition module 301 is used to establish a wireless communication connection with the terminal under test in the same wireless network, control the terminal under test to establish a target service scenario and define an automated test action;
[0100] The test action execution module 302 is used to control the terminal under test to execute the automated test action in the target service scenario and disconnect the wireless communication connection with the terminal under test;
[0101] The power consumption data acquisition module 303 is used to collect the power consumption data generated by the terminal under test based on the automated test action by using the power consumption collection device;
[0102] The test data acquisition module 304 is used to restore the wireless communication connection with the terminal under test after the terminal under test completes the automated test action, and to acquire the test data generated by the terminal under test based on the automated test action.
[0103] In a specific application scenario, the test host pre-installs a command line tool; the test action definition module 301 can be specifically used to access the wireless network where the terminal under test is located;
[0104] Acquiring connection parameters of the terminal under test, wherein the connection parameters include an Internet Protocol address;
[0105] Load the connection parameters into the command line tool to generate a wireless communication connection command;
[0106] Execute the wireless communication connection command to establish a wireless communication connection with the terminal under test.
[0107] In a specific application scenario, the test action definition module 301 may also be used to send a target business scenario construction instruction to the terminal under test based on a wireless communication connection, so that the terminal under test generates a target page;
[0108] Obtaining page elements in the target page, generating an extensible markup language file based on the page elements, and parsing the extensible markup language file to generate an element tree, wherein the element tree includes a plurality of root node elements;
[0109] Get the initial input element and build a query function, load the initial input element into the query function to query whether there is a root node element in the element tree that is consistent with the initial input element;
[0110] When any node element is consistent with the initial input element, the target business scenario is established and the automated test action is defined based on the initial input element.
[0111] In a specific application scenario, the automated test action includes a click test action; the test action definition module 301 can also be used to obtain boundary information of the initial input element, wherein the boundary information includes the upper left corner position coordinates and the lower right corner position coordinates of the initial input element in the target page;
[0112] Select any value within the range of the horizontal coordinate of the upper left corner position coordinate and the horizontal coordinate of the lower right corner position coordinate to obtain the horizontal coordinate of the random position;
[0113] Select any value within the range of the ordinate of the upper left corner position coordinate and the ordinate of the lower right corner position coordinate to obtain the ordinate of the random position;
[0114] The random position is determined according to the horizontal coordinate of the random position and the vertical coordinate of the random position, and a click test action is defined based on the random position and preset click parameter information, wherein the click parameter information includes click frequency and click times.
[0115] In a specific application scenario, the automated test action includes a sliding test action, and the initial input element includes a first input element and a second input element; the test action definition module 301 can also be used to set the first input element as a sliding start point and the second input element as a sliding end point;
[0116] Generate multiple sliding trajectories based on the sliding start point and the sliding end point, and select any sliding trajectory from the multiple sliding trajectories as the target sliding trajectory;
[0117] The sliding test action is defined based on the sliding start point, the sliding end point, the target sliding track and the preset sliding parameters, wherein the sliding parameters include the sliding speed.
[0118] In a specific application scenario, the power consumption data acquisition module 303 can be specifically used to test that the host is connected to the power supply terminal of the terminal under test through the power consumption acquisition device;
[0119] The power consumption collection device collects the voltage data and current data generated by the terminal under test when performing the automated test action, and calculates the power consumption data of the terminal under test based on the voltage data and the current data;
[0120] The power consumption collection device sends the power consumption data to the test host.
[0121] In specific application scenarios, such as Figure 6 As shown, the device also includes a test result generating module 305, which can be specifically used to generate a test result of the terminal under test according to the power consumption data and the test data;
[0122] Determine the operating status of the terminal under test based on the test results and generate a test report.
[0123] It should be noted that for other corresponding descriptions of the functional units involved in the power consumption automatic test device provided in this embodiment, reference can be made to Figure 1 and Figure 2 The corresponding description in will not be repeated here.
[0124] Based on the above Figure 1 The method shown, accordingly, this embodiment also provides a storage medium, on which a computer program is stored, and when the program is executed by a processor, the above-mentioned power consumption automatic testing method is implemented.
[0125] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product. The software product to be identified can be stored in a non-volatile storage medium (which can be a CD-ROM, USB flash drive, mobile hard disk, etc.), including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute the power consumption automation test method for each implementation scenario of the present application.
[0126] Based on the above Figure 1 and Figure 2 The method shown, and Figure 5 and Figure 6 In order to achieve the above-mentioned purpose, the power consumption automatic test device embodiment shown in the figure is as follows: Figure 7 As shown, this embodiment also provides a physical device for power consumption automation testing, which includes a communication bus, a processor, a memory and a communication interface, and may also include an input and output interface and a display device, wherein each functional unit can communicate with each other through the bus. The memory stores a computer program, and the processor is used to execute the program stored in the memory and execute the power consumption automation testing method in the above embodiment.
[0127] Optionally, the physical device may also include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, etc. The user interface may include a display, an input unit such as a keyboard, etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), etc.
[0128] Those skilled in the art will appreciate that the structure of a power consumption automation test entity device provided in this embodiment does not constitute a limitation on the entity device, and may include more or fewer components, or a combination of certain components, or different component arrangements.
[0129] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware of the physical device and the software resources to be identified, and supports the operation of the information processing program and other software and / or programs to be identified. The network communication module is used to realize the communication between the components inside the storage medium, and the communication with other hardware and software in the information processing physical device.
[0130] Through the description of the above implementation methods, the technical personnel in this field can clearly understand that the present application can be implemented by means of software plus the necessary general hardware platform, or by hardware. By applying the technical solution of the present application, firstly, in the same wireless network, a wireless communication connection is established with the terminal under test, the terminal under test is controlled to establish a target service scenario and define an automated test action, and then the terminal under test is controlled to perform the automated test action in the target service scenario, and the wireless communication connection with the terminal under test is disconnected, and then the power consumption data generated by the terminal under test based on the automated test action is collected by the power consumption collection device, and finally, after the terminal under test completes the automated test action, the wireless communication connection with the terminal under test is restored, and the test data generated by the terminal under test based on the automated test action is obtained. In this application, the test host directly controls the terminal under test to establish the target business scenario and define and execute the automated test action based on the wireless communication connection. There is no need to install the test application on the terminal under test in advance, which effectively avoids the continuous operation of the test application from affecting the collected power consumption data and ensures the accuracy of the power consumption data; the test host disconnects the wireless communication connection when the terminal under test performs the automated test action, and uses the power consumption acquisition device to collect power consumption data, simplifies the data acquisition process, and realizes the accurate recording of power consumption data; in the complete test process, the test host and the terminal under test successively experience the establishment, disconnection and recovery process of the wireless communication connection, and compared with the physical connection of the traditional USB data cable, effectively avoids the continuous plugging and unplugging of the USB data cable to affect the accuracy of the test results, and the use of wireless communication connection has strong flexibility, which improves the test efficiency. The above method effectively improves the test efficiency, avoids the installation of the test application on the terminal under test and the continuous plugging and unplugging of the USB data cable to affect the accuracy of the test results, can be applied to test scenarios with high requirements for power consumption test accuracy, and has strong flexibility.
[0131] Those skilled in the art will appreciate that the accompanying drawings are only schematic diagrams of a preferred implementation scenario, and the modules or processes in the accompanying drawings are not necessarily necessary for implementing the present application. Those skilled in the art will appreciate that the modules in the devices in the implementation scenario can be distributed in the devices of the implementation scenario according to the description of the implementation scenario, or can be changed accordingly and located in one or more devices different from the present implementation scenario. The modules of the above-mentioned implementation scenario can be combined into one module, or can be further split into multiple submodules.
[0132] The above serial numbers of this application are only for description and do not represent the advantages and disadvantages of the implementation scenarios. The above disclosure is only a few specific implementation scenarios of this application, but this application is not limited to them, and any changes that can be thought of by technicians in this field should fall within the scope of protection of this application.< / ip> < / ip>
Claims
1. A power consumption test method, applied to a test host, characterized in that: include: In the same wireless network, establish a wireless communication connection with the terminal under test, control the terminal under test to establish a target service scenario and define automated test actions; Controlling the terminal under test to perform an automated test action in the target service scenario, and disconnecting the wireless communication connection with the terminal under test; Using a power consumption collection device to collect power consumption data generated by the terminal under test based on the automated test action; After the terminal under test completes the automated test action, the wireless communication connection with the terminal under test is restored, and test data generated by the terminal under test based on the automated test action is acquired.
2. The method according to claim 1, characterized in that The test host is pre-installed with a command line tool; The step of establishing a wireless communication connection with the terminal under test in the same wireless network includes: Accessing the wireless network where the terminal under test is located; Acquiring connection parameters of the terminal under test, wherein the connection parameters include an Internet Protocol address; Loading the connection parameters into the command line tool to generate a wireless communication connection command; The wireless communication connection command is executed to establish a wireless communication connection with the terminal under test.
3. The method according to claim 1, characterized in that The controlling the terminal under test to establish a target service scenario and define an automated test action includes: Based on the wireless communication connection, sending a target business scenario construction instruction to the terminal under test, so that the terminal under test generates a target page; Acquire page elements in the target page, generate an extensible markup language file based on the page elements, and parse the extensible markup language file to generate an element tree, wherein the element tree includes a plurality of root node elements; Obtaining an initial input element and constructing a query function, loading the initial input element into the query function to query whether there is a root node element in the element tree that is consistent with the initial input element; When any of the root node elements is consistent with the initial input element, the establishment of the target business scenario is completed, and an automated test action is defined based on the initial input element.
4. The method according to claim 3, characterized in that The automated test action includes a click test action; and the automated test action is defined based on the initial input element, including: Acquire boundary information of the initial input element, wherein the boundary information includes the upper left corner position coordinates and the lower right corner position coordinates of the initial input element in the target page; Select any value within the numerical range of the abscissa of the upper left corner position coordinate and the abscissa of the lower right corner position coordinate to obtain the abscissa of the random position; Select any value within the range of the ordinate of the upper left corner position coordinate and the ordinate of the lower right corner position coordinate to obtain the ordinate of the random position; The random position is determined according to the horizontal coordinate of the random position and the vertical coordinate of the random position, and a click test action is defined based on the random position and preset click parameter information, wherein the click parameter information includes click frequency and click times.
5. The method according to claim 3, characterized in that: The automated test action includes a sliding test action, and the initial input element includes a first input element and a second input element; The step of defining an automated test action based on the initial input element comprises: Set the first input element as the sliding start point, and set the second input element as the sliding end point; Generate a plurality of sliding trajectories based on the sliding starting point and the sliding end point, and select any one sliding trajectory from the plurality of sliding trajectories as a target sliding trajectory; A sliding test action is defined based on the sliding start point, the sliding end point, the target sliding track and preset sliding parameters, wherein the sliding parameters include a sliding speed.
6. The method according to claim 1, characterized in that The using of the power consumption collection device to collect the power consumption data generated by the terminal under test based on the automated test action includes: The test host is connected to the power supply end of the terminal under test through the power consumption acquisition device; The power consumption collection device collects voltage data and current data generated by the terminal under test when performing an automated test action, and calculates the power consumption data of the terminal under test based on the voltage data and the current data; The power consumption collection device sends the power consumption data to the test host.
7. The method according to claim 1, characterized in that After obtaining the test data generated by the terminal under test based on the automated test action, the method includes: Generating a test result of the terminal under test according to the power consumption data and the test data; The operating status of the tested terminal is determined based on the test result, and a test report is generated.
8. A power consumption test device, used for testing a host, characterized in that: The device comprises: A test action definition module is used to establish a wireless communication connection with a terminal under test in the same wireless network, control the terminal under test to establish a target service scenario and define an automated test action; A test action execution module, used to control the terminal under test to execute an automated test action in the target service scenario and disconnect the wireless communication connection with the terminal under test; A power consumption data acquisition module, used to collect power consumption data generated by the terminal under test based on the automated test action using a power consumption acquisition device; The test data acquisition module is used to restore the wireless communication connection with the terminal under test after the terminal under test completes the automated test action, and to acquire the test data generated by the terminal under test based on the automated test action.
9. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
