A vending machine applet linkage camera automatic test method and system
The automated testing of the vending machine's camera linkage via ADB commands solves the problems of low efficiency and incomplete scene coverage in manual testing. It achieves efficient and comprehensive test coverage and fault location, adapts to multiple equipment specifications, and reduces costs.
Patent Information
- Application Number
- CN202611118307.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-24
- Publication Date
- 2026-11-27
AI Technical Summary
In existing technologies, testing the camera linked to the smart vending machine mini-program relies on manual operation, which results in low testing efficiency, incomplete scene coverage, inability to quantify indicators, and difficulty in locating anomalies in the business chain, thus failing to meet the comprehensive testing requirements before large-scale deployment.
This paper provides an automated testing method for vending machine mini-programs linked to cameras. It achieves automated control through ADB commands, simulates user operations, builds an operation list, executes tests in a loop, monitors the application and camera status in real time, generates test reports, supports high-frequency and long-cycle testing, and is compatible with different devices.
It achieves fully automated testing, which can efficiently expose low-probability hidden problems, comprehensively cover test scenarios, accurately count test indicators, reduce testing costs, improve troubleshooting efficiency, and adapt to multiple device specifications.
Smart Images

Figure CN123185341A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of automated testing technology, specifically to an automated testing method and system for a vending machine mini-program linked to a camera. Background Technology
[0002] With the widespread adoption of smart vending machines, scanning a QR code with a mobile app to activate the vending machine's camera has become the mainstream interaction mode. The main process in this scenario is as follows: the user clicks the QR code button on the vending machine, the device displays the QR code, the user scans the code with their mobile phone and operates the mini-program, ultimately activating the camera to complete the interaction. The stability of this business chain directly determines the user experience and the vending machine's operational efficiency.
[0003] Currently, testing in this scenario relies primarily on manual labor. There are no standardized, automated dedicated testing solutions in the industry, and this manual testing model has several significant drawbacks. First, testing efficiency is low. Manual testing is insufficient for high-frequency, long-term stress testing, failing to effectively expose low-probability, hidden issues such as memory leaks, occasional application crashes, and camera process remnants, making it difficult to support comprehensive testing before large-scale deployment of vending machines. Second, test scenario coverage is insufficient. Rigid manual operation procedures cannot simulate diverse user click and swipe behaviors, easily overlooking various boundary and abnormal scenarios. Third, data quantification capabilities are lacking. Manual testing cannot accurately calculate key test indicators such as application crash rates and camera trigger failure rates, nor can it monitor application memory and process status in real time, leading to significant difficulties and low efficiency in problem localization and root cause tracing. Fourth, device compatibility is poor. Manual testing struggles to adapt to vending machine devices with different resolutions and hardware configurations, requiring repeated testing on different devices, significantly increasing testing costs. Fifth, the end-to-end monitoring capability is weak, making it impossible to conduct automated anomaly detection on the main links of "QR code generation, mini-program linkage, and camera activation," making it difficult to accurately locate faulty links and hindering rapid problem repair.
[0004] In conclusion, traditional manual testing methods are no longer adequate for the current testing needs of smart vending machines. The industry urgently requires an automated testing solution that can simulate real user behavior, support quantifiable statistical analysis of test metrics, and adapt to various device specifications. This solution will compensate for the shortcomings of manual testing and comprehensively improve the testing efficiency and quality of vending machine mini-program-linked camera scenarios. Summary of the Invention
[0005] To address this, the present invention provides an automated testing method and system for vending machine mini-program linked cameras, which solves the drawbacks of existing vending machine mini-program linked camera scenarios that rely on manual testing, resulting in low testing efficiency, incomplete scenario coverage, inability to quantify indicators, and difficulty in locating anomalies in major business links.
[0006] To achieve the above objectives, the present invention provides the following technical solution: an automated testing method for a vending machine mini-program linked to a camera, comprising:
[0007] S1. Initialize the test environment, configure test parameters, create a log storage directory and generate log files with timestamps, grant necessary permissions to the vending machine application, obtain the vending machine screen resolution and adapt it to the operation coordinates, and clean up residual camera processes.
[0008] S2. Based on a preset weight allocation strategy, construct an operation list including product clicks, product list scrolling, and camera link triggers;
[0009] S3. Execute test operations in a loop. In each loop, first check the current active page. If it is an abnormal page / camera interaction page that is not the main sales page, then perform a return operation to reset to the main sales page. Then check the application running status and camera process status, count the number of application crashes and camera trigger failures, and clean up residual camera processes periodically during the test run. Then, select the operation type and execute the corresponding test operation through a weighted random sampling algorithm until the preset termination condition is reached.
[0010] S4. After the test is terminated, the test data is statistically analyzed and a final test report including the log storage path is generated. The test data includes the total test duration, cumulative number of operations, average operation frequency, application crash rate, camera trigger failure rate, peak memory usage, and average memory usage.
[0011] As a preferred solution for automated testing of the camera linked to the vending machine mini-program, in S1, the test parameters include the vending machine application package name, ADB tool path, operation area coordinates, test interval, and mini-program manual operation window period. The test parameters are configured according to the test requirements.
[0012] The operating area includes a product click area, a swipe area, and a QR code button area;
[0013] The test intervals include the normal operation interval and the camera link operation interval.
[0014] As a preferred solution for the automated testing method of the vending machine mini-program linked to the camera, in S1, the specific process of obtaining the screen resolution of the vending machine is as follows: execute the ADB command "wmsize" and parse the returned resolution result, use the actual obtained screen resolution to cover the default resolution parameter, and use the proportional coordinate conversion formula to adapt the operation coordinates of vending machine devices of different sizes and resolutions.
[0015] The proportional coordinate conversion formula is as follows:
[0016]
[0017] In the formula, Based on the baseline screen resolution, The actual screen resolution of the device being tested. The original operational coordinates at the reference resolution. The actual operating coordinates of the current device after adaptation.
[0018] As a preferred solution for automated testing of the camera linked to the vending machine mini-program, in S2, the duration of the manual operation window of the mini-program in the camera link triggering operation is customizable; both the QR code refresh interface and the mini-program linkage interface are configured with a retry mechanism, with a default retry count of no less than 3 times, and a retry is triggered when the interface call fails.
[0019] The retry logic formula is as follows:
[0020]
[0021] In the formula, This represents the maximum number of retries. This is the current number of retries, initially. , This is the interval between retry attempts. Mark the result of the API call. For the call to be successful, The call failed.
[0022] The weight allocation strategy adopts the following weight normalization constraint formula:
[0023]
[0024] In the formula, For product click weight, Sliding weights for the product list The camera link triggers weights.
[0025] As a preferred solution for automated testing of the vending machine mini-program linked to the camera, S3 includes the following specific process for detecting the application running status and the camera process status: obtaining the vending machine application PID process identifier, TotalPSS memory usage index, and camera process running status; if the application process is detected to be non-existent, it is determined that the application has crashed, and the number of crashes is counted; if the camera process does not start after the window period ends, it is determined that the camera triggering has failed, and the number of failures is counted.
[0026] As a preferred method for automated testing of the vending machine mini-program linked to the camera, in S3, the specific process of selecting the operation type and executing the corresponding test operation through the random algorithm includes:
[0027] If it is a touch operation, generate random coordinates within the product area, execute the ADB click command, and simulate the user's click behavior on the product;
[0028] If it is a motion operation, generate the start / end coordinates of the list swiping, execute the ADB swiping command, and simulate the user's behavior of swiping the product list;
[0029] If it is a qr_camera operation, click the QR code button at the bottom to trigger the loading of a new QR code page; wait for the new page and QR code to finish rendering; enter the manual operation window of the mini program, call the QR code refresh interface and the mini program linkage interface to complete the parameter passing; after the window ends, check whether the camera process has been successfully launched. If the launch fails, count the number of camera trigger failures; if the launch is successful, simulate the camera usage time and then return to the sales page.
[0030] As a preferred automated testing method for vending machine mini-programs linked to cameras, in S3, the application crash rate calculation formula is as follows:
[0031]
[0032] In the formula, This represents the total number of test operations. Total number of application crashes;
[0033] The formula for calculating the camera trigger failure rate is as follows:
[0034]
[0035] In the formula, This represents the total number of camera link-triggered operations. This represents the total number of times the camera failed to trigger.
[0036] As a preferred automated testing method for the camera linked to the vending machine mini-program, S3 also includes executing the next operation at a preset test interval:
[0037]
[0038] In the formula, This is a normal operating interval. For camera link operation interval;
[0039] After each preset number of test operations is completed, the real-time test progress is output, which includes the average operation frequency and abnormal statistics.
[0040] The formula for calculating the average operating frequency is:
[0041]
[0042] In the formula, Total test duration This represents the total number of test operations.
[0043] As a preferred solution for the automated testing method of the vending machine mini-program linked camera, in S3, the preset termination conditions include reaching the preset total number of operations and receiving a manual termination command.
[0044] The preset termination condition logical expression is:
[0045] After a single operation is completed:
[0046] In the formula, This represents the current number of operations completed, initially... , To preset the total number of operations, This is a manual termination signal. This indicates that a termination command has been received. This indicates that the item has not been received.
[0047] This invention also provides an automated testing system for vending machine mini-program linked to a camera, employing the aforementioned automated testing method for vending machine mini-program linked to a camera, including:
[0048] Test environment initialization unit: Used for initializing the test environment, configuring test parameters, creating a log storage directory and generating log files with timestamps, granting necessary permissions to the vending machine application, obtaining the vending machine screen resolution and adapting it to the operation coordinates, and cleaning up residual camera processes;
[0049] The operation list construction unit is used to construct an operation list including product clicks, product list scrolling, and camera link triggers based on a preset weight allocation strategy.
[0050] Test Loop Execution Unit: Used to repeatedly execute test operations. In each loop, it first checks the current active page. If it is an abnormal page or camera interaction page that is not the main sales page, it performs a return operation to reset to the main sales page. Then, it checks the application running status and camera process status, counts the number of application crashes and camera trigger failures, and periodically cleans up residual camera processes during the test run. Then, it selects the operation type and executes the corresponding test operation through a weighted random sampling algorithm until the preset termination condition is reached.
[0051] Test report generation unit: Used to collect test data after test termination and generate a final test report including the log storage path. The test data includes total test duration, cumulative number of operations, average operation frequency, application crash rate, camera trigger failure rate, peak memory usage, and average memory usage.
[0052] The present invention has the following advantages:
[0053] First, this invention can replace manual testing and supports high-frequency, long-cycle testing and infinite loop mode. It can effectively expose low-probability hidden problems that are difficult to detect manually, such as memory leaks, occasional application crashes, and camera process residues, greatly shortening the testing cycle and fully meeting the comprehensive testing needs before large-scale deployment of vending machines.
[0054] Secondly, by using a preset weight allocation strategy to randomly generate diverse operations such as product clicks, list scrolling, and camera link triggers, it breaks through the limitations of fixed manual operation processes, highly simulates the operating habits of real users, and can fully cover regular business scenarios, edge scenarios, and various abnormal scenarios.
[0055] Third, the system can monitor application PID, TotalPSS memory usage, and camera process running status in real time, and accurately count key test indicators such as application crash rate and camera trigger failure rate. At the same time, it can achieve automated status detection and interface linkage monitoring for the entire business chain of "QR code generation, mini-program linkage, and camera initiation", which can accurately locate the specific link where the anomaly occurs and greatly improve the efficiency of fault diagnosis and problem repair.
[0056] Fourth, it can recognize the screen resolution of the vending machine and adaptively match the operation coordinates, eliminating the need for manual debugging for devices with different resolutions and hardware configurations, avoiding repeated testing and effectively reducing testing costs; at the same time, it generates operation logs and status logs with timestamps throughout the process, outputs a complete test report after the test, and retains all process data, making it easy to trace back the test process and delve into the root cause of problems.
[0057] Fifth, it supports custom settings for parameters such as test interval, manual operation window period of mini program, total number of test operations, and weight of various operations, which can flexibly adapt to the testing needs of different test pressures and different business scenarios. The solution is highly practical and has high promotion and application value. Attached Figure Description
[0058] To more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings in the following description are merely exemplary, and those skilled in the art can derive other embodiments based on the provided drawings without creative effort.
[0059] The structures, proportions, sizes, etc. illustrated in this specification are only for the purpose of assisting those skilled in the art in understanding and reading the content disclosed herein, and are not intended to limit the conditions under which the present invention can be implemented. Therefore, they have no substantial technical significance. Any modifications to the structure, changes in the proportions, or adjustments to the size, without affecting the effects and objectives that the present invention can produce, should still fall within the scope of the technical content disclosed in the present invention.
[0060] Figure 1 This is a schematic diagram of the automated testing method for linking a vending machine mini-program with a camera, as provided in Embodiment 1 of the present invention.
[0061] Figure 2 This is a technical roadmap for the automated testing method of the vending machine mini-program linked to the camera provided in Embodiment 1 of the present invention;
[0062] Figure 3 This is a schematic diagram of the automated testing system architecture for a vending machine mini-program linked to a camera, as provided in Embodiment 1 of the present invention. Detailed Implementation
[0063] The following specific embodiments illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0064] Example 1
[0065] See Figure 1 and Figure 2 This invention provides an automated testing method for linking a vending machine mini-program with a camera, including:
[0066] S1. Initialize the test environment, configure test parameters, create a log storage directory and generate log files with timestamps, grant necessary permissions to the vending machine application, obtain the vending machine screen resolution and adapt it to the operation coordinates, and clean up residual camera processes.
[0067] S2. Based on a preset weight allocation strategy, construct an operation list including product clicks, product list scrolling, and camera link triggers;
[0068] S3. Execute test operations in a loop. In each loop, first check the current active page. If it is an abnormal page / camera interaction page that is not the main sales page, then perform a return operation to reset to the main sales page. Then check the application running status and camera process status, count the number of application crashes and camera trigger failures, and clean up residual camera processes periodically during the test run. Then, select the operation type and execute the corresponding test operation through a weighted random sampling algorithm until the preset termination condition is reached.
[0069] S4. After the test is terminated, the test data is statistically analyzed and a final test report including the log storage path is generated. The test data includes the total test duration, cumulative number of operations, average operation frequency, application crash rate, camera trigger failure rate, peak memory usage, and average memory usage.
[0070] Specifically, this method is based on ADB (Android Debug Bridge) to achieve instruction-level automated control of the vending machine's Android system, employing a logical testing architecture of "environment initialization, test case generation, loop execution, and result output." The main logic is to simulate user operations through pre-defined rules and collect system status data across the entire process, replacing manual labor for repetitive and intensive stability testing. By recording operation and status data throughout the entire process, it achieves controllable testing, anomaly identification, and quantifiable result output, addressing the pain points of low efficiency, incomplete coverage, and lack of quantification in manual testing. Specifically, S1 (environment initialization) unifies the testing benchmark, eliminates interference from environmental differences on test results, and ensures consistent starting states for each round of testing; S2 (weighted operation list) aims to fit the operation distribution of real users, making the test scenario more closely resemble actual usage; S3 (loop execution) is the main vehicle for stress testing and stability testing, ensuring continuous and stable test operation through a fixed process of page reset, status detection, and operation execution; and S4 (test report) is the output vehicle for test value, reflecting application quality through quantitative indicators and providing data support for problem localization.
[0071] In one possible embodiment, in S1, the test parameters include the vending machine application package name, ADB tool path, operation area coordinates, test interval, and manual operation window period of the mini-program. The test parameters are configured according to the test requirements.
[0072] The operating area includes a product click area, a swipe area, and a QR code button area;
[0073] The test intervals include the normal operation interval and the camera link operation interval.
[0074] Specifically, the above parameters are configurable input items for the automated testing system. Their main function is to allow a single test script to adapt to different test scenarios and hardware devices, improving the versatility of the solution. The application package name is the unique identifier of an application in the Android system and is the basis for ADB commands to locate the target application and detect its process. The ADB tool path is a dependency configuration for the program to call the system's ADB capabilities, ensuring that the program can correctly issue operation commands to the vending machine and read the device status. The operation area coordinates define the execution range of various operations, dividing the screen into different functional areas to avoid accidental touches of irrelevant controls and ensure the accuracy of test operations. The test interval controls the test stress intensity: the shorter the interval, the more operations are performed per unit time, resulting in greater test stress. This can be flexibly adjusted according to the test objective (normal functional testing / high-pressure stress testing). The manual operation window period for the mini-program is to match real business logic: in real scenarios, after scanning the code, the user needs to complete the operation on the mini-program side, and the vending machine needs to wait for the linkage signal from the mini-program side. Setting a window period ensures that the interface call timing is consistent with the real scenario, preventing automated operations from skipping manual steps and causing test distortion.
[0075] In one possible embodiment, in S1, the specific process of obtaining the screen resolution of the vending machine is as follows: execute the ADB instruction "wmsize" and parse the returned resolution result, overwrite the default resolution parameter with the actual obtained screen resolution, and use the proportional coordinate conversion formula to adapt the operation coordinates of vending machine devices of different sizes and resolutions.
[0076] The proportional coordinate conversion formula is as follows:
[0077]
[0078] In the formula, Based on the baseline screen resolution, The actual screen resolution of the device being tested. The original operational coordinates at the reference resolution. The actual operating coordinates of the current device after adaptation.
[0079] Specifically, the ADB standard command is `wmsize`, a native Android system command for querying screen resolution. It can directly read the device's physical resolution without manual input, ensuring accuracy and automation in resolution acquisition. The main principle of proportional coordinate conversion is relative coordinate mapping logic: the operation coordinates at the base resolution essentially correspond to the relative position on the screen. For example, a QR code button is centered at the bottom of the screen. When the device resolution changes, the coordinates scale synchronously according to the screen's width and height, ensuring that the operation always hits the target control area. This mechanism eliminates the need to debug coordinates separately for each device, enabling a single test script to adapt to multiple vending machine specifications, significantly improving the compatibility and reusability of the test script and reducing the adaptation cost for multi-device testing.
[0080] In one possible embodiment, in S2, the duration of the manual operation window of the mini-program is customizable in the camera link triggering operation; both the QR code refresh interface and the mini-program linkage interface are configured with a retry mechanism, with a default retry count of no less than 3 times, and a retry is triggered when the interface call fails;
[0081] The retry logic formula is as follows:
[0082]
[0083] In the formula, This represents the maximum number of retries. This is the current number of retries, initially. , This is the interval between retry attempts. Mark the result of the API call. For the call to be successful, The call failed.
[0084] The weight allocation strategy adopts the following weight normalization constraint formula:
[0085]
[0086] In the formula, For product click weight, Sliding weights for the product list The camera link triggers weights.
[0087] Specifically, the manual operation window in the mini-program is essentially a time-sequenced design of the business process, closely mirroring the operation time of real users. This ensures sufficient interaction time between the mini-program and the vending machine, avoiding misjudgments caused by premature camera status checks and improving the realism of the link test. The interface retry mechanism is primarily a fault-tolerance design. Due to occasional non-application failures such as network fluctuations, interface response delays, and temporary system lag, a single interface call may fail. By setting the number of retries and the retry interval, the call can be re-initiated, filtering out test anomalies caused by these occasional environmental issues. This avoids misjudging network problems as application failures and improves the accuracy of test results. The weight normalization constraint is the mathematical basis of probabilistic random sampling. The sum of the weights of the three types of operations is 1, corresponding to a complete probability distribution in the 0-1 interval, ensuring that the sum of the probabilities of all operation types is 100% during random sampling, ensuring the mathematical rigor of the sampling logic. Simultaneously, the weights are customizable, allowing for flexible adjustment of the proportion of different operations to adapt to different testing focuses.
[0088] In one possible embodiment, S3, the specific process of detecting the application running status and the camera process status includes: obtaining the vending machine application PID process identifier, TotalPSS memory usage index, and camera process running status; if the application process is detected to be non-existent, it is determined that the application has crashed, and the number of crashes is counted; if the camera process does not start after the window period ends, it is determined that the camera triggering has failed, and the number of failures is counted.
[0089] Specifically, PID (Process Identifier) is used to determine crashes: PID is a unique identifier for a process in the operating system. An application continuously holds its corresponding PID while running normally; after an application crashes, the process is destroyed and reclaimed by the system, and the PID becomes invalid. Therefore, periodically checking the existence of the target application's PID can accurately and objectively determine whether the application has crashed, without the need for manual identification of crash pop-ups. TotalPSS (Proportional Set Size) memory metric is a standard indicator in the Android system for measuring application memory usage. It calculates the memory used by shared libraries proportionally, providing a more realistic reflection of the application's actual memory resource usage. It is a primary indicator for identifying memory leaks. If this metric continuously rises and does not fall back during testing, there is a high probability of a memory leak. Camera process trigger failure detection: When the camera hardware is invoked, the system starts the corresponding camera service process; if the link between the mini-program and the camera fails, the camera process will not start. Therefore, checking the existence of the camera process after the window period ends can accurately determine whether the camera link was successfully invoked and count the number of failures.
[0090] In one possible embodiment, S3, the specific process of selecting the operation type and executing the corresponding test operation through the random algorithm includes:
[0091] If it is a touch operation, generate random coordinates within the product area, execute the ADB click command, and simulate the user's click behavior on the product;
[0092] If it is a motion operation, generate the start / end coordinates of the list swiping, execute the ADB swiping command, and simulate the user's behavior of swiping the product list;
[0093] If it is a qr_camera operation, click the QR code button at the bottom to trigger the loading of a new QR code page; wait for the new page and QR code to finish rendering; enter the manual operation window of the mini program, call the QR code refresh interface and the mini program linkage interface to complete the parameter passing; after the window ends, check whether the camera process has been successfully launched. If the launch fails, count the number of camera trigger failures; if the launch is successful, simulate the camera usage time and then return to the sales page.
[0094] Specifically, the three types of operations correspond to three main user behaviors in a vending machine scenario. ADB commands are used to simulate user touchscreen operations, achieving automated behavior reproduction: Touch operation involves sending the `inputtap` command via ADB to simulate a user's finger tapping the screen; random coordinates are generated within the product area to cover clicks at different product locations, avoiding the bias caused by fixed click positions and better reflecting the random browsing and clicking habits of real users. Motion operation involves sending the `inputswipe` command via ADB to simulate a user's browsing behavior of scrolling up and down the product list; randomly generated start and end points simulate different scrolling amplitudes, reflecting the scrolling browsing habits of real users and covering more scrolling boundary scenarios. The `qr_camera` camera link operation fully reproduces the entire business logic of user-triggered camera, with each step corresponding to a link in the real business, ensuring the business authenticity of the test; simulating usage time after successful camera activation and returning to the sales page ensures that after each round of testing, the user returns to the initial main page, not affecting the execution of the next loop, achieving sustainable testing loops.
[0095] In one possible embodiment, in S3, the application crash rate calculation formula is:
[0096]
[0097] In the formula, This represents the total number of test operations. Total number of application crashes;
[0098] The formula for calculating the camera trigger failure rate is as follows:
[0099]
[0100] In the formula, This represents the total number of camera link-triggered operations. This represents the total number of times the camera failed to trigger.
[0101] Specifically, the two metrics correspond to different dimensions of quality assessment, and the statistical methods adhere to the rationality of business logic: Application crash rate is a key indicator for measuring the overall stability of the application. Using the total number of operations as the denominator and the number of crashes as the numerator, the calculated ratio reflects the probability of a crash occurring with each operation. This metric can be used for horizontal comparisons of stability across different versions and devices, quantitatively assessing improvements or declines in application quality. Camera trigger failure rate is a specific metric for measuring the reliability of the camera-linked link. Using the total number of camera link operations as the denominator is because failure events only occur in camera link trigger scenarios. Only counting the failure percentage of this type of operation accurately reflects the reliability of the mini-program's camera-linked link, avoiding the distortion caused by including ordinary operations in the denominator, and ensuring the business rationality and accuracy of the metric statistics.
[0102] In one possible embodiment, S3 further includes performing the next operation at a preset test interval:
[0103]
[0104] In the formula, This is a normal operating interval. For camera link operation interval;
[0105] After each preset number of test operations is completed, the real-time test progress is output, which includes the average operation frequency and abnormal statistics.
[0106] The formula for calculating the average operating frequency is:
[0107]
[0108] In the formula, Total test duration This represents the total number of test operations.
[0109] Specifically, the main logic of categorized test intervals is to match the business time consumption of different operations. Ordinary click and swipe operations only involve page UI responses and have short durations; setting a shorter interval can increase test pressure. Camera link operations involve page navigation, API calls, and hardware camera activation; the business chain is longer and takes longer. Setting a longer interval ensures that the next operation is executed only after the previous one has finished, avoiding test anomalies caused by operation overlap and resource conflicts, and ensuring test stability. Real-time progress output improves the controllability of the testing process. Testers can monitor test progress, current operation rate, and anomaly occurrences in real time without needing to view complete logs, facilitating timely detection of test anomalies and adjustment of test strategies. Average operation frequency is a quantitative indicator of test execution efficiency, reflecting the number of operations completed per unit time. It can be used to evaluate the execution efficiency of test scripts and to compare test execution speeds across different hardware configurations.
[0110] In one possible embodiment, in S3, the preset termination condition includes reaching a preset total number of operands and receiving a manual termination command;
[0111] The preset termination condition logical expression is:
[0112] After a single operation is completed:
[0113] In the formula, This represents the current number of operations completed, initially... , To preset the total number of operations, This is a manual termination signal. This indicates that a termination command has been received. This indicates that the item has not been received.
[0114] Specifically, the dual-termination condition design balances the needs of quantitative standardized testing and flexible interruption, adapting to different testing scenarios: The preset total number of operands termination is suitable for quantitative stability testing and regression testing, such as performing 10,000 operations to verify application crash rates. Stopping after reaching the preset number ensures consistent sample size for each test, guaranteeing comparability of results across different rounds and meeting the requirements of standardized testing. The manual termination command is suitable for exploratory testing and infinite loop stress testing. Testers can send a stop command at any time to interrupt the test when they discover problems or achieve expected results, without waiting for the preset number of operations to complete, improving testing flexibility and efficiency. The auto-incrementing counter logic is the foundation of loop control; the counter increments by 1 for each valid operation, achieving precise control of the loop count by comparing it with the preset total number of operands. The manual termination signal, by listening to external inputs such as console commands or stop buttons, enables asynchronous interruption of the test process, ensuring flexible test control.
[0115] This embodiment uses an application test of a certain brand of smart vending machine (Android 7.1 system, screen resolution 1080x1920) as an example to illustrate the implementation process of the present invention:
[0116] Step 1: Initialize the test instance
[0117] Create a test instance using Python code and configure specific test parameters, as shown below:
[0118] Python
[0119] vending_test=VendingMachineTest(
[0120] package_name="com.leomaster.biubiu", #vending machine application package name
[0121] adb_path="adb", #ADB tool path
[0122] qr_btn_x=(86,290), #X-axis coordinate range of the QR code button
[0123] qr_btn_y=(1760,1840), # Y-axis coordinate range of the QR code button
[0124] manual_operate_time=3, # Manual operation window period in the mini-program (3 seconds)
[0125] normal_throttle=100, # Normal operation interval (100ms)
[0126] qr_camera_throttle=3000 # Camera link operation interval (3000ms)
[0127] )".
[0128] Step 2: Perform the test
[0129] The `run_test` method is called to execute the test, with a total number of test operations configured to 4000, and an infinite loop mode enabled. The code is as follows:
[0130] Python
[0131] #Execute 4000 operations, infinite loop mode (you can manually continue the loop after reaching 4000 operations).
[0132] vending_test.run_test(total_ops=4000,loop_test=True)".
[0133] Step 3: Test Process Description
[0134] 1. Initialization Phase: The system executes the grant_all_permissions method to grant applications necessary permissions such as camera, network, and storage in batches; it executes the ADB command "wmsize" through the get_device_resolution method to parse the vending machine screen resolution as 1080x1920, overriding the default parameters and adapting to the operation coordinates; it executes the clean_camera_process method to clean up residual camera processes and release hardware resources.
[0135] 2. Test Loop Phase: In each loop, the operation type is selected using a random algorithm. If it is a "touch" operation, the `random_click_coordinate` method generates random coordinates within the product area, such as (500, 800), and executes the ADB click command. If it is a "motion" operation, the `slide_coordinate` method generates a sliding start point (such as (500, 1000)) and an end point (such as (500, 500)), and executes the ADB sliding command. If it is a "qr_camera" operation, the bottom QR code button is clicked, and the coordinates are randomly within the range of (86-290, 1760-1840). The `qrcode_refresh` interface is called to refresh the QR code information, and a 3-second manual operation window is entered. The `wechat_ready` / `wechat_go` interface is called to complete the transmission of mini-program linkage parameters. After the window ends, the `get_app_camera_status` method checks whether the camera process is running. If it is not running, the number of camera trigger failures is counted.
[0136] 3. Test Termination Phase: After the tester manually interrupts the test, the system calls the generate_final_report method to generate the final test report, which includes the total number of operations (4000), total test duration, average operation frequency, number of application crashes, number of camera trigger failures, crash rate, camera trigger failure rate, peak and average memory usage, and log storage path, to facilitate testers in analyzing test results and locating problems.
[0137] The application scenarios of this invention are as follows:
[0138] Smart vending machine factory acceptance testing scenario: Applicable to smart vending machine manufacturers and equipment quality inspection departments during the factory quality inspection of vending machines, adapting to the functional verification of vending machine equipment with different hardware configurations and screen resolutions. Traditional methods rely on testers to manually complete the entire acceptance process, including scanning codes, mini-program linkage, and camera activation, resulting in low testing efficiency, high difficulty in batch testing, and incomplete sampling coverage. This solution achieves fully automated testing, supports simultaneous testing of batch devices, and significantly improves the efficiency of factory quality inspection and the coverage of functional verification.
[0139] Regression testing scenario: Suitable for vending machine software R&D and maintenance teams in the regression testing phase after application version updates and function iterations, and adapted to the repetitive verification work of the main business process of the mini-program linked camera; the traditional method requires manual repeated reproduction of the complete business link to carry out regression verification, which is cumbersome and prone to human error and inconsistent testing standards. This solution performs multiple simulation operations in a loop to complete regression testing in a standardized manner and avoids various problems caused by manual testing.
[0140] Multi-device compatibility testing scenario for vending machines: This solution is suitable for vending machine product development departments and third-party professional testing organizations to conduct multi-device adaptation testing, adapting to various vending machine terminals with different Android system versions, screen sizes, and resolutions. Traditional methods require manually modifying operation coordinates and repeatedly building test environments for each device, resulting in long adaptation cycles and high labor costs. This solution identifies screen resolution and adapts operation coordinates accordingly, eliminating the need for secondary manual debugging and efficiently completing multi-device compatibility testing.
[0141] Routine stability inspection of offline vending machines: This solution is suitable for vending machine operators and on-site maintenance teams to conduct online inspections of deployed offline equipment. It is compatible with long-term, high-frequency stress testing and equipment status monitoring 24 / 7. Traditional manual testing cannot achieve uninterrupted continuous testing and is difficult to detect low-probability hidden faults such as memory leaks, camera process remnants, and occasional application crashes. This solution supports infinite loop automated stress testing, collects process and memory data in real time, and achieves long-term automated inspection of offline equipment.
[0142] Cross-platform link testing scenario between mini-programs and vending machine cameras: This solution is suitable for mini-program development teams and vending machine development teams to conduct cross-platform interface integration and business link testing. It is compatible with the entire link process detection of QR code generation, interface calls, parameter passing, and camera wake-up. Traditional manual testing can only determine the overall link connectivity and cannot accurately distinguish fault nodes such as interface timeouts, call failures, and camera wake-up anomalies. This solution monitors the entire link in stages, and with the interface retry mechanism and anomaly statistics function, it can quickly locate the link fault location.
[0143] It should be noted that the method of this embodiment can be executed by a single device, such as a computer or server. The method of this embodiment can also be applied to a distributed scenario, where multiple devices cooperate to complete the task. In such a distributed scenario, one of these devices may execute only one or more steps of the method of this embodiment, and the multiple devices will interact with each other to complete the automated testing method for the vending machine mini-program linked to the camera.
[0144] It should be noted that the above description describes some embodiments of this disclosure. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in a different order than that shown in the above embodiments and still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0145] Example 2
[0146] See Figure 3 Embodiment 2 of the present invention also provides an automated testing system for a vending machine mini-program linked to a camera, employing the aforementioned automated testing method for a vending machine mini-program linked to a camera, including:
[0147] Test environment initialization unit 100: Used for initializing the test environment, configuring test parameters, creating a log storage directory and generating log files with timestamps, granting necessary permissions to the vending machine application, obtaining the vending machine screen resolution and adapting the operation coordinates, and cleaning up residual camera processes.
[0148] Operation list construction unit 200: used to construct an operation list including product clicks, product list scrolling, and camera link triggers based on a preset weight allocation strategy;
[0149] Test loop execution unit 300: Used to perform test operations in a loop. In each loop, it first checks the current active page. If it is an abnormal page / camera interaction page that is not the main sales page, it performs a return operation to reset to the main sales page. Then it checks the application running status and camera process status, counts the number of application crashes and camera trigger failures, and cleans up residual camera processes periodically during the test run. Then it selects the operation type and executes the corresponding test operation through a weighted random sampling algorithm until the preset termination condition is reached.
[0150] Test report generation unit 400: Used to collect test data after test termination and generate a final test report including the log storage path. The test data includes total test duration, cumulative number of operations, average operation frequency, application crash rate, camera trigger failure rate, peak memory usage, and average memory usage.
[0151] It should be noted that the information interaction and execution process between the modules of the above-mentioned device are based on the same concept as the method embodiment in Embodiment 1 of this application, and the resulting technical effects are the same as those in the method embodiment of this application. For details, please refer to the description in the method embodiment shown above in this application, and it will not be repeated here.
[0152] Example 3
[0153] Embodiment 3 of the present invention provides a non-transitory computer-readable storage medium storing program code for an automated testing method of a vending machine mini-program linked to a camera. The program code includes instructions for executing the automated testing method of the vending machine mini-program linked to a camera as described in Embodiment 1 or any possible implementation thereof.
[0154] Computer-readable storage media can be any available medium that a computer can access, or a data storage device such as a server or data center that integrates one or more available media. The available medium can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).
[0155] Example 4
[0156] Embodiment 4 of the present invention provides an electronic device, including: a memory and a processor;
[0157] The processor and the memory communicate with each other via a bus; the memory stores program instructions that can be executed by the processor, and the processor can execute the automated testing method for the vending machine mini-program linked to the camera according to Embodiment 1 or any possible implementation thereof by calling the program instructions.
[0158] Specifically, a processor can be implemented in hardware or software. When implemented in hardware, the processor can be a logic circuit, an integrated circuit, etc. When implemented in software, the processor can be a general-purpose processor that reads software code stored in memory. This memory can be integrated into the processor or located outside the processor and exist independently.
[0159] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means.
[0160] It is obvious to those skilled in the art that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby storing them in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those presented herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.
[0161] Although the present invention has been described in detail above with general descriptions and specific embodiments, modifications or improvements can be made to it, which will be obvious to those skilled in the art. Therefore, all such modifications or improvements made without departing from the spirit of the present invention fall within the scope of protection claimed by the present invention.
Claims
1. An automated testing method for a vending machine mini-program linked to a camera, characterized in that, include: S1. Initialize the test environment, configure test parameters, create a log storage directory and generate log files with timestamps, grant necessary permissions to the vending machine application, obtain the vending machine screen resolution and adapt it to the operation coordinates, and clean up residual camera processes. S2. Based on a preset weight allocation strategy, construct an operation list including product clicks, product list scrolling, and camera link triggers; S3. Execute the test operation in a loop. In each loop, first check the current active page. If it is an abnormal page / camera interaction page that is not the main sales page, then perform a return operation to reset to the main sales page. Next, the application running status and camera process status are checked, the number of application crashes and camera trigger failures are counted, and residual camera processes are cleaned up periodically during the test run. Then, the operation type is selected and the corresponding test operation is executed through a weighted random sampling algorithm until the preset termination condition is reached. S4. After the test is terminated, the test data is statistically analyzed and a final test report including the log storage path is generated. The test data includes the total test duration, cumulative number of operations, average operation frequency, application crash rate, camera trigger failure rate, peak memory usage, and average memory usage.
2. The automated testing method for the vending machine mini-program linked to the camera according to claim 1, characterized in that, In S1, the test parameters include the vending machine application package name, ADB tool path, operation area coordinates, test interval, and mini-program manual operation window period. The test parameters are configured according to the test requirements. The operating area includes a product click area, a swipe area, and a QR code button area; The test intervals include the normal operation interval and the camera link operation interval.
3. The automated testing method for the vending machine mini-program linked to the camera according to claim 1, characterized in that, In S1, the specific process of obtaining the screen resolution of the vending machine is as follows: The ADB command "wmsize" is executed and the returned resolution result is parsed. The actual screen resolution obtained is used to overwrite the default resolution parameter. The operation coordinates of vending machine devices of different sizes and resolutions are adapted using an equal-proportion coordinate conversion formula. The proportional coordinate conversion formula is as follows: In the formula, Based on the baseline screen resolution, The actual screen resolution of the device being tested. The original operational coordinates at the reference resolution. The actual operating coordinates of the current device after adaptation.
4. The automated testing method for the vending machine mini-program linked to the camera according to claim 1, characterized in that, In S2, the duration of the manual operation window in the mini-program is customizable during the camera link triggering operation; both the QR code refresh interface and the mini-program linkage interface are configured with a retry mechanism, with a default retry count of no less than 3 times, and a retry is triggered when the interface call fails. The retry logic formula is as follows: In the formula, This represents the maximum number of retries. This is the current number of retries, initially. , This is the interval between retry attempts. Mark the result of the API call. For the call to be successful, The call failed. The weight allocation strategy adopts the following weight normalization constraint formula: In the formula, For product click weight, Sliding weights for the product list The camera link triggers weights.
5. The automated testing method for the vending machine mini-program linked to the camera according to claim 1, characterized in that, In S3, the specific process of detecting the application running status and the camera process status includes: obtaining the vending machine application PID process identifier, TotalPSS memory usage index, and camera process running status; if the application process is detected to be non-existent, it is determined that the application has crashed, and the number of crashes is counted; if the camera process does not start after the window period ends, it is determined that the camera triggering has failed, and the number of failures is counted.
6. The automated testing method for the vending machine mini-program linked to the camera according to claim 1, characterized in that, In S3, the specific process of selecting the operation type and executing the corresponding test operation through the random algorithm includes: If it is a touch operation, generate random coordinates within the product area, execute the ADB click command, and simulate the user's click behavior on the product; If it is a motion operation, generate the start / end coordinates of the list swiping, execute the ADB swiping command, and simulate the user's behavior of swiping the product list; If it is a qr_camera operation, click the QR code button at the bottom to trigger the loading of a new QR code page; wait for the new page and QR code to finish rendering; enter the manual operation window of the mini program, call the QR code refresh interface and the mini program linkage interface to complete the parameter passing; after the window ends, check whether the camera process has been successfully launched. If the launch fails, count the number of camera trigger failures; if the launch is successful, simulate the camera usage time and then return to the sales page.
7. The automated testing method for vending machine mini-program linked to a camera according to claim 1, characterized in that, In S3, the application crash rate calculation formula is as follows: In the formula, This represents the total number of test operations. Total number of application crashes; The formula for calculating the camera trigger failure rate is as follows: In the formula, This represents the total number of camera link-triggered operations. This represents the total number of times the camera failed to trigger.
8. The automated testing method for the vending machine mini-program linked to the camera according to claim 1, characterized in that, S3 also includes executing the next operation at a preset test interval: In the formula, This is a normal operating interval. For camera link operation interval; After each preset number of test operations is completed, the real-time test progress is output, which includes the average operation frequency and abnormal statistics. The formula for calculating the average operating frequency is: In the formula, Total test duration This represents the total number of test operations.
9. The automated testing method for the vending machine mini-program linked to the camera according to claim 1, characterized in that, In S3, the preset termination conditions include reaching a preset total number of operations and receiving a manual termination command; The preset termination condition logical expression is: After a single operation is completed: In the formula, This represents the current number of operations completed, initially... , To preset the total number of operations, This is a manual termination signal. This indicates that a termination command has been received. This indicates that the item has not been received.
10. An automated testing system for a vending machine mini-program linked to a camera, employing the automated testing method for a vending machine mini-program linked to a camera as described in any one of claims 1-9, characterized in that, include: Test environment initialization unit: Used for initializing the test environment, configuring test parameters, creating a log storage directory and generating log files with timestamps, granting necessary permissions to the vending machine application, obtaining the vending machine screen resolution and adapting it to the operation coordinates, and cleaning up residual camera processes; The operation list construction unit is used to construct an operation list including product clicks, product list scrolling, and camera link triggers based on a preset weight allocation strategy. Test loop execution unit: Used to perform test operations in a loop. In each loop, the current active page is checked first. If it is an abnormal page / camera interaction page that is not the main sales page, a return operation is performed to reset to the main sales page. Next, the application running status and camera process status are checked, the number of application crashes and camera trigger failures are counted, and residual camera processes are cleaned up periodically during the test run. Then, the operation type is selected and the corresponding test operation is executed through a weighted random sampling algorithm until the preset termination condition is reached. Test report generation unit: Used to collect test data after test termination and generate a final test report including the log storage path. The test data includes total test duration, cumulative number of operations, average operation frequency, application crash rate, camera trigger failure rate, peak memory usage, and average memory usage.
