Application program testing method and device
Through a variety of testing methods, combining visual positioning and learning models to identify application elements, generate random operation sequences and preset model test cases, solving the problem of low accuracy in traditional testing methods and achieving more comprehensive test coverage and accuracy improvement.
Patent Information
- Application Number
- CN202510688221.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-26
- Publication Date
- 2025-07-18
AI Technical Summary
Traditional application testing methods cannot dynamically adapt to interface element changes, and it is difficult to cover the long-tail scenarios of users' real behavior, resulting in low test accuracy, especially when the business logic in the financial and e-commerce fields is complex, which cannot effectively cover the functional defects in the deep water area.
Various methods are used to test applications at different stages of the test process, including executing random operation sequences, generating preset model test cases, and identifying target operation sequences from application logs, combining visual positioning, document object model analysis and learning models for element recognition, generating multi-dimensional response data and storing test results.
It improves the accuracy of application testing, can cover various test scenarios more comprehensively, discover complex business logic errors, and improves the comprehensiveness and accuracy of tests.
Smart Images

Figure CN120336191A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular, to a method and device for testing an application program. Background Art
[0002] Traditional software testing technologies require writing fixed scripts in advance, and cannot dynamically adapt to changes in interface elements (such as button ID updates and page layout adjustments), relying too much on test scripts. In addition, it is difficult for manually designed test cases to cover the long-tail scenarios of users' real behaviors (such as unconventional operation sequences and boundary value inputs). Front-end function testing, back-end interface testing, and data consistency verification are separated from each other, lacking end-to-end closed-loop verification, and it is difficult to discover complex business logic errors (such as inventory overselling and payment status out-of-sync in concurrent scenarios) during the use of application programs through conventional testing. In addition, in the fields of financial technology and e-commerce technology, the business logic is complex and the user behaviors are diverse. Traditional testing tools cannot effectively cover the functional defects in the deep water area, resulting in a low accuracy rate for testing application programs. Summary of the Invention
[0003] Embodiments of this application provide a method and device for testing an application program to at least solve the technical problem of low accuracy rate in testing application programs in related technologies.
[0004] According to one aspect of the embodiments of this application, a method for testing an application program is provided, including: receiving an application program to be tested; testing the application program to be tested in different stages of the test process by using multiple methods respectively to obtain test results, where the multiple methods include at least one of the following: performing testing by using an actuator to execute a random operation sequence, generating test cases by using a preset model and completing testing based on the test cases, and identifying a target operation sequence that meets preset conditions from the log of the application program to be tested and performing testing according to the target operation sequence; storing the test results.
[0005] Optionally, performing testing by using an actuator to execute a random operation sequence includes: identifying elements in the interface of the application program to be tested by using multiple identification methods to obtain identification results, where the multiple identification methods include at least one of the following: identifying by visual positioning, parsing the document object model of the interface of the application program to be tested, and identifying text adjacent to the elements in the interface of the application program to be tested, and the identification results at least include the type of each element; determining the operation weights of multiple operations corresponding to each element according to the type of each element; generating multiple random operation sequences according to the operation weights of the multiple operations corresponding to each element; using the actuator to execute the multiple random operation sequences, and collecting multi-dimensional response data of the multiple random operation sequences; generating a test result according to the response data.
[0006] Optionally, multiple recognition methods are used to recognize the elements in the application interface to be tested, and the recognition result is obtained, including: matching a pre-determined template with the elements in the application interface to be tested, and determining the first sub-recognition result of the elements with successful matching. Wherein, the pre-determined template contains element features, and the first sub-recognition result contains the position and size of the elements; obtaining the document object model of the application interface to be tested and extracting the features of each element from the document object model; using a learning model to analyze the features of each element to obtain a second sub-recognition result, and the second sub-recognition result at least includes the type of the element and the attributes of the element; determining a third sub-recognition result according to the position of each element and the text content corresponding to the text adjacent to each element, and the third sub-recognition result includes the function of each element; forming the recognition result according to the first sub-recognition result, the second sub-recognition result and the third sub-recognition result.
[0007] Optionally, a preset model is used to generate test cases and complete the test based on the test cases, including: obtaining screen recording data, where the screen recording data includes a video of the interaction between the application interface to be tested and the user; extracting a plurality of video frames from the screen recording data at preset time intervals, and detecting the elements and element states operated by the user from the plurality of video frames respectively; traversing all the elements operated by the user and the changes in the element states before and after the user operations to generate an operation sequence diagram, where the nodes in the operation sequence diagram represent the elements to be operated, and the edges in the operation sequence diagram represent the operation paths; using the preset model to analyze the operation sequence diagram to generate the test cases; completing the test of the application to be tested based on the test cases.
[0008] Optionally, using the preset model to analyze the operation sequence diagram to generate the test cases includes: obtaining a state space, where the state space includes: a set of elements in the application interface to be tested and the historical operation paths of the application interface to be tested. Wherein, the historical operation paths include: the operation paths corresponding to the operation sequence diagram and the operation paths corresponding to the random operation sequences; obtaining a reward function, where the reward function is determined according to the path coverage rate corresponding to the generated test case and whether the path corresponding to the test case repeats the historical operation path; using the preset model to generate a plurality of candidate test cases, and selecting the candidate path with the largest reward function value from the candidate paths corresponding to the plurality of candidate test cases as the target path, and generating the test case based on the target path.
[0009] Optionally, the method further includes: creating an abnormal input data set, where the abnormal input data set includes: adding a string with a length greater than a preset length and special characters to the input data; generating an abnormal operation path based on the abnormal input data set; generating a reverse operation path according to the historical operation path; respectively executing the abnormal operation path and the reverse operation path, and collecting the response data to complete the test.
[0010] Optionally, identifying a target operation sequence that meets a preset condition from the log of the application under test and performing a test according to the target operation sequence includes: obtaining the log of the application under test, and performing regularization processing on the log of the application under test to obtain a processed log; extracting user operation logs from the processed log, and grouping the user operation logs according to user identifiers to obtain the operation logs of each user; constructing an operation sequence for each user according to the operation logs of each user; detecting, from the operation sequences of each user, operation sequences with an operation frequency higher than a preset frequency and abnormal operation sequences, and determining the operation sequences with an operation frequency higher than the preset frequency and the abnormal operation sequences as the target operation sequences; simulating and concurrently executing the target operation sequences to obtain a test result.
[0011] According to another aspect of the embodiments of the present application, there is also provided a test device for an application, including: a receiving module, configured to receive an application under test; a testing module, configured to perform tests on the application under test in multiple ways respectively to obtain a test result, where the multiple ways include at least one of the following: performing a test by executing a random operation sequence using an executor, generating test cases using a preset model and completing the test based on the test cases, identifying a target operation sequence that meets a preset condition from the log of the application under test and performing a test according to the target operation sequence; a storage module, configured to store the test result.
[0012] According to yet another aspect of the embodiments of the present application, there is also provided a computer device, including: a memory and a processor, where the memory is used to store program instructions; the processor is connected to the memory and is configured to execute the above-mentioned test method for an application.
[0013] According to yet another aspect of the embodiments of the present application, there is also provided a computer device, including: a memory and a processor, where the memory is used to store program instructions; the processor is connected to the memory and is configured to execute the above-mentioned test method for an application.
[0014] According to still another aspect of the embodiments of the present application, there is also provided a computer program product, including computer instructions, where when the computer instructions are executed by a processor, the above-mentioned test method for an application is implemented.
[0015] In the embodiments of the present application, a to-be-tested application program is received; the to-be-tested application program is tested in different stages of the test process by various methods respectively to obtain test results, where the various methods include at least one of the following: testing by executing a random operation sequence using an executor, generating test cases using a preset model and completing the test based on the test cases, identifying a target operation sequence that meets preset conditions from the to-be-tested application program log and performing a test according to the target operation sequence; storing the test results. By testing the to-be-tested application program using different test methods in different stages of the test, test results are obtained, achieving the purpose of testing various test scenarios, thereby realizing the technical effect of improving the test accuracy of the application program, and further solving the technical problem of low test accuracy of the application program in the related art. Description of the Drawings
[0016] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation to the present application. In the drawings:
[0017] Figure 1 is a hardware structure block diagram of a computer terminal for implementing a test method of an application program according to an embodiment of the present application;
[0018] Figure 2 is a flowchart of a test method of an application program according to an embodiment of the present application;
[0019] Figure 3 is a flowchart of element recognition in an application program interface according to an embodiment of the present application;
[0020] Figure 4 is a flowchart of generating test instances using a preset model according to an embodiment of the present application;
[0021] Figure 5 is a flowchart of performing a test according to the log analysis result according to an embodiment of the present application;
[0022] Figure 6 is a structure diagram of a test system of an application program according to an embodiment of the present application;
[0023] Figure 7 is a structure diagram of a test device of an application program according to an embodiment of the present application. Detailed Embodiments
[0024] To enable those skilled in the art to better understand the solution of this application, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of this application.
[0025] It should be noted that the terms "first", "second", etc. in the description and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily need to be used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of this application described here can be implemented in an order other than those illustrated or described here. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device including a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0026] The information collected in the embodiments of this application is information and data authorized by the user or fully authorized by all parties. Moreover, the processing of relevant data, such as collection, storage, use, processing, transmission, provision, disclosure and application, complies with the relevant laws, regulations and standards in the relevant regions, takes necessary confidentiality measures, does not violate public order and good customs, and provides corresponding operation entrances for users to choose to authorize or reject the results of automated decision-making; if the user chooses to reject, the expert decision-making process will be entered.
[0027] To solve the problems existing in the related art, the embodiments of this application provide a method for testing an application program, which can run on Figure 1 the computer terminal shown below. The following is an explanatory description of this computer terminal.
[0028] The method embodiments for testing an application program provided by the embodiments of this application can be executed on a mobile terminal, a computer terminal or a similar computing device. Figure 1 The following shows a hardware structure block diagram of a computer terminal for implementing the method for testing an application program. As Figure 1As shown, the computer terminal 10 may include one or more processors (illustrated as 102a, 102b, ……, 102n in the figure) (the processor may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission module 106 for communication functions connected via a wired and / or wireless network. In addition, it may further include: a display, a keyboard, a cursor control device, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, and a BUS bus. Those of ordinary skill in the art can understand that Figure 1 the structure shown is only illustrative and does not limit the structure of the above-mentioned electronic device. For example, the computer terminal 10 may further include more or fewer components than Figure 1 shown therein, or have a different configuration from Figure 1 that shown.
[0029] It should be noted that the above one or more processors and / or other data processing circuits are generally referred to as "data processing circuits" herein. The data processing circuit may be embodied in whole or in part as software, hardware, firmware, or any combination thereof. In addition, the data processing circuit may be a single independent processing module, or be incorporated in whole or in part into any one of the other elements in the computer terminal 10. As involved in the embodiments of the present application, the data processing circuit is a processor control (such as the selection of a variable resistor terminal path connected to an interface).
[0030] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the test method of the application program in the embodiments of the present application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, implements the above-mentioned test method of the application program. The memory 104 may include a high-speed random access memory, and may further include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memories. In some instances, the memory 104 may further include a memory remotely located relative to the processor, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above network include, but are not limited to, the Internet, an enterprise intranet, a local area network, a mobile communication network, and combinations thereof.
[0031] The transmission module 106 is used to receive or send data via a network. Specific examples of the above-mentioned network may include a wireless network provided by the communication provider of the computer terminal 10. In one example, the transmission module 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission module 106 can be a Radio Frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0032] The display can be, for example, a touch-screen liquid crystal display (LCD), which enables the user to interact with the user interface of the computer terminal 10.
[0033] It should be noted here that in some alternative embodiments, the above Figure 1 illustrated computer terminal may include hardware elements (including circuits), software elements (including computer code stored on a computer-readable medium), or a combination of both hardware elements and software elements. It should be pointed out that Figure 1 is only an example of a specific specific instance and is intended to illustrate the types of components that may exist in the above computer terminal.
[0034] Under the above operating environment, an embodiment of a method for testing an application program is provided in the embodiments of the present application. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.
[0035] Figure 2 is a flowchart of a method for testing an application program according to an embodiment of the present application. As Figure 2 shown, the method includes the following steps:
[0036] Step S202, receiving the application program to be tested;
[0037] Step S204, testing the application program to be tested in different stages of the test process in multiple ways respectively to obtain test results, where the multiple ways include at least one of the following: testing by executing a random operation sequence using an executor, generating test cases using a preset model and completing the test based on the test cases, and identifying a target operation sequence that meets preset conditions from the log of the application program to be tested and performing the test according to the target operation sequence;
[0038] Step S206, storing the test results.
[0039] Through the above steps S202 to S206, the method includes receiving the application to be tested; testing the application to be tested in different stages of the test process in multiple ways respectively to obtain test results, where the multiple ways include at least one of the following: using an executor to execute a random operation sequence for testing, using a preset model to generate test cases and completing the test based on the test cases, identifying a target operation sequence that meets preset conditions from the log of the application to be tested and performing testing according to the target operation sequence; storing the test results. By testing the application to be tested in different ways in different stages of the test, test results are obtained, achieving the purpose of testing various test scenarios, thereby realizing the technical effect of improving the test accuracy of the application, and further solving the technical problem of low test accuracy of the application in the related art. The following is a detailed description.
[0040] In step S204, in the case of using an executor to execute a random operation sequence for testing, the specific testing method is as follows: using multiple recognition methods to recognize the elements in the interface of the application to be tested to obtain recognition results, where the multiple recognition methods include at least one of the following: recognizing through visual positioning, parsing the document object model of the interface of the application to be tested and recognizing the text adjacent to the elements in the interface of the application to be tested, and the recognition results at least include the type of each element; determining the operation weights of multiple operations corresponding to each element according to the type of each element; generating multiple random operation sequences according to the operation weights of multiple operations corresponding to each element; using the executor to execute the multiple random operation sequences and collecting multi-dimensional response data of the multiple random operation sequences; generating test results according to the response data.
[0041] Among them, the specific steps of using multiple recognition methods to recognize the elements in the interface of the application to be tested to obtain recognition results are as follows: using a pre-determined template to match the elements in the interface of the application to be tested and determining the first sub-recognition result of the successfully matched elements, where the pre-determined template contains element features, and the first sub-recognition result contains the position and size of the elements; obtaining the document object model of the interface of the application to be tested and extracting the features of each element from the document object model; using a learning model to analyze the features of each element to obtain a second sub-recognition result, and the second sub-recognition result at least includes the type and attributes of the elements; determining a third sub-recognition result according to the position of each element and the text content corresponding to the text adjacent to each element, and the third sub-recognition result includes the function of each element; forming the recognition result according to the first sub-recognition result, the second sub-recognition result and the third sub-recognition result.
[0042] Specifically, when the test executor RPA (Robotic Process Automation) operates on the interface of an application, the screen capture function is used to capture the currently displayed page content.
[0043] As Figure 3 shown, the first recognition method is to use a pre-determined template, such as various types of buttons, input boxes, etc. The template image is compared with the screenshot to find the exact position of the element on the screen. The template matching process supports fuzzy recognition, that is, a certain degree of visual difference (such as slight changes in color and size) is allowed. As long as the similarity exceeds the similarity threshold (default 85%), it is considered that the matching element has been found.
[0044] For example: For each template, check its matching position and similarity in the screenshot. If the similarity is higher than the set similarity threshold (85%), confirm the existence of the element on the current page and record its position coordinates (the first sub-recognition result).
[0045] The second recognition method is DOM (Document Object Model) parsing to obtain the DOM tree of the current interface. Specific types of elements, such as buttons, input boxes, and dropdown menus, are located from the DOM structure through XPath (XML Path Language) selectors or CSS (Cascading Style Sheets) selectors. The ResNet (Residual Network) model is run to extract features from the attributes (such as tag names, class names, id attributes) of these DOM elements to further classify the element types.
[0046] The third recognition method is to infer through context: Based on the positional relationship of elements and adjacent text, recognize the content of the adjacent text to infer the function of the elements.
[0047] For example: For the "Submit" button, it is usually located near the bottom of the form filling area, and the content of the adjacent text will contain words such as "Submit" and "Save".
[0048] Combine the three recognition results to form a comprehensive list of interface elements, including element types, positions, and functions.
[0049] The following is an example to illustrate the method of generating multiple random operation sequences:
[0050] For the "button" element, among them, the probability of the "click" operation is 0.7, and the probability of the "hover" operation is 0.2.
[0051] The "input box" element is given a weight of 0.8 for the "input" operation and a weight of 0.1 for the "clear" operation.
[0052] The operations of the "scroll bar" element include "scroll_up" (scroll up) and "scroll_down" (scroll down), and the weights are evenly distributed, both being 0.5.
[0053] It can be understood that the weight can be used to represent the probability of an element being operated on.
[0054] The multi-dimensional response data is shown in Table 1 and includes: front-end performance data, network request data, console log data, and interface state snapshot data.
[0055] Table 1
[0056]
[0057] In the embodiments of this application, a data storage method is also provided for storing test results. Specifically, the test results are stored in layers. For example, the test results are divided into hot data (recent test results) and cold data. Among them, the hot data is stored in memory and searched using a real-time search engine. Cold data (historical records): Archived by time partition. For example, the data can be classified and stored according to years, months, or finer time intervals (such as days).
[0058] In the stage of using an executor to execute a random operation sequence for testing, Step 1, login and permission verification: The RPA simulates user login and randomly selects a role (data engineer, analyst, administrator); verifies the permission differences of different roles (for example, an administrator can access the "data lineage management" page, and an analyst can only view reports); randomly generates password strength (weak passwords trigger front-end prompts, and strong passwords pass authentication). Step 2, data source configuration: Randomly select a data source type (Kafka, MySQL, log file) on the "data access" page; generate data source configuration parameters (such as Kafka Topic name, MySQL table structure); detect whether the configuration is successful.
[0059] Step 3, ETL (Extract, Transform, Load) job trigger: Randomly select a configured data source and trigger an ETL job (such as "MySQL→Hive data synchronization"); record the job duration and error logs.
[0060] Obtain test results. For example: Scenario 1: Successful login with weak password → Trigger permission vulnerability warning. Scenario 2: Kafka Topic name contains special characters (such as `!@`), detect whether the front-end input verification intercepts. Scenario 3: ETL job timeout (>300 seconds), automatically capture screenshots and record Flink job manager logs.
[0061] In some embodiments of the present application, the specific process of generating test cases using a preset model and completing tests based on the test cases is as follows: Obtain screen recording data, where the screen recording data includes a video of the interaction between the interface of the application under test and the user; Extract multiple video frames from the screen recording data at preset time intervals, and detect the elements and element states of user operations from the multiple video frames respectively; Traverse all the elements of user operations and the changes in element states before and after user operations to generate an operation sequence diagram, where the nodes in the operation sequence diagram represent the elements being operated, and the edges in the operation sequence diagram represent the operation paths; Use the preset model to analyze the operation sequence diagram to generate the test cases; Complete the test of the application under test based on the test cases.
[0062] As Figure 4 shown, use a video processing tool to capture key frames of the video according to the time interval of the user's operations on the application interface (for example, every 0.5 seconds). This choice of time interval is to ensure that each frame contains complete information about the user's operations, while avoiding excessive duplicate frames, thereby optimizing the processing efficiency.
[0063] Then use an object detection model to process each key frame, identify and label each element in the interface, including their categories (such as buttons, input boxes, dropdown menus, etc.), coordinates on the screen, and the confidence level of model detection. This step is crucial for understanding the interaction between the user and the interface.
[0064] By analyzing the detected elements, construct an operation sequence diagram. Among them, the nodes in the diagram represent interface elements, and the edges represent the operation order from one element to another.
[0065] Specifically, traverse each frame, identify the current element, and compare it with the element in the previous frame. According to the changes in the element and the element states before and after, identify the types of operations performed by the user, such as clicking, entering text, dragging, etc.
[0066] For example: If the current element is different from the previous element, then add a new edge in the diagram to indicate that the user has moved from the previous element to the current element. In this way, reconstruct the complete path of the user's operations.
[0067] In some embodiments of the present application, the steps of analyzing the operation sequence diagram using the preset model to generate the test case are as follows: Obtain a state space, where the state space includes: a set of elements in the application interface to be tested and the historical operation path of the application interface to be tested. Among them, the historical operation path includes: the operation path corresponding to the operation sequence diagram and the operation path corresponding to the random operation sequence; Obtain a reward function, where the reward function is determined according to the path coverage rate corresponding to the generated test case and whether the path corresponding to the test case repeats the historical operation path; Use the preset model to generate multiple candidate test cases, and select the candidate path with the largest reward function value from the candidate paths corresponding to the multiple candidate test cases as the target path, and generate the test case based on the target path.
[0068] It can be understood that the embodiments of the present application use a reinforcement learning model to explore low-coverage operation paths through reinforcement learning for testing.
[0069] For example: Reward for exploring low-coverage paths: coverage represents the proportion of elements and operation paths included in the generated test case that have been tested. novelty = 1 - coverage represents the novelty of the test case.
[0070] Penalty for repeated operations: Determine whether the current path is a repeated action through a conditional expression. If the operation path of the current test case repeats a part of the historical operation path, then set repeat_penalty (repeated penalty) to 0.2, otherwise 0. The penalty for repeated operations is to avoid wasting resources in the parts that the test system is already familiar with and encourage it to find more testing opportunities.
[0071] The method for calculating the comprehensive reward is as follows: The reward value of the path corresponding to the test case is novelty * 0.8 - repeat_penalty.
[0072] To further improve the test effect, in an actual application scenario, the method of inputting an abnormal input data set can be adopted. Specifically, create an abnormal input data set, where the abnormal input data set includes: adding a string with a length greater than the preset length and special characters to the input data; Generate an abnormal operation path based on the abnormal input data set; Generate a reverse operation path according to the historical operation path; Execute the abnormal operation path and the reverse operation path respectively, and collect the response data to complete the test.
[0073] For example: The abnormal operation path includes: inputting the abnormal input data set when inputting the operation path data set and reducing the steps in the normal operation path; The reverse operation path includes: a path opposite to the normal operation path.
[0074] In the stage of generating test cases using a preset model and completing tests based on the test cases, screen recording data analysis: Parse the operation screen recording of the data engineer, and find the high-frequency path: "Login → Create data source → Configure ETL → Submit Spark job → Query data quality report". Extract the key operation timings. Generate test cases: Positive path: Simulate the complete operation chain of the data engineer to verify the end-to-end consistency of the data from access to query. Abnormal path: "Submit ETL job directly without configuring data source → Detect front-end prompts and interface error codes". "Forcefully refresh the page during the running of the Spark job → Monitor whether the job status interface returns intermediate results".
[0075] Obtain test results: It is found that after the ETL job is submitted, the page does not update the status in real time, resulting in users submitting repeatedly → Trigger optimization suggestions for the front-end polling mechanism.
[0076] In some embodiments of the present application, in the deep water area test stage, identify target operation sequences that meet preset conditions from the logs of the application under test and perform tests according to the target operation sequences, specifically as follows: Obtain the logs of the test application and perform regularization processing on the logs of the test application to obtain the processed logs; Extract user operation logs from the processed logs and group the user operation logs according to user identifiers to obtain the operation logs of each user; Construct the operation sequence of each user according to the operation logs of each user; Detect operation sequences with an operation frequency higher than a preset frequency and abnormal operation sequences from the operation sequences of each user, and determine the operation sequences with an operation frequency higher than the preset frequency and abnormal operation sequences as the target operation sequences; Simulate the concurrent execution of the target operation sequences to obtain test results.
[0077] As Figure 5 shown, use regular expression technology to parse and standardize the original log data. For example: Obtain log data such as IP address, timestamp, request method, and URL from the log through regular expressions.
[0078] The process of deep water area testing includes: Aggregate the operation sequences of each user from the log data according to the user identifiers, and use data mining algorithms to determine operation sequences with an operation frequency higher than a preset spectrum from them. For example: The operation sequence of the "Login - Query - Payment" path has an operation frequency higher than the preset frequency,
[0079] Use anomaly detection algorithms to mine abnormal operation sequences. For example, it is detected that some users initiated 1000 queries within a preset duration, exceeding the preset number of operations.
[0080] Simulate user behavior: Extract historical order identifiers from the log to simulate actual user traffic, and execute the target operation sequences for concurrent stress testing.
[0081] While performing stress testing, data consistency also needs to be ensured. This means that even in high concurrency or abnormal situations, the status of various components in the system should remain synchronized and consistent, such as databases, caches, and message queues. By comparing and verifying the status of these components, data integrity issues can be discovered in a timely manner to ensure the correct execution of business logic.
[0082] It should be noted that the interface elements collected during the testing phase using an executor to execute a random operation sequence can be used as a training data set for a preset model. Test cases are generated using the preset model and when an abnormal path is found during the testing phase based on the test cases, a target operation sequence that meets preset conditions is identified from the log of the application to be tested and testing is performed according to the target operation sequence; wherein, the high-frequency operation sequence identified during the log testing phase can be used for high-frequency testing during the testing phase using an executor to execute a random operation sequence.
[0083] In the log-driven testing phase, log analysis: Deepwater identification: parse the backend logs and find high-frequency operations: the average daily call volume is > 1 million times. Users often perform complex queries. Abnormal pattern detection: identify the sudden increase in timeout rate in the early morning hours (conflict with resource scheduling strategy). Perform stress testing: Scenario 1: High-concurrency query: simulate 1,000 concurrent users to execute the target operation path. Monitor the load and query response time (delay needs to be < 2 seconds). Scenario 2: Resource contention test: trigger 10 Spark jobs + 500 concurrent queries at the same time to detect whether the resource allocation strategy is fair. Perform data consistency verification: Cross-system checks: 1. Raw data: the increase in the offset of the Kafka Topic `trade_logs` (a topic in a messaging system). 2. Processing results: the number of records in the Hive table `dw.trade_stats` (a data table). 3. Service layer: the statistical results returned by the API `GET / api / trade_stats` (an API interface).
[0084] Get test results: Hive query results are delayed in updating under high concurrency → locate the HDFS small file merging strategy defect. Resource contention causes Spark (a data processing framework) job failure rate > 15% → trigger dynamic resource allocation algorithm optimization.
[0085] Visualize the test coverage of each module in the actual application scenario, and guide the preset model to test elements and paths in low coverage areas.
[0086] In the process of training the preset model, historical defect classification (such as payment timeout, inventory asynchrony) can be added to the training data set, and the preset model can be trained to generate test cases in a targeted manner.
[0087] Figure 6 shows an application testing system, as Figure 6 shown, including: Data acquisition layer: RPA executor, screen recording parsing module, log analysis engine. Intelligent decision-making layer: AI behavior modeling engine, test case generator, anomaly detection model. Execution feedback layer: multi-stage test executor, result storage and root cause analysis system.
[0088] Figure 7 is a test device for an application according to an embodiment of the present application. The device includes:
[0089] A receiving module 70, configured to receive an application to be tested;
[0090] A testing module 72, configured to test the application to be tested in multiple ways respectively to obtain a test result, where the multiple ways include at least one of the following: performing a test by executing a random operation sequence using an executor, generating a test case using a preset model and completing the test based on the test case, and identifying a target operation sequence that meets a preset condition from the log of the application to be tested and performing a test according to the target operation sequence;
[0091] A storage module 74, configured to store the test result.
[0092] The test device for an application provided by the embodiment of the present application adopts receiving an application to be tested; testing the application to be tested in multiple ways respectively at different stages of the test process to obtain a test result, where the multiple ways include at least one of the following: performing a test by executing a random operation sequence using an executor, generating a test case using a preset model and completing the test based on the test case, and identifying a target operation sequence that meets a preset condition from the log of the application to be tested and performing a test according to the target operation sequence; storing the test result. By testing the application to be tested using different test methods at different stages of the test, a test result is obtained, achieving the purpose of testing various test scenarios, thereby realizing the technical effect of improving the accuracy of application testing, and further solving the technical problem of low accuracy of application testing in the related art.
[0093] The test module 72 includes: a first test sub-module, a second test sub-module, and a third test sub-module. Among them, the first test sub-module is used to perform tests by using an actuator to execute a random operation sequence, including: identifying elements in the application interface to be tested by using multiple identification methods, and obtaining an identification result. Among them, the multiple identification methods include at least one of the following: identifying by visual positioning, parsing the document object model of the application interface to be tested, and identifying the text adjacent to the elements in the application interface to be tested. The identification result at least includes the type of each element; determining the operation weights of multiple operations corresponding to each element according to the type of each element; generating multiple random operation sequences according to the operation weights of multiple operations corresponding to each element; using the actuator to execute the multiple random operation sequences, and collecting multi-dimensional response data of the multiple random operation sequences; generating a test result according to the response data.
[0094] The first test sub-module includes: an identification unit, which is used to identify elements in the application interface to be tested by using multiple identification methods, and obtain an identification result, including: matching a pre-determined template with the elements in the application interface to be tested, and determining the first sub-identification result of the elements with successful matching. Among them, the pre-determined template contains element features, and the first sub-identification result contains the position and size of the element; obtaining the document object model of the application interface to be tested and extracting the features of each element from the document object model; using a learning model to analyze the features of each element to obtain a second sub-identification result, and the second sub-identification result at least includes the type and attributes of the element; determining a third sub-identification result according to the position of each element and the text content corresponding to the text adjacent to each element, and the third sub-identification result includes the function of each element; composing the identification result according to the first sub-identification result, the second sub-identification result, and the third sub-identification result.
[0095] The second test sub-module is used to generate test cases by using a preset model and complete tests based on the test cases, including: obtaining screen recording data, where the screen recording data includes a video of the interaction between the application interface to be tested and the user; extracting multiple video frames from the screen recording data at preset time intervals, and detecting the elements and element states of the user operations from the multiple video frames respectively; traversing all the elements of the user operations and the changes in the element states before and after the user operations to generate an operation sequence diagram, where the nodes in the operation sequence diagram represent the elements to be operated, and the edges in the operation sequence diagram represent the operation paths; using the preset model to analyze the operation sequence diagram to generate the test cases; and completing the test of the application interface to be tested based on the test cases.
[0096] The second test sub-module includes: a generation unit, configured to analyze the operation sequence diagram by using the preset model to generate the test case, including: obtaining a state space, where the state space includes: a set of elements in the application program interface to be tested and a historical operation path of the application program interface to be tested, where the historical operation path includes: an operation path corresponding to the operation sequence diagram and an operation path corresponding to the random operation sequence; obtaining a reward function, where the reward function is determined according to the path coverage rate corresponding to the generated test case and whether the path corresponding to the test case repeats the historical operation path; generating a plurality of candidate test cases by using the preset model, and selecting a candidate path with the largest reward function value from the candidate paths corresponding to the plurality of candidate test cases as the target path, and generating the test case based on the target path.
[0097] The generation unit further includes: a test sub-unit, configured to create an abnormal input data set, where the abnormal input data set includes: adding a string with a length greater than a preset length and special characters to the input data; generating an abnormal operation path based on the abnormal input data set; generating a reverse operation path according to the historical operation path; respectively executing the abnormal operation path and the reverse operation path, and collecting the response data to complete the test.
[0098] The third test sub-module is configured to identify a target operation sequence that meets the preset conditions from the application program log to be tested and perform a test according to the target operation sequence, including: obtaining the application program log to be tested, and performing regularization processing on the application program log to obtain a processed log; extracting user operation logs from the processed log, and grouping the user operation logs according to user identifiers to obtain the operation logs of each user; constructing an operation sequence for each user according to the operation logs of each user; detecting an operation sequence with an operation frequency higher than a preset frequency and an abnormal operation sequence from the operation sequences of each user, and determining the operation sequence with an operation frequency higher than the preset frequency and the abnormal operation sequence as the target operation sequence; simulating concurrent execution of the target operation sequence to obtain a test result.
[0099] It should be noted that Figure 7 the test device of the application program shown is used to execute Figure 2 the test method of the application program shown, so the relevant explanations in the above test method of the application program also apply to this test device of the application program, and will not be elaborated here.
[0100] An embodiment of the present application further provides a computer device, including: a memory and a processor, where the memory is used to store program instructions; the processor is connected to the memory and is configured to execute the above test method of the application program.
[0101] An embodiment of the present application also provides a computer program product, including computer instructions, which implement the steps of the test method of the application program in the present application when executed by a processor.
[0102] The serial numbers of the above embodiments of the present application are only for description and do not represent the advantages or disadvantages of the embodiments.
[0103] In the above embodiments of the present application, the descriptions of the respective embodiments have their own emphases. For the parts not detailed in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.
[0104] In several embodiments provided by the present application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only illustrative. For example, the division of the units can be a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection between each other can be through some interfaces. The indirect coupling or communication connection of units or modules can be in an electrical or other form.
[0105] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place, or they can be distributed to multiple units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0106] In addition, the functional units in each embodiment of the present application can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.
[0107] When the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The foregoing storage medium includes: various media that can store program codes, such as USB flash drives, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), mobile hard disks, magnetic disks, or optical discs.
[0108] The foregoing are only the preferred embodiments of this application. It should be noted that for those of ordinary skill in the art, without departing from the principle of this application, several improvements and refinements can still be made, and these improvements and refinements should also be regarded as the protection scope of this application.
Claims
1. A test method for an application program, characterized in that Including: Receiving an application to be tested; Testing the application to be tested in different stages of the test process by various methods respectively to obtain test results, where the various methods include at least one of the following: testing by executing a random operation sequence using an executor, generating test cases using a preset model and completing the test based on the test cases, identifying a target operation sequence that meets preset conditions from the log of the application to be tested and performing tests according to the target operation sequence; Storing the test results.
2. The method according to claim 1, characterized in that, Testing by executing a random operation sequence using an executor includes: Identifying elements in the interface of the application to be tested by various identification methods to obtain identification results, where the various identification methods include at least one of the following: identifying by visual positioning, parsing the document object model of the interface of the application to be tested and identifying the text adjacent to the elements in the interface of the application to be tested, and the identification results at least include the type of each element; Determining the operation weights of multiple operations corresponding to each element according to the type of each element; Generating multiple random operation sequences according to the operation weights of multiple operations corresponding to each element; Using the executor to execute the multiple random operation sequences and collecting multi-dimensional response data of the multiple random operation sequences; Generating test results according to the response data.
3. The method according to claim 2, wherein Identifying elements in the interface of the application to be tested by various identification methods to obtain identification results, including: Matching a pre-determined template with the elements in the interface of the application to be tested and determining the first sub-identification results of the elements with successful matching, where the pre-determined template contains element features, and the first sub-identification results include the position and size of the elements; Obtaining the document object model of the interface of the application to be tested and extracting the features of each element from the document object model; Analyzing the features of each element using a learning model to obtain second sub-identification results, where the second sub-identification results at least include the type and attributes of the elements; Determining third sub-identification results according to the position of each element and the text content corresponding to the text adjacent to each element, where the third sub-identification results include the functions of each element; Composing the identification results according to the first sub-identification results, the second sub-identification results and the third sub-identification results.
4. The method according to claim 1, wherein Generating test cases using a preset model and completing the test based on the test cases, including: Obtaining screen recording data, where the screen recording data includes a video of the interface of the application to be tested interacting with the user; Extracting multiple video frames from the screen recording data at preset time intervals, and respectively detecting the elements and element states of the user operations from the multiple video frames; Traversing all the elements of the user operations and the changes in the element states before and after the user operations to generate an operation sequence diagram, where the nodes in the operation sequence diagram represent the elements being operated, and the edges in the operation sequence diagram represent the operation paths; Analyzing the operation sequence diagram using the preset model to generate the test cases; Complete the testing of the application to be tested based on the test cases.
5. The method according to claim 4, wherein Analyze the operation sequence diagram using the preset model to generate the test cases, including: Obtain the state space, which includes: a set of elements in the interface of the application to be tested and the historical operation paths of the interface of the application to be tested, where the historical operation paths include: the operation paths corresponding to the operation sequence diagram and the operation paths corresponding to the random operation sequences; Obtain the reward function, which is determined according to the path coverage rate corresponding to the generated test cases and whether the paths corresponding to the test cases are repeated with the historical operation paths; Use the preset model to generate multiple candidate test cases, select the candidate path with the largest reward function value from the candidate paths corresponding to the multiple candidate test cases as the target path, and generate the test cases based on the target path.
6. The method according to claim 5, characterized in that The method further includes: Create an abnormal input data set, where the abnormal input data set includes: adding strings with lengths greater than a preset length and special characters to the input data; Generate abnormal operation paths based on the abnormal input data set; Generate reverse operation paths according to the historical operation paths; Execute the abnormal operation paths and the reverse operation paths respectively, and collect response data to complete the testing.
7. The method according to claim 1, wherein Identify target operation sequences that meet preset conditions from the logs of the application to be tested and perform testing according to the target operation sequences, including: Obtain the logs of the application to be tested and perform regularization processing on the logs of the application to be tested to obtain the processed logs; Extract the user operation logs from the processed logs and group the user operation logs according to the user identifiers to obtain the operation logs of each user; Construct the operation sequences of each user according to the operation logs of each user; Detect operation sequences and abnormal operation sequences with operation frequencies higher than a preset frequency from the operation sequences of each user, and determine the operation sequences with operation frequencies higher than the preset frequency and the abnormal operation sequences as the target operation sequences; Simulate the concurrent execution of the target operation sequences to obtain the test results.
8. A test device for an application program, characterized in that, Include: A receiving module, configured to receive the application to be tested; A testing module, configured to test the application to be tested in multiple ways respectively to obtain the test results, where the multiple ways include at least one of the following: performing testing by executing a random operation sequence using an executor, generating test cases using a preset model and completing the testing based on the test cases, identifying target operation sequences that meet preset conditions from the logs of the application to be tested and performing testing according to the target operation sequences; A storage module, configured to store the test results.
9. A computer device, characterized in that, Include: A memory and a processor, where the memory is used to store program instructions; The processor, connected to the memory, is configured to execute the testing method of the application according to any one of claims 1 to 7.
10. A computer program product, comprising computer instructions, characterized in that, When the computer instructions are executed by the processor, the testing method of the application according to any one of claims 1 to 7 is implemented.